makeRule {xegaBNF} | R Documentation |
makeRule()
transforms a single BNF rule
into a production table.
makeRule(Rule, ST)
Rule |
A rule. |
ST |
A symbol table. |
Because a single BNF rule can provide a set of substitutions, more than one line in a production table may result. The number of substitutions corresponds to the number of lines in the production table.
A named list with 2 elements, namely $LHS
and $RHS
.
The left-hand side $LHS
is
a vector of non-terminal identifiers
and the right-hand side $RHS
is a vector of vectors
of numerical identifiers.
The list represents the substitution of $LHS[i]
by the identifier list $RHS[[i]]
.
c<-booleanGrammar()$BNF
ST<-makeSymbolTable(c)
c<-booleanGrammar()$BNF
b<-strsplit(c,";")[[1]]
a<-b[2:4]
a<-gsub(pattern=";",replacement="", paste(a[1], a[2], a[3], sep=""))
makeRule(a, ST)