6. Statement tokens
The syntax for introducing a statement token is simply:
#pragma token STATEMENT init_globs# int g(int); int f(int x) { init_globs return g(x); }
Internal statement token identifiers reside in the macro name space. The optional name space, TAG
, should not appear in statement token introductions.
The use of statement tokens is analogous to the use of expression tokens (see §5). A new symbol, stat-token-name, has been introduced into the syntax analysis at phase 7 of translation as defined in the ISO C standard. This token is passed through to the syntax analyser whenever the preprocessor encounters an identifier referring to a statement token. A stat-token-name
can only occur as part of the statement syntax (ISO C standard, section 6.6).
As with expression tokens, statement tokens are defined using #define
statements. An example of this is shown below:
#pragma token STATEMENT i_globs# #define i_globs { int i = x; x = 3; }
The constraints on the definition of statement tokens are:
-
the use of labels is forbidden unless the definition of the statement token occurs at the outer level (i.e outside of any compound statement forming a function definition);
-
the use of return within the defining statement is not allowed.
The semantics of the defining statement are precisely the same as the semantics of a compound statement forming the definition of a function with no parameters and void result. The definition of statement tokens carries the same implications for phases of translation as the definition of expression tokens (see F.5 Expression tokens).