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