|
librdesc
|
seminfo. Often, we shall call these token identifiers terminals, since they appear as terminal symbols in the grammar. The seminfo, if present, contains additional information about the token. This additional information is not part of the grammar.librdesc uses the word token for both meanings: the lexer output as a whole, and the terminal symbol referenced in the grammar. The term terminal is avoided to keep the API surface uniform.
In a traditional context-free grammar (CFG), if multiple alternatives can all match the same input, the grammar is ambiguous – the resulting parse tree is undefined. librdesc grammars are not ambiguous in this sense: they follow ordered-choice semantics.
The / operator is used in librdesc to denote ordered-choice between alternatives.
The following recursive rule matches standard C-style if/then/else statements in such a way that the optional "else" clause always binds to the innermost "if", because of the implicit prioritization of the / operator. (In a context-free grammar, this construct yields the classic dangling else ambiguity.)