Learn R Programming

xegaDerivationTrees (version 1.0.0.6)

treeInsert: Inserts a subtree into a derivation tree at a node.

Description

treeInsert() inserts a subtree into a tree at a node.

Usage

treeInsert(tree, subtree, node)

Value

A derivation tree.

Arguments

tree

Derivation tree.

subtree

Subtree.

node

Attributed node.

Details

An attributed node is a list whose element node$Index contains an access function to the node. The access function is represented as a string which contains an executable R index expression. All what remains to be done, is

  • to complete the assignment statement and

  • to parse and evaluate the string.

See Also

Other Tree Operations: compatibleSubtrees(), treeExtract()

Examples

Run this code
g<-compileBNF(booleanGrammar())
t1<-randomDerivationTree(g$Start, g)
t2<-randomDerivationTree(g$Start, g)
t1anl<-treeANL(t1, g$ST)
n1<-chooseNode(t1anl$ANL)
t2<-randomDerivationTree(n1$ID, g)
tI1<-treeInsert(t1, t2, n1)
decodeCDT(tI1, g$ST)

Run the code above in your browser using DataLab