| 1 |
Here is an overview of special syntactic constructions that may be used |
| 2 |
inside action blocks: |
| 3 |
itemization( |
| 4 |
itt($$) and tt($i) notations represent semantic values of the nonterminal |
| 5 |
defined by production rules and semantic values of components of production |
| 6 |
rules. Different `dollar-notations' are available for different types (single, |
| 7 |
union, or polymorphic) of semantic values. Refer to section ref(ACTIONS) for a |
| 8 |
complete description. |
| 9 |
|
| 10 |
itt(@@) and tt(@n): Usually these represent plain old data (a bf(C)-type |
| 11 |
structure) containing information about line numbers and column numbers that |
| 12 |
is associated with, respectively, the rule's nonterminal and the production |
| 13 |
rule's n+sups(th) component. The default structure is defined like this (see |
| 14 |
also section ref(LSPNEEDED)): |
| 15 |
verb( |
| 16 |
struct LTYPE_ |
| 17 |
{ |
| 18 |
int timestamp; |
| 19 |
int first_line; |
| 20 |
int first_column; |
| 21 |
int last_line; |
| 22 |
int last_column; |
| 23 |
char *text; |
| 24 |
}; |
| 25 |
) |
| 26 |
Thus, to get the starting line number of the third component, you would |
| 27 |
use tt(@3.first_line). |
| 28 |
|
| 29 |
In order for the members of this structure to contain valid information, |
| 30 |
you must make sure the lexical scanner supplies this information about each |
| 31 |
token. If you need only certain fields, then the lexical scanner |
| 32 |
only has to provide those fields. |
| 33 |
|
| 34 |
Be advised that using this or corresponding (custom-defined, see sections |
| 35 |
ref(LTYPE) and ref(LOCSTRUCT)) constructions may somewhat slow down the |
| 36 |
parsing process. |
| 37 |
) |