13.2.2 Terminals

The Terminal list of the Grammar Definition dialog contains all terminal symbols which belong to the current grammar.

When you press the Clear button all terminal symbols will be removed. Pressing the Remove button only deletes the currently selected terminal symbol. Press the Arrow Up or Arrow Down button to move the selected terminal symbol one row up or down in the list.

When you press the Add, Insert or Edit button of the Terminals list the Layout Definition Terminal dialog shown in figure Defining a terminal will open. If you press the Edit button the dialog will display the current settings of the selected terminal symbol otherwise the dialog's fields will be blank.

Defining a terminal
Defining a terminal

In the Name field enter the name of the terminal symbol. In the Definitions field you must define the terminal symbol. Regular expressions are used to define a terminal. Note: Spaces in terminal definitions are evaluated as any other characters (e.g. “A” or “9”). The supported regular expression operators are listed in the following table.

Supported operators in regular expressions
Operator Description Example
() Group (abc)
* Zero or more occurrences (abc)*
+ One or more occurrences (abc)+
? Zero or one occurrence (abc)?
#n n occurrences (abc)#10
| Alternative abc|def
~ Invert ~(abc)
[] Character set [abc]
[^] Inverted character set [^abc]
[n-m] Character range set [a-z]
\ Escape \*
%xx ASCII code (hexadecimal) %0d%0a
. Wildcard .+
^ Start of field ^abc (column in filter expressions, text in log)
$ End of field abc$

The Layout Definition Terminal dialog also has another useful feature which is called Update grammar dependencies. If this check box is ticked and you change the name of the terminal all occurrences of this terminal (e.g. in production rules) will also be changed to the new name.

Besides name and definition you must also set the type of the terminal. The follwoing table lists and describes all available types.

Terminal types
Type Icon Description
Macro Gray diamond A macro assigns a name to a regular expression in order to facilitate reusing this regular expression in other terminal definitions. This makes terminal definitions easier to read.
Separator A single red leaf node from a tree graph underlined by a white space symbol

Separators separate different pieces of information.

Terminals of type separator are only relevant during the lexical analysis (scanning), they are not evaluated during parsing (column creation) because they are meta information.

Evaluate A single red leaf node from a tree graph The information that is represented by this terminal is evaluated during parsing and will be displayed in a column.
Skip A single white leaf node from a tree graph

The information that is represented by this terminal is skipped and thus will not be displayed in a column. You should only use this for special cases like the Start of File (sof) terminal.

The begin of the log is represented by the terminal sof. This terminal should be skipped if no production rule should depend on this terminal. Otherwise it must be considered in a production rule in order to create a useful grammar.

Skipped terminals will be ignored during parsing.

The figure Notations used by the Grammar Definition dialog shows the usage of macros, terminal types and nonterminal types in the Grammar Definition dialog.

Notations used by the Grammar Definition dialog
Notations used by the Grammar Definition dialog

In order to use a macro in a terminal definition you must encompass the macro with angle brackets (see dateTime terminal in the figure below). Moreover, when a macro should be used in a terminal definition you must tick the check box Resolve Macros in the Layout Definition Terminal dialog, i.e. in the grammar definition of figure Notations used by the Grammar Definition dialog you have to do this for the dateTime terminal symbol. Otherwise the angle brackets and the macro name are considered as “normal” characters. The definition of the dateTime terminal symbol mixes a macro and regular expressions in order to illustrate the usage of macros. It certainly makes sense to replace all other regular expressions [0-9] with the macro.

The colon in figure Notations used by the Grammar Definition dialog in the HEADER nonterminal symbol before the nonterminal TID is the terminal “:” from the Name column of the Terminals list. The colon in the dateTime terminal's definition does not have anything to do with the terminal “:”. Terminals of type Separator or Evaluate cannot be used in the Terminals list. If you tick the check box Update Grammar Dependencies in the Layout Definition Terminal dialog of the terminal “:” and you change the name “:” to “colon” than in the HEADER nonterminal symbol the “:” will also change to “colon” (the notation is then analogous to “space”).