Node:Action Features, Previous:Error Reporting, Up:Interface
Here is a table of Bison constructs, variables and macros that are useful in actions.
$$
$n
$<typealt>$
$$
but specifies alternative typealt in the union
specified by the %union
declaration. See Data Types of Values in Actions.
$<typealt>n
$n
but specifies alternative typealt in the
union specified by the %union
declaration.
See Data Types of Values in Actions.
YYABORT;
yyparse
, indicating failure.
See The Parser Function yyparse
.
YYACCEPT;
yyparse
, indicating success.
See The Parser Function yyparse
.
YYBACKUP (token, value);
If the macro is used when it is not valid, such as when there is
a look-ahead token already, then it reports a syntax error with
a message cannot back up
and performs ordinary error
recovery.
In either case, the rest of the action is not executed.
YYEMPTY
yychar
when there is no look-ahead token.
YYERROR;
yyerror
, and does not print any message. If you
want to print an error message, call yyerror
explicitly before
the YYERROR;
statement. See Error Recovery.
YYRECOVERING
yychar
yyparse
.) When there is
no look-ahead token, the value YYEMPTY
is stored in the variable.
See Look-Ahead Tokens.
yyclearin;
yyerrok;
@n
struct { int first_line, last_line; int first_column, last_column; };
Thus, to get the starting line number of the third component, use
@3.first_line
.
In order for the members of this structure to contain valid information,
you must make yylex
supply this information about each token.
If you need only certain members, then yylex
need only fill in
those members.
The use of this feature makes the parser noticeably slower.