isNonTerminal: Is the numeric identifier a non-terminal symbol?

View source: R/BNF.R

isNonTerminalR Documentation

Is the numeric identifier a non-terminal symbol?

Description

isNonTerminal() tests if the numeric identifier is a non-terminal symbol.

Usage

isNonTerminal(Id, ST)

Arguments

Id

A numeric identifier (integer).

ST

A symbol table.

Details

isNonTerminal() is one of the most frequently used functions of a grammar-based genetic programming algorithm. Careful coding pays off! Do not index the symbol table as a matrix (e.g. ST[2,2]), because this is really slow!

Value

  • TRUE if the numeric identifier is a terminal symbol.

  • FALSE if the numeric identifier is a non-terminal symbol.

  • NA if the symbol does not exist.

See Also

Other Utility Functions: derive(), id2symb(), isTerminal(), rules(), symb2id()

Examples

g<-compileBNF(booleanGrammar())
isNonTerminal(1, g$ST)
isNonTerminal(2, g$ST)
isNonTerminal(5, g$ST)
isNonTerminal(12, g$ST)
isNonTerminal(15, g$ST)
identical(isNonTerminal(15, g$ST), NA)


xegaBNF documentation built on May 29, 2024, 10:23 a.m.