Next: , Up: Grammar File


2.1 Terminal and Nonterminal Symbols

Symbols in semantic grammars represent the grammatical classifications of the language. They are valid Emacs Lisp symbols without special punctuations that require escaping.

A terminal symbol (also known as a lexical token class) represents a class of syntactically equivalent tokens. You use the symbol in grammar rules to mean that a token in that class is allowed. Bison's convention recommends it should be all upper case.

Terminal symbols are part of the lexical tokens returned by the function semantic-lex-analyzer. They indicate what kind of token has been read. For more on lexical analysis, see Writing Lexers.

Terminal symbols are declared using %keyword (see keyword Decl) or %token (see token Decl) statements.

Please note:
Terminal symbols can be literal characters which have the same syntax used in C for character constants; for example, '+' is a literal character token class. A character token class doesn't need to be declared, and can be used in precedence declarations like other terminal symbols (see precedence Decl).
For now semantic lexers don't handle literal characters terminals.

A nonterminal symbol stands for a class of syntactically equivalent groupings. The symbol name is used in writing grammar rules. Bison's convention recommends it should be all lower case.

The symbol error is a terminal symbol reserved for error recovery; you shouldn't use it for any other purpose.