Learn R Programming

xega (version 0.9.0.23)

compileBNF: Compile a BNF.

Description

compileBNF() produces a context-free grammar from its specification in Backus-Naur form (BNF). Warning: No error checking implemented.

Usage

compileBNF(g, verbose = FALSE)

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).

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. An example BNF is provided by booleanGrammar().

The function performs the following steps:

  1. Make the symbol table.

  2. Make the production table.

  3. Extract the start symbol.

  4. Compile a short production table.

  5. Return the grammar.

For a full documentation, see <https://CRAN.R-project.org/package=xegaBNF>

See Also

Other Grammar: booleanGrammar()

Examples

Run this code
g<-compileBNF(booleanGrammar())
g$ST
g$PT
g$Start
g$SPT

Run the code above in your browser using DataLab