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