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