Terminal symbols are string literals enclosed in double quotes, for example: "a", "Beta", "foo bar", "2+x".
The character ‘\’ escapes the characters ‘\’ and ‘"’ in string literals.
Terminal symbols fall into three following categories.
The adaptive top-down parser atd-parser on passing the option --eos-marker and the adaptive bottom-up parser abu-parser support the special terminal symbol
$$
for the end-of-stream marker.
It can be an input or, preferably, a put-back terminal symbol.
For abu-parser, or on passing the option --input-parse-units to atd-parser, a top-down template grammar consumes terminal symbols $$ after consuming all terminal symbols from a parse unit.
Without passing --input-parse-units to atd-parser, a top-down template grammar consumes terminal symbols $$ after consuming all terminal symbols from a training terminal symbol sequence.
A top-down template grammar is template one in the sense that it makes it possible to specify terminal symbol placeholders and classes matching multiple terminal symbols for consumption or analysis as one input or put-back terminal symbol.
The terminal symbol placeholder
.
matches any terminal symbol. A terminal symbol class specified inside ‘[’ and ‘]’ matches a terminal symbol belonging to the class.
A parser treats a sequence of input or put-back terminal symbols, terminal symbol placeholders, and terminal symbol classes as a single unit. For example, the sequence
"at" . . . .
is the template for a sequence consisting of five terminal symbols and beginning with the terminal symbol "at".
Use ‘(’ and ‘)’ to split a template sequence into smaller units. For example
( "at" . ) ( . . . )
denotes two units, where the first unit is a sequence consisting of two terminal symbols and beginning with the terminal symbol "at", and the second unit is a sequence consisting of three terminal symbols.
Note: it is generally preferable to use longer sequences of terminal symbols, terminal symbol placeholders, and terminal symbol classes, as longer sequences capture more relations between terminal symbols.
To give a name to a sequence of input or put-back terminal symbols, terminal symbol placeholders, and terminal symbol classes, prepend the name followed by ‘:’ to the sequence. The sequence becomes a named terminal symbol segment. Multiple terminal symbol segments located in various productions of a grammar can have the same name on condition that the terminal symbol segments have the same length counted in terminal symbols. See Named Segments, for more information.
Not all terminal symbols and terminal symbol classes specified in production right-hand sides restrict terminal symbols to consume or analyze. If a terminal symbol or terminal symbol class does not take part in selecting the next production subexpression to execute, a parser interprets the terminal symbol or terminal symbol class as the terminal symbol placeholder ‘.’.
For example, the sequence
"at" . "in" . .
might or might not restrict the first terminal symbol to be "at", but it never restricts the third terminal symbol to be "in".
A parser interprets "in" as ‘.’ there, and "in" suggests a terminal symbol at that position for a grammar developer.