]> git.saurik.com Git - bison.git/blame - tests/calc.at
* tests/cxx-type.at: Construct a tree, count the parents of shared
[bison.git] / tests / calc.at
CommitLineData
82c53be4 1# Simple calculator. -*- Autotest -*-
419ab105
PE
2
3# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software
4# Foundation, Inc.
bfb07874 5
342b8b6e
AD
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2, or (at your option)
9# any later version.
bfb07874 10
342b8b6e
AD
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
bfb07874 15
342b8b6e
AD
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
0fb669f9
PE
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19# 02110-1301, USA.
bfb07874 20
bfb07874
AD
21## ---------------------------------------------------- ##
22## Compile the grammar described in the documentation. ##
23## ---------------------------------------------------- ##
24
25
26# ------------------------- #
27# Helping Autotest macros. #
28# ------------------------- #
29
30
2a8d363a
AD
31# _AT_DATA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES])
32# -----------------------------------------------
bfb07874
AD
33# Produce `calc.y'. Don't call this macro directly, because it contains
34# some occurrences of `$1' etc. which will be interpreted by m4. So
35# you should call it with $1, $2, and $3 as arguments, which is what
36# AT_DATA_CALC_Y does.
342b8b6e
AD
37m4_define([_AT_DATA_CALC_Y],
38[m4_if([$1$2$3], $[1]$[2]$[3], [],
39 [m4_fatal([$0: Invalid arguments: $@])])dnl
9501dc6e 40AT_DATA_GRAMMAR([calc.y],
bfb07874 41[[/* Infix notation calculator--calc */
fb9712a9
AD
42]$4
43AT_LALR1_CC_IF(
44[%define "global_tokens_and_yystype"])[
bfb07874
AD
45%{
46#include <stdio.h>
2ce10144 47
6e26ca8c
PE
48#include <stdlib.h>
49#include <string.h>
82c53be4
PE
50#if HAVE_UNISTD_H
51# include <unistd.h>
52#else
53# undef alarm
54# define alarm(seconds) /* empty */
55#endif
bfb07874 56#include <ctype.h>
bfb07874 57
0dd1580a 58/* Exercise pre-prologue dependency to %union. */
caf37a36 59typedef int semantic_value;
0dd1580a 60
caf37a36 61static semantic_value global_result = 0;
4e8c79eb 62static int global_count = 0;
bfb07874
AD
63%}
64
5a08f1ce 65/* Exercise %union. */
213e640e
AD
66%union
67{
caf37a36 68 semantic_value ival;
213e640e
AD
69};
70
c19988b7 71%{
c19988b7 72static int power (int base, int exponent);
fb9712a9
AD
73]AT_LALR1_CC_IF(
74[typedef yy::location YYLTYPE;
75#define first_line begin.line
76#define first_column begin.column
77#define last_line end.line
78#define last_column end.column
79],
67a25fed 80[/* yyerror receives the location if:
2a8d363a
AD
81 - %location & %pure & %glr
82 - %location & %pure & %yacc & %parse-param. */
ebc3737e 83static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
caf37a36 84 AT_PARAM_IF([semantic_value *result, int *count, ])
93724f13 85 const char *s
d02b25f9 86 );])[
7548fed2 87static int yylex (]AT_LEX_FORMALS[);
a9739e7c
PE
88static int get_char (]AT_LEX_FORMALS[);
89static void unget_char (]AT_LEX_PRE_FORMALS[ int c);
c19988b7
AD
90%}
91
6b7e85b9 92/* Bison Declarations */
c19988b7 93%token CALC_EOF 0 "end of input"
213e640e
AD
94%token <ival> NUM "number"
95%type <ival> exp
bfb07874
AD
96
97%nonassoc '=' /* comparison */
98%left '-' '+'
99%left '*' '/'
100%left NEG /* negation--unary minus */
101%right '^' /* exponentiation */
102
103/* Grammar follows */
104%%
105input:
b7c49edf 106 line
2a8d363a 107| input line { ]AT_PARAM_IF([++*count; ++global_count;])[ }
bfb07874
AD
108;
109
110line:
c19988b7 111 '\n'
2a8d363a 112| exp '\n' { ]AT_PARAM_IF([*result = global_result = $1;])[ }
bfb07874
AD
113;
114
115exp:
116 NUM { $$ = $1; }
117| exp '=' exp
118 {
2a8d363a
AD
119 if ($1 != $3)
120 fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
121 $$ = $1;
bfb07874
AD
122 }
123| exp '+' exp { $$ = $1 + $3; }
124| exp '-' exp { $$ = $1 - $3; }
125| exp '*' exp { $$ = $1 * $3; }
126| exp '/' exp { $$ = $1 / $3; }
127| '-' exp %prec NEG { $$ = -$2; }
128| exp '^' exp { $$ = power ($1, $3); }
129| '(' exp ')' { $$ = $2; }
0b86fc41
AD
130| '(' error ')' { $$ = 1111; }
131| '!' { YYERROR; }
82c53be4 132| '-' error { YYERROR; }
bfb07874
AD
133;
134%%
135/* The input. */
a9739e7c 136static FILE *input;
bfb07874 137
7548fed2 138]AT_LALR1_CC_IF(
68e11668 139[/* A C++ error reporting function. */
7548fed2 140void
99880de5 141yy::parser::error (const location& l, const std::string& m)
7548fed2 142{
efeed023
AD
143 (void) l;
144 std::cerr << AT_LOCATION_IF([l << ": " << ])m << std::endl;
7548fed2
AD
145}
146
147int
caf37a36 148yyparse (AT_PARAM_IF([semantic_value *result, int *count]))
7548fed2 149{
99880de5 150 yy::parser parser[]AT_PARAM_IF([ (result, count)]);
a3cb6248 151 parser.set_debug_level (!!YYDEBUG);
7548fed2
AD
152 return parser.parse ();
153}
154],
155[static void
ebc3737e 156yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
caf37a36 157 AT_PARAM_IF([semantic_value *result, int *count, ])
7548fed2
AD
158 const char *s)
159{
160AT_PARAM_IF([(void) result; (void) count;])
161AT_YYERROR_SEES_LOC_IF([
162 fprintf (stderr, "%d.%d",
163 AT_LOC.first_line, AT_LOC.first_column);
164 if (AT_LOC.first_line != AT_LOC.last_line)
165 fprintf (stderr, "-%d.%d",
166 AT_LOC.last_line, AT_LOC.last_column - 1);
167 else if (AT_LOC.first_column != AT_LOC.last_column - 1)
168 fprintf (stderr, "-%d",
169 AT_LOC.last_column - 1);
170 fprintf (stderr, ": ");])
171 fprintf (stderr, "%s\n", s);
172}])[
173
b7c49edf 174
2a8d363a 175]AT_LOCATION_IF([
b7c49edf 176static YYLTYPE last_yylloc;
2a8d363a 177])[
bfb07874 178static int
a9739e7c 179get_char (]AT_LEX_FORMALS[)
bfb07874 180{
a9739e7c 181 int res = getc (input);
7548fed2 182 ]AT_USE_LEX_ARGS[;
2a8d363a 183]AT_LOCATION_IF([
7548fed2 184 last_yylloc = AT_LOC;
bfb07874
AD
185 if (res == '\n')
186 {
fb9712a9
AD
187 AT_LOC.last_line++;
188 AT_LOC.last_column = 0;
bfb07874
AD
189 }
190 else
fb9712a9 191 AT_LOC.last_column++;
2a8d363a 192])[
bfb07874
AD
193 return res;
194}
195
196
197static void
a9739e7c 198unget_char (]AT_LEX_PRE_FORMALS[ int c)
bfb07874 199{
7548fed2 200 ]AT_USE_LEX_ARGS[;
2a8d363a 201]AT_LOCATION_IF([
bfb07874 202 /* Wrong when C == `\n'. */
7548fed2 203 AT_LOC = last_yylloc;
2a8d363a 204])[
a9739e7c 205 ungetc (c, input);
bfb07874
AD
206}
207
208static int
7548fed2 209read_signed_integer (]AT_LEX_FORMALS[)
bfb07874 210{
a9739e7c 211 int c = get_char (]AT_LEX_ARGS[);
bfb07874
AD
212 int sign = 1;
213 int n = 0;
214
7548fed2 215 ]AT_USE_LEX_ARGS[;
bfb07874
AD
216 if (c == '-')
217 {
a9739e7c 218 c = get_char (]AT_LEX_ARGS[);
bfb07874
AD
219 sign = -1;
220 }
221
222 while (isdigit (c))
223 {
224 n = 10 * n + (c - '0');
a9739e7c 225 c = get_char (]AT_LEX_ARGS[);
bfb07874
AD
226 }
227
a9739e7c 228 unget_char (]AT_LEX_PRE_ARGS[ c);
bfb07874
AD
229
230 return sign * n;
231}
232
233
234
235/*---------------------------------------------------------------.
236| Lexical analyzer returns an integer on the stack and the token |
237| NUM, or the ASCII character read if not a number. Skips all |
238| blanks and tabs, returns 0 for EOF. |
239`---------------------------------------------------------------*/
240
241static int
7548fed2 242yylex (]AT_LEX_FORMALS[)
bfb07874 243{
c19988b7 244 static int init = 1;
bfb07874
AD
245 int c;
246
c19988b7
AD
247 if (init)
248 {
249 init = 0;
fb9712a9 250]AT_LOCATION_IF([
7548fed2
AD
251 AT_LOC.last_column = 0;
252 AT_LOC.last_line = 1;
fb9712a9 253])[
c19988b7
AD
254 }
255
fb9712a9
AD
256]AT_LOCATION_IF([
257 AT_LOC.first_column = AT_LOC.last_column;
7548fed2 258 AT_LOC.first_line = AT_LOC.last_line;
fb9712a9 259])[
bfb07874
AD
260
261 /* Skip white space. */
a9739e7c 262 while ((c = get_char (]AT_LEX_ARGS[)) == ' ' || c == '\t')
bfb07874 263 {
fb9712a9 264]AT_LOCATION_IF(
d02b25f9 265[ AT_LOC.first_column = AT_LOC.last_column;
7548fed2 266 AT_LOC.first_line = AT_LOC.last_line;
fb9712a9 267])[
bfb07874
AD
268 }
269
270 /* process numbers */
271 if (c == '.' || isdigit (c))
272 {
a9739e7c 273 unget_char (]AT_LEX_PRE_ARGS[ c);
7548fed2 274 ]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
bfb07874
AD
275 return NUM;
276 }
277
278 /* Return end-of-file. */
279 if (c == EOF)
6b7e85b9 280 return CALC_EOF;
bfb07874
AD
281
282 /* Return single chars. */
283 return c;
284}
285
286static int
287power (int base, int exponent)
288{
289 int res = 1;
290 if (exponent < 0)
6100a9aa 291 exit (3);
bfb07874
AD
292 for (/* Niente */; exponent; --exponent)
293 res *= base;
294 return res;
295}
296
7548fed2 297
bfb07874 298int
342b8b6e 299main (int argc, const char **argv)
bfb07874 300{
caf37a36 301 semantic_value result = 0;
e7cb57c0 302 int count = 0;
4e8c79eb 303 int status;
342b8b6e 304
419ab105
PE
305 /* This used to be alarm (10), but that isn't enough time for
306 a July 1995 vintage DEC Alphastation 200 4/100 system,
307 according to Nelson H. F. Beebe. 100 seconds is enough. */
308 alarm (100);
309
342b8b6e 310 if (argc == 2)
a9739e7c 311 input = fopen (argv[1], "r");
bfb07874 312 else
a9739e7c 313 input = stdin;
bfb07874 314
a9739e7c 315 if (!input)
bfb07874
AD
316 {
317 perror (argv[1]);
6100a9aa 318 return 3;
bfb07874
AD
319 }
320
d02b25f9
AD
321]AT_LALR1_CC_IF([], [m4_bmatch([$4], [%debug],
322[ yydebug = 1;])])[
b0f98b10 323 status = yyparse (]AT_PARAM_IF([&result, &count])[);
63d0fb9c
PE
324 if (global_result != result)
325 abort ();
326 if (global_count != count)
327 abort ();
b0f98b10 328 return status;
bfb07874
AD
329}
330]])
331])# _AT_DATA_CALC_Y
332
333
334# AT_DATA_CALC_Y([BISON-OPTIONS])
335# -------------------------------
336# Produce `calc.y'.
342b8b6e 337m4_define([AT_DATA_CALC_Y],
9e32add8 338[_AT_DATA_CALC_Y($[1], $[2], $[3], [$1])
f50adbbd 339])
bfb07874
AD
340
341
342
d9963c85
PE
343# _AT_CHECK_CALC(BISON-OPTIONS, INPUT, [NUM-STDERR-LINES])
344# --------------------------------------------------------
bfb07874 345# Run `calc' on INPUT and expect no STDOUT nor STDERR.
342b8b6e 346#
f50adbbd 347# If BISON-OPTIONS contains `%debug' but not `%glr-parser', then
d9963c85 348#
f50adbbd 349# NUM-STDERR-LINES is the number of expected lines on stderr.
d9963c85 350# Currently this is ignored, though, since the output format is fluctuating.
f50adbbd
AD
351#
352# We don't count GLR's traces yet, since its traces are somewhat
353# different from LALR's.
342b8b6e
AD
354m4_define([_AT_CHECK_CALC],
355[AT_DATA([[input]],
356[[$2
357]])
f50adbbd 358AT_PARSER_CHECK([./calc input], 0, [], [stderr])
342b8b6e
AD
359])
360
361
b0f98b10 362# _AT_CHECK_CALC_ERROR(BISON-OPTIONS, EXIT-STATUS, INPUT,
d9963c85 363# [NUM-STDERR-LINES],
2a8d363a 364# [VERBOSE-AND-LOCATED-ERROR-MESSAGE])
b0f98b10 365# ---------------------------------------------------------
6e649e65 366# Run `calc' on INPUT, and expect a `syntax error' message.
342b8b6e 367#
b7c49edf
AD
368# If INPUT starts with a slash, it is used as absolute input file name,
369# otherwise as contents.
370#
d9963c85
PE
371# NUM-STDERR-LINES is the number of expected lines on stderr.
372# Currently this is ignored, though, since the output format is fluctuating.
373#
9e32add8 374# If BISON-OPTIONS contains `%location', then make sure the ERROR-LOCATION
342b8b6e
AD
375# is correctly output on stderr.
376#
f50adbbd 377# If BISON-OPTIONS contains `%error-verbose', then make sure the
6e649e65 378# IF-YYERROR-VERBOSE message is properly output after `syntax error, '
342b8b6e
AD
379# on STDERR.
380#
f50adbbd
AD
381# If BISON-OPTIONS contains `%debug' but not `%glr', then NUM-STDERR-LINES
382# is the number of expected lines on stderr.
342b8b6e 383m4_define([_AT_CHECK_CALC_ERROR],
b0f98b10
AD
384[m4_bmatch([$3], [^/],
385 [AT_PARSER_CHECK([./calc $3], $2, [], [stderr])],
b7c49edf 386 [AT_DATA([[input]],
b0f98b10 387[[$3
342b8b6e 388]])
b0f98b10 389AT_PARSER_CHECK([./calc input], $2, [], [stderr])])
342b8b6e 390
51dec47b
AD
391# Normalize the observed and expected error messages, depending upon the
392# options.
393# 1. Remove the traces from observed.
9280d3ef
AD
394sed '/^Starting/d
395/^Entering/d
f50adbbd 396/^Stack/d
9280d3ef
AD
397/^Reading/d
398/^Reducing/d
399/^Shifting/d
400/^state/d
dd5f2af2 401/^Cleanup:/d
9280d3ef
AD
402/^Error:/d
403/^Next/d
404/^Discarding/d
62b08cfc 405/ \$[[0-9$]]* = /d
9280d3ef 406/^yydestructor:/d' stderr >at-stderr
342b8b6e 407mv at-stderr stderr
51dec47b
AD
408# 2. Create the reference error message.
409AT_DATA([[expout]],
b0f98b10 410[$5
342b8b6e 411])
51dec47b 412# 3. If locations are not used, remove them.
2a8d363a 413AT_YYERROR_SEES_LOC_IF([],
51dec47b
AD
414[[sed 's/^[-0-9.]*: //' expout >at-expout
415mv at-expout expout]])
416# 4. If error-verbose is not used, strip the`, unexpected....' part.
f50adbbd 417m4_bmatch([$1], [%error-verbose], [],
6e649e65 418[[sed 's/syntax error, .*$/syntax error/' expout >at-expout
51dec47b
AD
419mv at-expout expout]])
420# 5. Check
421AT_CHECK([cat stderr], 0, [expout])
342b8b6e 422])
bfb07874
AD
423
424
fb9712a9
AD
425# AT_CHECK_CALC([BISON-OPTIONS, [EXPECTED-TO-FAIL]])
426# --------------------------------------------------
bfb07874
AD
427# Start a testing chunk which compiles `calc' grammar with
428# BISON-OPTIONS, and performs several tests over the parser.
907e3bc8 429# However, if EXPECTED-TO-FAIL is nonempty, this test is expected to fail.
342b8b6e 430m4_define([AT_CHECK_CALC],
bfb07874
AD
431[# We use integers to avoid dependencies upon the precision of doubles.
432AT_SETUP([Calculator $1])
433
907e3bc8
PE
434m4_ifval([$2], [AT_CHECK([exit 77])])
435
67a25fed 436AT_BISON_OPTION_PUSHDEFS([$1])
2a8d363a 437
bfb07874
AD
438AT_DATA_CALC_Y([$1])
439
07971983
PE
440AT_LALR1_CC_IF(
441 [AT_CHECK([bison -o calc.cc calc.y])
442 AT_COMPILE_CXX([calc])],
443 [AT_CHECK([bison -o calc.c calc.y])
444 AT_COMPILE([calc])])
bfb07874
AD
445
446# Test the priorities.
447_AT_CHECK_CALC([$1],
448[1 + 2 * 3 = 7
4491 + 2 * -3 = -5
450
451-1^2 = -1
452(-1)^2 = 1
453
454---1 = -1
455
4561 - 2 - 3 = -4
4571 - (2 - 3) = 2
458
4592^2^3 = 256
e7cb57c0 460(2^2)^3 = 64],
d1ff7a7c 461 [842])
bfb07874 462
6e649e65 463# Some syntax errors.
d1ff7a7c 464_AT_CHECK_CALC_ERROR([$1], [1], [0 0], [15],
72f000b0 465 [1.2: syntax error, unexpected number])
d1ff7a7c 466_AT_CHECK_CALC_ERROR([$1], [1], [1//2], [20],
72f000b0 467 [1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'])
e757bb10 468_AT_CHECK_CALC_ERROR([$1], [1], [error], [5],
0b86fc41 469 [1.0: syntax error, unexpected $undefined])
d1ff7a7c 470_AT_CHECK_CALC_ERROR([$1], [1], [1 = 2 = 3], [30],
7548fed2 471 [1.6: syntax error, unexpected '='])
b0f98b10 472_AT_CHECK_CALC_ERROR([$1], [1],
bfb07874
AD
473 [
474+1],
d1ff7a7c 475 [20],
7548fed2 476 [2.0: syntax error, unexpected '+'])
b7c49edf 477# Exercise error messages with EOF: work on an empty file.
cea1469d 478_AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4],
72f000b0 479 [1.0: syntax error, unexpected end of input])
51dec47b
AD
480
481# Exercise the error token: without it, we die at the first error,
0b86fc41
AD
482# hence be sure to
483#
484# - have several errors which exercise different shift/discardings
485# - (): nothing to pop, nothing to discard
486# - (1 + 1 + 1 +): a lot to pop, nothing to discard
487# - (* * *): nothing to pop, a lot to discard
488# - (1 + 2 * *): some to pop and discard
489#
490# - test the action associated to `error'
491#
8dd162d3
PE
492# - check the look-ahead that triggers an error is not discarded
493# when we enter error recovery. Below, the look-ahead causing the
0b86fc41
AD
494# first error is ")", which is needed to recover from the error and
495# produce the "0" that triggers the "0 != 1" error.
496#
497_AT_CHECK_CALC_ERROR([$1], [0],
498 [() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1],
d1ff7a7c 499 [250],
72f000b0
PE
500[1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
5011.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
5021.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
5031.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
0b86fc41
AD
504calc: error: 4444 != 1])
505
506# The same, but this time exercising explicitly triggered syntax errors.
8dd162d3 507# POSIX says the look-ahead causing the error should not be discarded.
d1ff7a7c 508_AT_CHECK_CALC_ERROR([$1], [0], [(!) + (0 0) = 1], [102],
72f000b0 509[1.9: syntax error, unexpected number
0b86fc41 510calc: error: 2222 != 1])
d1ff7a7c 511_AT_CHECK_CALC_ERROR([$1], [0], [(- *) + (0 0) = 1], [113],
72f000b0
PE
512[1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
5131.11: syntax error, unexpected number
82c53be4 514calc: error: 2222 != 1])
67a25fed 515AT_BISON_OPTION_POPDEFS
2a8d363a 516
d803322e 517AT_CLEANUP
bfb07874
AD
518])# AT_CHECK_CALC
519
520
521
522
f50adbbd
AD
523# ------------------------ #
524# Simple LALR Calculator. #
525# ------------------------ #
526
527AT_BANNER([[Simple LALR Calculator.]])
528
529# AT_CHECK_CALC_LALR([BISON-OPTIONS])
530# -----------------------------------
531# Start a testing chunk which compiles `calc' grammar with
532# BISON-OPTIONS, and performs several tests over the parser.
533m4_define([AT_CHECK_CALC_LALR],
534[AT_CHECK_CALC($@)])
535
536AT_CHECK_CALC_LALR()
537
9e32add8 538AT_CHECK_CALC_LALR([%defines])
ae7453f2 539AT_CHECK_CALC_LALR([%locations])
9e32add8
AD
540AT_CHECK_CALC_LALR([%name-prefix="calc"])
541AT_CHECK_CALC_LALR([%verbose])
542AT_CHECK_CALC_LALR([%yacc])
f50adbbd
AD
543AT_CHECK_CALC_LALR([%error-verbose])
544
211074ca 545AT_CHECK_CALC_LALR([%pure-parser %locations])
ae7453f2 546AT_CHECK_CALC_LALR([%error-verbose %locations])
f50adbbd 547
9e32add8 548AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc])
f50adbbd
AD
549
550AT_CHECK_CALC_LALR([%debug])
9e32add8 551AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
c19988b7 552
2a8d363a
AD
553AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
554
caf37a36 555AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
f50adbbd
AD
556
557
558# ----------------------- #
559# Simple GLR Calculator. #
560# ----------------------- #
561
562AT_BANNER([[Simple GLR Calculator.]])
563
564# AT_CHECK_CALC_GLR([BISON-OPTIONS])
565# ----------------------------------
566# Start a testing chunk which compiles `calc' grammar with
567# BISON-OPTIONS and %glr-parser, and performs several tests over the parser.
568m4_define([AT_CHECK_CALC_GLR],
ae7453f2 569[AT_CHECK_CALC([%glr-parser] $@)])
f50adbbd 570
bfb07874 571
f50adbbd 572AT_CHECK_CALC_GLR()
bfb07874 573
9e32add8 574AT_CHECK_CALC_GLR([%defines])
ae7453f2 575AT_CHECK_CALC_GLR([%locations])
9e32add8
AD
576AT_CHECK_CALC_GLR([%name-prefix="calc"])
577AT_CHECK_CALC_GLR([%verbose])
578AT_CHECK_CALC_GLR([%yacc])
f50adbbd 579AT_CHECK_CALC_GLR([%error-verbose])
bfb07874 580
211074ca 581AT_CHECK_CALC_GLR([%pure-parser %locations])
ae7453f2 582AT_CHECK_CALC_GLR([%error-verbose %locations])
bfb07874 583
9e32add8 584AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc])
bfb07874 585
f50adbbd 586AT_CHECK_CALC_GLR([%debug])
9e32add8 587AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
21964f43 588
2a8d363a
AD
589AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
590
caf37a36 591AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
7548fed2
AD
592
593
594# ----------------------------- #
595# Simple LALR1 C++ Calculator. #
596# ----------------------------- #
597
598AT_BANNER([[Simple LALR1 C++ Calculator.]])
599
600# AT_CHECK_CALC_LALR1_CC([BISON-OPTIONS])
601# ---------------------------------------
602# Start a testing chunk which compiles `calc' grammar with
caf37a36 603# the C++ skeleton, and performs several tests over the parser.
7548fed2 604m4_define([AT_CHECK_CALC_LALR1_CC],
47301314 605[AT_CHECK_CALC([%skeleton "lalr1.cc"] $@)])
7548fed2
AD
606
607# AT_CHECK_CALC_LALR1_CC()
608
d02b25f9 609AT_CHECK_CALC_LALR1_CC([%defines %locations])
0b86fc41 610
d02b25f9 611AT_CHECK_CALC_LALR1_CC([%defines])
7548fed2
AD
612# AT_CHECK_CALC_LALR1_CC([%locations])
613# AT_CHECK_CALC_LALR1_CC([%name-prefix="calc"])
614# AT_CHECK_CALC_LALR1_CC([%verbose])
615# AT_CHECK_CALC_LALR1_CC([%yacc])
616# AT_CHECK_CALC_LALR1_CC([%error-verbose])
617
211074ca 618# AT_CHECK_CALC_LALR1_CC([%pure-parser %locations])
7548fed2
AD
619# AT_CHECK_CALC_LALR1_CC([%error-verbose %locations])
620
d02b25f9 621AT_CHECK_CALC_LALR1_CC([%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc])
7548fed2
AD
622
623# AT_CHECK_CALC_LALR1_CC([%debug])
d02b25f9 624AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
7548fed2 625
d02b25f9 626AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
7548fed2 627
caf37a36 628AT_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}])