50 |
extern void perror (const char *s); |
extern void perror (const char *s); |
51 |
|
|
52 |
/* Exercise pre-prologue dependency to %union. */ |
/* Exercise pre-prologue dependency to %union. */ |
53 |
typedef int value; |
typedef int semantic_value; |
54 |
|
|
55 |
static value global_result = 0; |
static semantic_value global_result = 0; |
56 |
static int global_count = 0; |
static int global_count = 0; |
57 |
%} |
%} |
58 |
|
|
59 |
/* Exercise %union. */ |
/* Exercise %union. */ |
60 |
%union |
%union |
61 |
{ |
{ |
62 |
value ival; |
semantic_value ival; |
63 |
}; |
}; |
64 |
|
|
65 |
%{ |
%{ |
69 |
- %location & %pure & %glr |
- %location & %pure & %glr |
70 |
- %location & %pure & %yacc & %parse-param. */ |
- %location & %pure & %yacc & %parse-param. */ |
71 |
static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ]) |
static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ]) |
72 |
AT_PARAM_IF([value *result, int *count, ]) |
AT_PARAM_IF([semantic_value *result, int *count, ]) |
73 |
const char *s |
const char *s |
74 |
);])[ |
);])[ |
75 |
static int yylex (]AT_LEX_FORMALS[); |
static int yylex (]AT_LEX_FORMALS[); |
139 |
} |
} |
140 |
|
|
141 |
int |
int |
142 |
yyparse (void) |
yyparse (AT_PARAM_IF([semantic_value *result, int *count])) |
143 |
{ |
{ |
144 |
yy::Parser parser (!!YYDEBUG[]AT_LOCATION_IF([, yy::Location::Location ()])); |
yy::Parser parser (!!YYDEBUG[]AT_LOCATION_IF([, yy::Location::Location ()])AT_PARAM_IF([, result, count])); |
145 |
return parser.parse (); |
return parser.parse (); |
146 |
} |
} |
147 |
], |
], |
148 |
[static void |
[static void |
149 |
yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ]) |
yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ]) |
150 |
AT_PARAM_IF([value *result, int *count, ]) |
AT_PARAM_IF([semantic_value *result, int *count, ]) |
151 |
const char *s) |
const char *s) |
152 |
{ |
{ |
153 |
AT_PARAM_IF([(void) result; (void) count;]) |
AT_PARAM_IF([(void) result; (void) count;]) |
299 |
int |
int |
300 |
main (int argc, const char **argv) |
main (int argc, const char **argv) |
301 |
{ |
{ |
302 |
value result = 0; |
semantic_value result = 0; |
303 |
int count = 0; |
int count = 0; |
304 |
int status; |
int status; |
305 |
|
|
546 |
|
|
547 |
AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc]) |
AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc]) |
548 |
|
|
549 |
AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {value *result} %parse-param {int *count}]) |
AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) |
550 |
|
|
551 |
|
|
552 |
# ----------------------- # |
# ----------------------- # |
582 |
|
|
583 |
AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc]) |
AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc]) |
584 |
|
|
585 |
AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {value *result} %parse-param {int *count}]) |
AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) |
586 |
|
|
587 |
|
|
588 |
# ----------------------------- # |
# ----------------------------- # |
594 |
# AT_CHECK_CALC_LALR1_CC([BISON-OPTIONS]) |
# AT_CHECK_CALC_LALR1_CC([BISON-OPTIONS]) |
595 |
# --------------------------------------- |
# --------------------------------------- |
596 |
# Start a testing chunk which compiles `calc' grammar with |
# Start a testing chunk which compiles `calc' grammar with |
597 |
# BISON-OPTIONS and %glr-parser, and performs several tests over the parser. |
# the C++ skeleton, and performs several tests over the parser. |
598 |
m4_define([AT_CHECK_CALC_LALR1_CC], |
m4_define([AT_CHECK_CALC_LALR1_CC], |
599 |
[AT_CHECK_CALC([%skeleton "lalr1.cc"] $@)]) |
[AT_CHECK_CALC([%skeleton "lalr1.cc"] $@)]) |
600 |
|
|
619 |
|
|
620 |
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc]) |
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc]) |
621 |
|
|
622 |
# AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {value *result} %parse-param {int *count}]) |
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) |