compileShortPT {xegaBNF} | R Documentation |
Produces a production table with non-recursive productions only.
Description
compileShortPT()
produces a “short” production table
from a context-free grammar. The short production table does not
contain recursive production rules.
Warning: No error checking implemented.
Usage
compileShortPT(G)
Arguments
G |
A grammar with symbol table |
Details
compileShortPT()
starts with production rules whose
right-hand side contains only terminals.
It incrementally builds up the new PT until at least one
production rule sequence from a non-terminal to a terminal symbol.
The short production rule provides for each non-terminal symbol a minimal finite derivation into terminals. Instead of the full production table, it is used for generating depth-bounded derivation trees.
Value
A (short) production table is a named list with 2 columns.
The first column
(the left-hand side LHS
) is a vector
of non-terminal identifiers.
The second column
(the right-hand side RHS
) is a
vector of vectors of numerical identifiers.
LHS[i]
derives into RHS[i]
.
Examples
g<-compileBNF(booleanGrammar())
compileShortPT(g)