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