compileBNF: Compile a BNF (Backus-Naur Form) of a context-free grammar.

compileBNFR 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:

  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.

Value

A grammar object (list) with the attributes

  • name: Filename of the grammar.

  • ST: Symbol table.

  • PT: Production table.

  • Start: Start symbol of the grammar.

  • SPT: Short production table.

See Also

Other Grammar: booleanGrammar()

Examples

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

xegaDerivationTrees documentation built on April 16, 2025, 5:11 p.m.