]> git.saurik.com Git - bison.git/blob - tests/calc.at
a5e64efe8358049b8097f1d04a2c962894b32b68
[bison.git] / tests / calc.at
1 # Checking the output filenames. -*- Autotest -*-
2 # Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
3
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.
8
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.
13
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.
18
19 ## ---------------------------------------------------- ##
20 ## Compile the grammar described in the documentation. ##
21 ## ---------------------------------------------------- ##
22
23
24 # ------------------------- #
25 # Helping Autotest macros. #
26 # ------------------------- #
27
28
29 # _AT_DATA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES])
30 # -----------------------------------------------
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.
35 m4_define([_AT_DATA_CALC_Y],
36 [m4_if([$1$2$3], $[1]$[2]$[3], [],
37 [m4_fatal([$0: Invalid arguments: $@])])dnl
38 AT_DATA_GRAMMAR([calc.y],
39 [[/* Infix notation calculator--calc */
40 ]$4[
41 %{
42 #include <stdio.h>
43
44 #if STDC_HEADERS
45 # include <stdlib.h>
46 # include <string.h>
47 #endif
48 #include <ctype.h>
49
50 extern void perror (const char *s);
51
52 /* Exercise pre-prologue dependency to %union. */
53 typedef int value;
54
55 static value global_result = 0;
56 static int global_count = 0;
57
58 ]AT_LALR1_CC_IF([typedef yy::Location YYLTYPE;])[
59 %}
60
61 /* Exercise %union. */
62 %union
63 {
64 value ival;
65 };
66
67 %{
68 static int power (int base, int exponent);
69 /* yyerror receives the location if:
70 - %location & %pure & %glr
71 - %location & %pure & %yacc & %parse-param. */
72 static void yyerror (]AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])[
73 ]AT_PARAM_IF([value *result, int *count, ])[
74 const char *s
75 );
76 static int yylex (]AT_LEX_FORMALS[);
77 static int yygetc (]AT_LEX_FORMALS[);
78 static void yyungetc (]AT_LEX_PRE_FORMALS[ int c);
79 %}
80
81 /* Bison Declarations */
82 %token CALC_EOF 0 "end of input"
83 %token <ival> NUM "number"
84 %type <ival> exp
85
86 %nonassoc '=' /* comparison */
87 %left '-' '+'
88 %left '*' '/'
89 %left NEG /* negation--unary minus */
90 %right '^' /* exponentiation */
91
92 /* Grammar follows */
93 %%
94 input:
95 line
96 | input line { ]AT_PARAM_IF([++*count; ++global_count;])[ }
97 ;
98
99 line:
100 '\n'
101 | exp '\n' { ]AT_PARAM_IF([*result = global_result = $1;])[ }
102 ;
103
104 exp:
105 NUM { $$ = $1; }
106 | exp '=' exp
107 {
108 if ($1 != $3)
109 fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
110 $$ = $1;
111 }
112 | exp '+' exp { $$ = $1 + $3; }
113 | exp '-' exp { $$ = $1 - $3; }
114 | exp '*' exp { $$ = $1 * $3; }
115 | exp '/' exp { $$ = $1 / $3; }
116 | '-' exp %prec NEG { $$ = -$2; }
117 | exp '^' exp { $$ = power ($1, $3); }
118 | '(' exp ')' { $$ = $2; }
119 | '(' error ')' { $$ = 0; }
120 ;
121 %%
122 /* The input. */
123 static FILE *yyin;
124
125 ]AT_LALR1_CC_IF(
126 [/* Currently, print_ is required in C++. */
127 void
128 yy::Parser::print_ ()
129 {
130 std::cerr << location;
131 }
132
133 /* A C++ error reporting function. */
134 void
135 yy::Parser::error_ ()
136 {
137 std::cerr << location << ": " << message << std::endl;
138 }
139
140 int
141 yyparse (void)
142 {
143 yy::Parser parser = yy::Parser (!!YYDEBUG[]AT_LOCATION_IF([,
144 yy::Location::Location ()]));
145 return parser.parse ();
146 }
147 ],
148 [static void
149 yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])
150 AT_PARAM_IF([value *result, int *count, ])
151 const char *s)
152 {
153 AT_PARAM_IF([(void) result; (void) count;])
154 AT_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
167
168 ]AT_LOCATION_IF([
169 static YYLTYPE last_yylloc;
170 ])[
171 static int
172 yygetc (]AT_LEX_FORMALS[)
173 {
174 int res = getc (yyin);
175 ]AT_USE_LEX_ARGS[;
176 ]AT_LOCATION_IF([
177 last_yylloc = AT_LOC;
178 if (res == '\n')
179 {
180 AT_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;])
185 }
186 else
187 AT_LALR1_CC_IF(
188 [ AT_LOC.end.column++;],
189 [ AT_LOC.last_column++;])
190 ])[
191 return res;
192 }
193
194
195 static void
196 yyungetc (]AT_LEX_PRE_FORMALS[ int c)
197 {
198 ]AT_USE_LEX_ARGS[;
199 ]AT_LOCATION_IF([
200 /* Wrong when C == `\n'. */
201 AT_LOC = last_yylloc;
202 ])[
203 ungetc (c, yyin);
204 }
205
206 static int
207 read_signed_integer (]AT_LEX_FORMALS[)
208 {
209 int c = yygetc (]AT_LEX_ARGS[);
210 int sign = 1;
211 int n = 0;
212
213 ]AT_USE_LEX_ARGS[;
214 if (c == '-')
215 {
216 c = yygetc (]AT_LEX_ARGS[);
217 sign = -1;
218 }
219
220 while (isdigit (c))
221 {
222 n = 10 * n + (c - '0');
223 c = yygetc (]AT_LEX_ARGS[);
224 }
225
226 yyungetc (]AT_LEX_PRE_ARGS[ c);
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
239 static int
240 yylex (]AT_LEX_FORMALS[)
241 {
242 static int init = 1;
243 int c;
244
245 if (init)
246 {
247 init = 0;
248 ]AT_LALR1_CC_IF([],
249 [AT_LOCATION_IF([
250 AT_LOC.last_column = 0;
251 AT_LOC.last_line = 1;
252 ])])[
253 }
254
255 ]AT_LALR1_CC_IF(
256 [ AT_LOC.begin = AT_LOC.end;],
257 [AT_LOCATION_IF([
258 AT_LOC.first_column = AT_LOC.last_column;
259 AT_LOC.first_line = AT_LOC.last_line;
260 ])])[
261
262 /* Skip white space. */
263 while ((c = yygetc (]AT_LEX_ARGS[)) == ' ' || c == '\t')
264 {
265 ]AT_LALR1_CC_IF(
266 [ AT_LOC.begin = AT_LOC.end;],
267 [AT_LOCATION_IF([
268 AT_LOC.first_column = AT_LOC.last_column;
269 AT_LOC.first_line = AT_LOC.last_line;
270 ])])[
271 }
272
273 /* process numbers */
274 if (c == '.' || isdigit (c))
275 {
276 yyungetc (]AT_LEX_PRE_ARGS[ c);
277 ]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
278 return NUM;
279 }
280
281 /* Return end-of-file. */
282 if (c == EOF)
283 return CALC_EOF;
284
285 /* Return single chars. */
286 return c;
287 }
288
289 static int
290 power (int base, int exponent)
291 {
292 int res = 1;
293 if (exponent < 0)
294 exit (1);
295 for (/* Niente */; exponent; --exponent)
296 res *= base;
297 return res;
298 }
299
300
301 int
302 main (int argc, const char **argv)
303 {
304 value result = 0;
305 int count = 0;
306 int status;
307
308 if (argc == 2)
309 yyin = fopen (argv[1], "r");
310 else
311 yyin = stdin;
312
313 if (!yyin)
314 {
315 perror (argv[1]);
316 exit (1);
317 }
318
319 #if YYDEBUG
320 yydebug = 1;
321 #endif
322 status = yyparse (]AT_PARAM_IF([&result, &count])[);
323 if (global_result != result)
324 abort ();
325 if (global_count != count)
326 abort ();
327 return status;
328 }
329 ]])
330 ])# _AT_DATA_CALC_Y
331
332
333 # AT_DATA_CALC_Y([BISON-OPTIONS])
334 # -------------------------------
335 # Produce `calc.y'.
336 m4_define([AT_DATA_CALC_Y],
337 [_AT_DATA_CALC_Y($[1], $[2], $[3], [$1])
338 ])
339
340
341
342 # _AT_CHECK_CALC(BISON-OPTIONS, INPUT, [NUM-STDERR-LINES = 0])
343 # ------------------------------------------------------------
344 # Run `calc' on INPUT and expect no STDOUT nor STDERR.
345 #
346 # If BISON-OPTIONS contains `%debug' but not `%glr-parser', then
347 # NUM-STDERR-LINES is the number of expected lines on stderr.
348 #
349 # We don't count GLR's traces yet, since its traces are somewhat
350 # different from LALR's.
351 m4_define([_AT_CHECK_CALC],
352 [AT_DATA([[input]],
353 [[$2
354 ]])
355 AT_PARSER_CHECK([./calc input], 0, [], [stderr])
356 m4_bmatch([$1],
357 [%debug.*%glr\|%glr.*%debug],
358 [],
359 [%debug],
360 [AT_CHECK([wc -l <stderr | sed 's/[[^0-9]]//g'], 0, [$3
361 ])])
362 ])
363
364
365 # _AT_CHECK_CALC_ERROR(BISON-OPTIONS, EXIT-STATUS, INPUT,
366 # [NUM-DEBUG-LINES],
367 # [VERBOSE-AND-LOCATED-ERROR-MESSAGE])
368 # ---------------------------------------------------------
369 # Run `calc' on INPUT, and expect a `syntax error' message.
370 #
371 # If INPUT starts with a slash, it is used as absolute input file name,
372 # otherwise as contents.
373 #
374 # If BISON-OPTIONS contains `%location', then make sure the ERROR-LOCATION
375 # is correctly output on stderr.
376 #
377 # If BISON-OPTIONS contains `%error-verbose', then make sure the
378 # IF-YYERROR-VERBOSE message is properly output after `syntax error, '
379 # on STDERR.
380 #
381 # If BISON-OPTIONS contains `%debug' but not `%glr', then NUM-STDERR-LINES
382 # is the number of expected lines on stderr.
383 m4_define([_AT_CHECK_CALC_ERROR],
384 [m4_bmatch([$3], [^/],
385 [AT_PARSER_CHECK([./calc $3], $2, [], [stderr])],
386 [AT_DATA([[input]],
387 [[$3
388 ]])
389 AT_PARSER_CHECK([./calc input], $2, [], [stderr])])
390 m4_bmatch([$1],
391 [%debug.*%glr\|%glr.*%debug],
392 [],
393 [%debug],
394 [AT_CHECK([wc -l <stderr | sed 's/[[^0-9]]//g'], 0, [$4
395 ])])
396
397 # Normalize the observed and expected error messages, depending upon the
398 # options.
399 # 1. Remove the traces from observed.
400 sed '/^Starting/d
401 /^Entering/d
402 /^Stack/d
403 /^Reading/d
404 /^Reducing/d
405 /^Shifting/d
406 /^state/d
407 /^Error:/d
408 /^Next/d
409 /^Discarding/d
410 /^yydestructor:/d' stderr >at-stderr
411 mv at-stderr stderr
412 # 2. Create the reference error message.
413 AT_DATA([[expout]],
414 [$5
415 ])
416 # 3. If locations are not used, remove them.
417 AT_YYERROR_SEES_LOC_IF([],
418 [[sed 's/^[-0-9.]*: //' expout >at-expout
419 mv at-expout expout]])
420 # 4. If error-verbose is not used, strip the`, unexpected....' part.
421 m4_bmatch([$1], [%error-verbose], [],
422 [[sed 's/syntax error, .*$/syntax error/' expout >at-expout
423 mv at-expout expout]])
424 # 5. Check
425 AT_CHECK([cat stderr], 0, [expout])
426 ])
427
428
429 # AT_CALC_PUSHDEFS($1, $2, [BISON-OPTIONS])
430 # -----------------------------------------
431 # This macro works around the impossibility to define macros
432 # inside macros, because issuing `[$1]' is not possible in M4 :(.
433 # This sucks hard, GNU M4 should really provide M5 like $$1.
434 m4_define([AT_CHECK_PUSHDEFS],
435 [m4_if([$1$2], $[1]$[2], [],
436 [m4_fatal([$0: Invalid arguments: $@])])dnl
437 m4_pushdef([AT_LALR1_CC_IF],
438 [m4_bmatch([$3], ["lalr1.cc"], [$1], [$2])])
439 m4_pushdef([AT_GLR_IF],
440 [m4_bmatch([$3], [%glr-parser], [$1], [$2])])
441 m4_pushdef([AT_PARAM_IF],
442 [m4_bmatch([$3], [%parse-param], [$1], [$2])])
443 m4_pushdef([AT_LOCATION_IF],
444 [m4_bmatch([$3], [%locations], [$1], [$2])])
445 m4_pushdef([AT_PURE_IF],
446 [m4_bmatch([$3], [%pure-parser], [$1], [$2])])
447 m4_pushdef([AT_PURE_AND_LOC_IF],
448 [m4_bmatch([$3], [%locations.*%pure-parser\|%pure-parser.*%locations],
449 [$1], [$2])])
450 m4_pushdef([AT_GLR_OR_PARAM_IF],
451 [m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
452
453 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
454 m4_pushdef([AT_YYERROR_ARG_LOC_IF],
455 [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
456 [$2])])
457 # yyerror cannot see the locations if !glr & pure & !param.
458 m4_pushdef([AT_YYERROR_SEES_LOC_IF],
459 [AT_LALR1_CC_IF([$1],
460 [AT_LOCATION_IF([AT_GLR_IF([$1],
461 [AT_PURE_IF([AT_PARAM_IF([$1],
462 [$2])],
463 [$1])])],
464 [$2])])])
465
466 # The interface is pure: either because %pure-parser, or because we
467 # are using the C++ parsers.
468 m4_pushdef([AT_PURE_LEX_IF],
469 [AT_PURE_IF([$1],
470 [AT_LALR1_CC_IF([$1], [$2])])])
471
472 AT_PURE_LEX_IF(
473 [m4_pushdef([AT_LOC], [(*yylloc)])
474 m4_pushdef([AT_VAL], [(*yylval)])
475 m4_pushdef([AT_LEX_FORMALS],
476 [YYSTYPE *yylval[]AT_LOCATION_IF([, YYLTYPE *yylloc])])
477 m4_pushdef([AT_LEX_ARGS],
478 [yylval[]AT_LOCATION_IF([, yylloc])])
479 m4_pushdef([AT_USE_LEX_ARGS],
480 [(void) yylval;AT_LOCATION_IF([(void) yylloc])])
481 m4_pushdef([AT_LEX_PRE_FORMALS],
482 [AT_LEX_FORMALS, ])
483 m4_pushdef([AT_LEX_PRE_ARGS],
484 [AT_LEX_ARGS, ])
485 ],
486 [m4_pushdef([AT_LOC], [(yylloc)])
487 m4_pushdef([AT_VAL], [(yylval)])
488 m4_pushdef([AT_LEX_FORMALS], [void])
489 m4_pushdef([AT_LEX_ARGS], [])
490 m4_pushdef([AT_USE_LEX_ARGS], [])
491 m4_pushdef([AT_LEX_PRE_FORMALS], [])
492 m4_pushdef([AT_LEX_PRE_ARGS], [])
493 ])
494 ])# AT_CALC_PUSHDEFS
495
496
497 # AT_CALC_POPDEFS
498 # ---------------
499 m4_define([AT_CHECK_POPDEFS],
500 [m4_popdef([AT_LEX_PRE_ARGS])
501 m4_popdef([AT_LEX_PRE_FORMALS])
502 m4_popdef([AT_USE_LEX_ARGS])
503 m4_popdef([AT_LEX_ARGS])
504 m4_popdef([AT_LEX_FORMALS])
505 m4_popdef([AT_VAL])
506 m4_popdef([AT_LOC])
507 m4_popdef([AT_PURE_LEX_IF])
508 m4_popdef([AT_YYERROR_SEES_LOC_IF])
509 m4_popdef([AT_YYERROR_ARG_LOC_IF])
510 m4_popdef([AT_GLR_OR_PARAM_IF])
511 m4_popdef([AT_PURE_AND_LOC_IF])
512 m4_popdef([AT_LOCATION_IF])
513 m4_popdef([AT_PARAM_IF])
514 m4_popdef([AT_GLR_IF])
515 m4_popdef([AT_LALR1_CC_IF])
516 ])
517
518
519
520 # AT_CHECK_CALC([BISON-OPTIONS])
521 # ------------------------------
522 # Start a testing chunk which compiles `calc' grammar with
523 # BISON-OPTIONS, and performs several tests over the parser.
524 m4_define([AT_CHECK_CALC],
525 [# We use integers to avoid dependencies upon the precision of doubles.
526 AT_SETUP([Calculator $1])
527
528 AT_CHECK_PUSHDEFS($[1], $[2], [$1])
529
530 AT_DATA_CALC_Y([$1])
531
532 # Specify the output files to avoid problems on different file systems.
533 AT_CHECK([bison -o calc.c calc.y],
534 [0], [], [])
535
536 AT_LALR1_CC_IF(
537 [AT_CHECK([$CXX --version || exit 77], 0, ignore, ignore)
538 AT_COMPILE_CXX([calc])],
539 [AT_COMPILE([calc])])
540
541 # Test the priorities.
542 _AT_CHECK_CALC([$1],
543 [1 + 2 * 3 = 7
544 1 + 2 * -3 = -5
545
546 -1^2 = -1
547 (-1)^2 = 1
548
549 ---1 = -1
550
551 1 - 2 - 3 = -4
552 1 - (2 - 3) = 2
553
554 2^2^3 = 256
555 (2^2)^3 = 64],
556 [486])
557
558 # Some syntax errors.
559 _AT_CHECK_CALC_ERROR([$1], [1], [0 0], [11],
560 [1.2: syntax error, unexpected "number"])
561 _AT_CHECK_CALC_ERROR([$1], [1], [1//2], [15],
562 [1.2: syntax error, unexpected '/', expecting "number" or '-' or '('])
563 _AT_CHECK_CALC_ERROR([$1], [1], [error], [4],
564 [1.0: syntax error, unexpected $undefined, expecting "number" or '-' or '\n' or '('])
565 _AT_CHECK_CALC_ERROR([$1], [1], [1 = 2 = 3], [22],
566 [1.6: syntax error, unexpected '='])
567 _AT_CHECK_CALC_ERROR([$1], [1],
568 [
569 +1],
570 [14],
571 [2.0: syntax error, unexpected '+'])
572 # Exercise error messages with EOF: work on an empty file.
573 _AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4],
574 [1.0: syntax error, unexpected "end of input", expecting "number" or '-' or '\n' or '('])
575
576 # Exercise the error token: without it, we die at the first error,
577 # hence be sure i. to have several errors, ii. to test the action
578 # associated to `error'.
579 _AT_CHECK_CALC_ERROR([$1], [0], [(1 ++ 2) + (0 0) = 1], [82],
580 [1.4: syntax error, unexpected '+', expecting "number" or '-' or '('
581 1.14: syntax error, unexpected "number"
582 calc: error: 0 != 1])
583
584 AT_CHECK_POPDEFS
585
586 AT_CLEANUP
587 ])# AT_CHECK_CALC
588
589
590
591
592 # ------------------------ #
593 # Simple LALR Calculator. #
594 # ------------------------ #
595
596 AT_BANNER([[Simple LALR Calculator.]])
597
598 # AT_CHECK_CALC_LALR([BISON-OPTIONS])
599 # -----------------------------------
600 # Start a testing chunk which compiles `calc' grammar with
601 # BISON-OPTIONS, and performs several tests over the parser.
602 m4_define([AT_CHECK_CALC_LALR],
603 [AT_CHECK_CALC($@)])
604
605 AT_CHECK_CALC_LALR()
606
607 AT_CHECK_CALC_LALR([%defines])
608 AT_CHECK_CALC_LALR([%locations])
609 AT_CHECK_CALC_LALR([%name-prefix="calc"])
610 AT_CHECK_CALC_LALR([%verbose])
611 AT_CHECK_CALC_LALR([%yacc])
612 AT_CHECK_CALC_LALR([%error-verbose])
613
614 AT_CHECK_CALC_LALR([%error-verbose %locations])
615
616 AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc])
617
618 AT_CHECK_CALC_LALR([%debug])
619 AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
620
621 AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
622
623 AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {value *result} %parse-param {int *count}])
624
625
626 # ----------------------- #
627 # Simple GLR Calculator. #
628 # ----------------------- #
629
630 AT_BANNER([[Simple GLR Calculator.]])
631
632 # AT_CHECK_CALC_GLR([BISON-OPTIONS])
633 # ----------------------------------
634 # Start a testing chunk which compiles `calc' grammar with
635 # BISON-OPTIONS and %glr-parser, and performs several tests over the parser.
636 m4_define([AT_CHECK_CALC_GLR],
637 [AT_CHECK_CALC([%glr-parser] $@)])
638
639
640 AT_CHECK_CALC_GLR()
641
642 AT_CHECK_CALC_GLR([%defines])
643 AT_CHECK_CALC_GLR([%locations])
644 AT_CHECK_CALC_GLR([%name-prefix="calc"])
645 AT_CHECK_CALC_GLR([%verbose])
646 AT_CHECK_CALC_GLR([%yacc])
647 AT_CHECK_CALC_GLR([%error-verbose])
648
649 AT_CHECK_CALC_GLR([%error-verbose %locations])
650
651 AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc])
652
653 AT_CHECK_CALC_GLR([%debug])
654 AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
655
656 AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
657
658 AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {value *result} %parse-param {int *count}])
659
660
661 # ----------------------------- #
662 # Simple LALR1 C++ Calculator. #
663 # ----------------------------- #
664
665 AT_BANNER([[Simple LALR1 C++ Calculator.]])
666
667 # AT_CHECK_CALC_LALR1_CC([BISON-OPTIONS])
668 # ---------------------------------------
669 # Start a testing chunk which compiles `calc' grammar with
670 # BISON-OPTIONS and %glr-parser, and performs several tests over the parser.
671 m4_define([AT_CHECK_CALC_LALR1_CC],
672 [AT_CHECK_CALC([%skeleton "lalr1.cc"] $@)])
673
674 # AT_CHECK_CALC_LALR1_CC()
675
676 AT_CHECK_CALC_LALR1_CC([%defines %pure-parser %locations])
677 # AT_CHECK_CALC_LALR1_CC([%defines])
678 # AT_CHECK_CALC_LALR1_CC([%locations])
679 # AT_CHECK_CALC_LALR1_CC([%name-prefix="calc"])
680 # AT_CHECK_CALC_LALR1_CC([%verbose])
681 # AT_CHECK_CALC_LALR1_CC([%yacc])
682 # AT_CHECK_CALC_LALR1_CC([%error-verbose])
683
684 # AT_CHECK_CALC_LALR1_CC([%error-verbose %locations])
685
686 # AT_CHECK_CALC_LALR1_CC([%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc])
687
688 # AT_CHECK_CALC_LALR1_CC([%debug])
689 # AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
690
691 # AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
692
693 # 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}])