7.1.1.4 Classes

A terminal symbol class is a specification of a set of terminal symbols enclosed in ‘[’ and ‘]’.

An empty terminal symbol class

[ ]

specifies an empty set of terminal symbols.

Note: an empty terminal symbol class [ ] put at the beginning of a branch prevents transferring control to it.

An inclusive terminal symbol class specifies a set of allowed terminal symbols inside ‘[’ and ‘]’. Example: [ "one" "two" "three" ].

The adaptive top-down parser atd-parser on passing the option --eos-marker and the adaptive bottom-up parser abu-parser support specifying the end-of-stream marker $$ as an allowed terminal symbol. Example: [ $$ "one" "two" "three" ].

An inclusive terminal symbol class can encompass a set of named terminal symbol classes previously defined using terminal symbol class expressions (see Symbol Class Expressions). To specify that an inclusive terminal symbol class additionally includes all terminal symbols from a named terminal symbol class TCLAS, put :TCLAS: inside ‘[’ and ‘]’. Example: [ :letters: "one" "two" "three" :arrows: ].

An exclusive terminal symbol class specifies a set of disallowed terminal symbols inside ‘[^’ and ‘]’.

Example

[^ "one" "two" "three" ]

If the set of terminal symbols in the grammar and training terminal symbol sequence is

one two three four five six seven eight nine

the above terminal symbol class contains the terminal symbols

four five six seven eight nine

The adaptive top-down parser atd-parser on passing the option --eos-marker and the adaptive bottom-up parser abu-parser implicitly add the end-of-stream marker $$ to a set of terminal symbols contained in the grammar and training terminal symbol sequences.

In this case, the above terminal symbol class [^ "one" "two" "three" ] will contain the terminal symbols

$$ four five six seven eight nine

To prevent adding the end-of-stream marker to a set of terminal symbols defined by an exclusive terminal symbol class, add $$ to a set of terminal symbols inside ‘[^’ and ‘]’. Example: [^ $$ "one" "two" "three" ].

An exclusive terminal symbol class can exclude terminal symbols contained in named terminal symbol classes previously defined using terminal symbol class expressions (see Symbol Class Expressions). To specify that an exclusive terminal symbol class additionally excludes all terminal symbols contained in a named terminal symbol class TCLAS, put :TCLAS: inside ‘[^’ and ‘]’. Example: [^ $$ :nonterminals: :errors: ].