Next: , Previous: , Up: top   [Contents][Index]

2 Wisent Grammar

In order for Wisent to parse a language, it must be described by a context-free grammar. That is a grammar specified as rules that can be applied regardless of context. For more information, see (bison)Language and Grammar, in the Bison manual.

The formal grammar is formulated using terminal and nonterminal items. Terminals can be Emacs Lisp symbols or characters, and nonterminals are symbols only.

Terminals (also known as tokens) represent the lexical elements of the language like numbers, strings, etc..

For example ‘PLUS’ can represent the operator ‘+’.

Nonterminal symbols are described by rules:


RESULT’ is a nonterminal that this rule describes and ‘COMPONENTS’ are various terminals and nonterminals that are put together by this rule.

For example, this rule:

exp ≡ exp PLUS exp

Says that two groupings of type ‘exp’, with a ‘PLUS’ token in between, can be combined into a larger grouping of type ‘exp’.