compileBNF {xegaBNF} | R Documentation |
Compile a BNF (Backus-Naur Form) of a context-free grammar.
Description
compileBNF
produces a context-free grammar
from its specification in Backus-Naur form (BNF).
Warning: No error checking is implemented.
Usage
compileBNF(g, verbose = FALSE)
Arguments
g |
A character string with a BNF. |
verbose |
Boolean. TRUE: Show progress. Default: FALSE. |
Details
A grammar consists of the symbol table ST
, the production
table PT
, the start symbol Start
,
and the short production
table SPT
.
The function performs the following steps:
Make the symbol table. See
makeSymbolTable
.Make the production table. See
makeProductionTable
.Extract the start symbol. See
makeStartSymbol
.Compile a short production table. See
compileShortPT
.Return the grammar.
Value
A grammar object (list) with the attributes
-
name
(the filename of the grammar), -
ST
(symbol table), -
PT
(production table), -
Start
(the start symbol of the grammar), and -
SPT
(the short production table).
References
Geyer-Schulz, Andreas (1997): Fuzzy Rule-Based Expert Systems and Genetic Machine Learning, Physica, Heidelberg. (ISBN:978-3-7908-0830-X)
Examples
g<-compileBNF(booleanGrammar())
g$ST
g$PT
g$Start
g$SPT