powered by
randomDerivationTree() generates a random derivation tree.
randomDerivationTree()
randomDerivationTree(sym, G, maxdepth = 5, CompleteDT = TRUE)
Derivation tree (a nested list).
Non-terminal symbol.
Grammar.
Integer. Maximal depth of the derivation tree.
Boolean. Generate a complete derivation tree? Default: TRUE.
RandomDerivationTree() recursively expands non-terminals and builds a depth-bounded derivation tree.
RandomDerivationTree()
Other Generate Derivation Tree: generateCDT(), generateDerivationTree(), rndsub(), rndsubk(), substituteSymbol()
generateCDT()
generateDerivationTree()
rndsub()
rndsubk()
substituteSymbol()
g<-compileBNF(booleanGrammar()) a<-randomDerivationTree(g$Start, g) b<-randomDerivationTree(g$Start, g, maxdepth=10) c<-randomDerivationTree(g$Start, g, 2, FALSE)
Run the code above in your browser using DataLab