makeRule {xegaBNF} | R Documentation |
Transforms a single BNF rule into a production table.
Description
makeRule()
transforms a single BNF rule
into a production table.
Usage
makeRule(Rule, ST)
Arguments
Rule |
A rule. |
ST |
A symbol table. |
Details
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.
Value
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]]
.
Examples
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)
[Package xegaBNF version 1.0.0.0 Index]