]> git.saurik.com Git - bison.git/blob - tests/calc.at
4346fb09aaaed1be0a3443f2c35b42f5cd266db8
[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 ')' { $$ = 1111; }
120 | '!' { YYERROR; }
121 ;
122 %%
123 /* The input. */
124 static FILE *yyin;
125
126 ]AT_LALR1_CC_IF(
127 [/* Currently, print_ is required in C++. */
128 void
129 yy::Parser::print_ ()
130 {
131 std::cerr << location;
132 }
133
134 /* A C++ error reporting function. */
135 void
136 yy::Parser::error_ ()
137 {
138 std::cerr << location << ": " << message << std::endl;
139 }
140
141 int
142 yyparse (void)
143 {
144 yy::Parser parser = yy::Parser (!!YYDEBUG[]AT_LOCATION_IF([,
145 yy::Location::Location ()]));
146 return parser.parse ();
147 }
148 ],
149 [static void
150 yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])
151 AT_PARAM_IF([value *result, int *count, ])
152 const char *s)
153 {
154 AT_PARAM_IF([(void) result; (void) count;])
155 AT_YYERROR_SEES_LOC_IF([
156 fprintf (stderr, "%d.%d",
157 AT_LOC.first_line, AT_LOC.first_column);
158 if (AT_LOC.first_line != AT_LOC.last_line)
159 fprintf (stderr, "-%d.%d",
160 AT_LOC.last_line, AT_LOC.last_column - 1);
161 else if (AT_LOC.first_column != AT_LOC.last_column - 1)
162 fprintf (stderr, "-%d",
163 AT_LOC.last_column - 1);
164 fprintf (stderr, ": ");])
165 fprintf (stderr, "%s\n", s);
166 }])[
167
168
169 ]AT_LOCATION_IF([
170 static YYLTYPE last_yylloc;
171 ])[
172 static int
173 yygetc (]AT_LEX_FORMALS[)
174 {
175 int res = getc (yyin);
176 ]AT_USE_LEX_ARGS[;
177 ]AT_LOCATION_IF([
178 last_yylloc = AT_LOC;
179 if (res == '\n')
180 {
181 AT_LALR1_CC_IF(
182 [ AT_LOC.end.line++;
183 AT_LOC.end.column = 0;],
184 [ AT_LOC.last_line++;
185 AT_LOC.last_column = 0;])
186 }
187 else
188 AT_LALR1_CC_IF(
189 [ AT_LOC.end.column++;],
190 [ AT_LOC.last_column++;])
191 ])[
192 return res;
193 }
194
195
196 static void
197 yyungetc (]AT_LEX_PRE_FORMALS[ int c)
198 {
199 ]AT_USE_LEX_ARGS[;
200 ]AT_LOCATION_IF([
201 /* Wrong when C == `\n'. */
202 AT_LOC = last_yylloc;
203 ])[
204 ungetc (c, yyin);
205 }
206
207 static int
208 read_signed_integer (]AT_LEX_FORMALS[)
209 {
210 int c = yygetc (]AT_LEX_ARGS[);
211 int sign = 1;
212 int n = 0;
213
214 ]AT_USE_LEX_ARGS[;
215 if (c == '-')
216 {
217 c = yygetc (]AT_LEX_ARGS[);
218 sign = -1;
219 }
220
221 while (isdigit (c))
222 {
223 n = 10 * n + (c - '0');
224 c = yygetc (]AT_LEX_ARGS[);
225 }
226
227 yyungetc (]AT_LEX_PRE_ARGS[ c);
228
229 return sign * n;
230 }
231
232
233
234 /*---------------------------------------------------------------.
235 | Lexical analyzer returns an integer on the stack and the token |
236 | NUM, or the ASCII character read if not a number. Skips all |
237 | blanks and tabs, returns 0 for EOF. |
238 `---------------------------------------------------------------*/
239
240 static int
241 yylex (]AT_LEX_FORMALS[)
242 {
243 static int init = 1;
244 int c;
245
246 if (init)
247 {
248 init = 0;
249 ]AT_LALR1_CC_IF([],
250 [AT_LOCATION_IF([
251 AT_LOC.last_column = 0;
252 AT_LOC.last_line = 1;
253 ])])[
254 }
255
256 ]AT_LALR1_CC_IF(
257 [ AT_LOC.begin = AT_LOC.end;],
258 [AT_LOCATION_IF([
259 AT_LOC.first_column = AT_LOC.last_column;
260 AT_LOC.first_line = AT_LOC.last_line;
261 ])])[
262
263 /* Skip white space. */
264 while ((c = yygetc (]AT_LEX_ARGS[)) == ' ' || c == '\t')
265 {
266 ]AT_LALR1_CC_IF(
267 [ AT_LOC.begin = AT_LOC.end;],
268 [AT_LOCATION_IF([
269 AT_LOC.first_column = AT_LOC.last_column;
270 AT_LOC.first_line = AT_LOC.last_line;
271 ])])[
272 }
273
274 /* process numbers */
275 if (c == '.' || isdigit (c))
276 {
277 yyungetc (]AT_LEX_PRE_ARGS[ c);
278 ]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
279 return NUM;
280 }
281
282 /* Return end-of-file. */
283 if (c == EOF)
284 return CALC_EOF;
285
286 /* Return single chars. */
287 return c;
288 }
289
290 static int
291 power (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
301
302 int
303 main (int argc, const char **argv)
304 {
305 value result = 0;
306 int count = 0;
307 int status;
308
309 if (argc == 2)
310 yyin = fopen (argv[1], "r");
311 else
312 yyin = stdin;
313
314 if (!yyin)
315 {
316 perror (argv[1]);
317 exit (1);
318 }
319
320 #if YYDEBUG
321 yydebug = 1;
322 #endif
323 status = yyparse (]AT_PARAM_IF([&result, &count])[);
324 if (global_result != result)
325 abort ();
326 if (global_count != count)
327 abort ();
328 return status;
329 }
330 ]])
331 ])# _AT_DATA_CALC_Y
332
333
334 # AT_DATA_CALC_Y([BISON-OPTIONS])
335 # -------------------------------
336 # Produce `calc.y'.
337 m4_define([AT_DATA_CALC_Y],
338 [_AT_DATA_CALC_Y($[1], $[2], $[3], [$1])
339 ])
340
341
342
343 # _AT_CHECK_CALC(BISON-OPTIONS, INPUT, [NUM-STDERR-LINES = 0])
344 # ------------------------------------------------------------
345 # Run `calc' on INPUT and expect no STDOUT nor STDERR.
346 #
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.
352 m4_define([_AT_CHECK_CALC],
353 [AT_DATA([[input]],
354 [[$2
355 ]])
356 AT_PARSER_CHECK([./calc input], 0, [], [stderr])
357 m4_bmatch([$1],
358 [%debug.*%glr\|%glr.*%debug],
359 [],
360 [%debug],
361 [AT_CHECK([wc -l <stderr | sed 's/[[^0-9]]//g'], 0, [$3
362 ])])
363 ])
364
365
366 # _AT_CHECK_CALC_ERROR(BISON-OPTIONS, EXIT-STATUS, INPUT,
367 # [NUM-DEBUG-LINES],
368 # [VERBOSE-AND-LOCATED-ERROR-MESSAGE])
369 # ---------------------------------------------------------
370 # Run `calc' on INPUT, and expect a `syntax error' message.
371 #
372 # If INPUT starts with a slash, it is used as absolute input file name,
373 # otherwise as contents.
374 #
375 # If BISON-OPTIONS contains `%location', then make sure the ERROR-LOCATION
376 # is correctly output on stderr.
377 #
378 # If BISON-OPTIONS contains `%error-verbose', then make sure the
379 # IF-YYERROR-VERBOSE message is properly output after `syntax error, '
380 # on STDERR.
381 #
382 # If BISON-OPTIONS contains `%debug' but not `%glr', then NUM-STDERR-LINES
383 # is the number of expected lines on stderr.
384 m4_define([_AT_CHECK_CALC_ERROR],
385 [m4_bmatch([$3], [^/],
386 [AT_PARSER_CHECK([./calc $3], $2, [], [stderr])],
387 [AT_DATA([[input]],
388 [[$3
389 ]])
390 AT_PARSER_CHECK([./calc input], $2, [], [stderr])])
391 m4_bmatch([$1],
392 [%debug.*%glr\|%glr.*%debug],
393 [],
394 [%debug],
395 [AT_CHECK([wc -l <stderr | sed 's/[[^0-9]]//g'], 0, [$4
396 ])])
397
398 # Normalize the observed and expected error messages, depending upon the
399 # options.
400 # 1. Remove the traces from observed.
401 sed '/^Starting/d
402 /^Entering/d
403 /^Stack/d
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
412 mv at-stderr stderr
413 # 2. Create the reference error message.
414 AT_DATA([[expout]],
415 [$5
416 ])
417 # 3. If locations are not used, remove them.
418 AT_YYERROR_SEES_LOC_IF([],
419 [[sed 's/^[-0-9.]*: //' expout >at-expout
420 mv at-expout expout]])
421 # 4. If error-verbose is not used, strip the`, unexpected....' part.
422 m4_bmatch([$1], [%error-verbose], [],
423 [[sed 's/syntax error, .*$/syntax error/' expout >at-expout
424 mv at-expout expout]])
425 # 5. Check
426 AT_CHECK([cat stderr], 0, [expout])
427 ])
428
429
430 # AT_CALC_PUSHDEFS($1, $2, [BISON-OPTIONS])
431 # -----------------------------------------
432 # This macro works around the impossibility to define macros
433 # inside macros, because issuing `[$1]' is not possible in M4 :(.
434 # This sucks hard, GNU M4 should really provide M5 like $$1.
435 m4_define([AT_CHECK_PUSHDEFS],
436 [m4_if([$1$2], $[1]$[2], [],
437 [m4_fatal([$0: Invalid arguments: $@])])dnl
438 m4_pushdef([AT_LALR1_CC_IF],
439 [m4_bmatch([$3], ["lalr1.cc"], [$1], [$2])])
440 m4_pushdef([AT_GLR_IF],
441 [m4_bmatch([$3], [%glr-parser], [$1], [$2])])
442 m4_pushdef([AT_PARAM_IF],
443 [m4_bmatch([$3], [%parse-param], [$1], [$2])])
444 m4_pushdef([AT_LOCATION_IF],
445 [m4_bmatch([$3], [%locations], [$1], [$2])])
446 m4_pushdef([AT_PURE_IF],
447 [m4_bmatch([$3], [%pure-parser], [$1], [$2])])
448 m4_pushdef([AT_PURE_AND_LOC_IF],
449 [m4_bmatch([$3], [%locations.*%pure-parser\|%pure-parser.*%locations],
450 [$1], [$2])])
451 m4_pushdef([AT_GLR_OR_PARAM_IF],
452 [m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
453
454 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
455 m4_pushdef([AT_YYERROR_ARG_LOC_IF],
456 [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
457 [$2])])
458 # yyerror cannot see the locations if !glr & pure & !param.
459 m4_pushdef([AT_YYERROR_SEES_LOC_IF],
460 [AT_LALR1_CC_IF([$1],
461 [AT_LOCATION_IF([AT_GLR_IF([$1],
462 [AT_PURE_IF([AT_PARAM_IF([$1],
463 [$2])],
464 [$1])])],
465 [$2])])])
466
467 # The interface is pure: either because %pure-parser, or because we
468 # are using the C++ parsers.
469 m4_pushdef([AT_PURE_LEX_IF],
470 [AT_PURE_IF([$1],
471 [AT_LALR1_CC_IF([$1], [$2])])])
472
473 AT_PURE_LEX_IF(
474 [m4_pushdef([AT_LOC], [(*yylloc)])
475 m4_pushdef([AT_VAL], [(*yylval)])
476 m4_pushdef([AT_LEX_FORMALS],
477 [YYSTYPE *yylval[]AT_LOCATION_IF([, YYLTYPE *yylloc])])
478 m4_pushdef([AT_LEX_ARGS],
479 [yylval[]AT_LOCATION_IF([, yylloc])])
480 m4_pushdef([AT_USE_LEX_ARGS],
481 [(void) yylval;AT_LOCATION_IF([(void) yylloc])])
482 m4_pushdef([AT_LEX_PRE_FORMALS],
483 [AT_LEX_FORMALS, ])
484 m4_pushdef([AT_LEX_PRE_ARGS],
485 [AT_LEX_ARGS, ])
486 ],
487 [m4_pushdef([AT_LOC], [(yylloc)])
488 m4_pushdef([AT_VAL], [(yylval)])
489 m4_pushdef([AT_LEX_FORMALS], [void])
490 m4_pushdef([AT_LEX_ARGS], [])
491 m4_pushdef([AT_USE_LEX_ARGS], [])
492 m4_pushdef([AT_LEX_PRE_FORMALS], [])
493 m4_pushdef([AT_LEX_PRE_ARGS], [])
494 ])
495 ])# AT_CALC_PUSHDEFS
496
497
498 # AT_CALC_POPDEFS
499 # ---------------
500 m4_define([AT_CHECK_POPDEFS],
501 [m4_popdef([AT_LEX_PRE_ARGS])
502 m4_popdef([AT_LEX_PRE_FORMALS])
503 m4_popdef([AT_USE_LEX_ARGS])
504 m4_popdef([AT_LEX_ARGS])
505 m4_popdef([AT_LEX_FORMALS])
506 m4_popdef([AT_VAL])
507 m4_popdef([AT_LOC])
508 m4_popdef([AT_PURE_LEX_IF])
509 m4_popdef([AT_YYERROR_SEES_LOC_IF])
510 m4_popdef([AT_YYERROR_ARG_LOC_IF])
511 m4_popdef([AT_GLR_OR_PARAM_IF])
512 m4_popdef([AT_PURE_AND_LOC_IF])
513 m4_popdef([AT_LOCATION_IF])
514 m4_popdef([AT_PARAM_IF])
515 m4_popdef([AT_GLR_IF])
516 m4_popdef([AT_LALR1_CC_IF])
517 ])
518
519
520
521 # AT_CHECK_CALC([BISON-OPTIONS])
522 # ------------------------------
523 # Start a testing chunk which compiles `calc' grammar with
524 # BISON-OPTIONS, and performs several tests over the parser.
525 m4_define([AT_CHECK_CALC],
526 [# We use integers to avoid dependencies upon the precision of doubles.
527 AT_SETUP([Calculator $1])
528
529 AT_CHECK_PUSHDEFS($[1], $[2], [$1])
530
531 AT_DATA_CALC_Y([$1])
532
533 # Specify the output files to avoid problems on different file systems.
534 AT_CHECK([bison -o calc.c calc.y],
535 [0], [], [])
536
537 AT_LALR1_CC_IF(
538 [AT_CHECK([$CXX --version || exit 77], 0, ignore, ignore)
539 AT_COMPILE_CXX([calc])],
540 [AT_COMPILE([calc])])
541
542 # Test the priorities.
543 _AT_CHECK_CALC([$1],
544 [1 + 2 * 3 = 7
545 1 + 2 * -3 = -5
546
547 -1^2 = -1
548 (-1)^2 = 1
549
550 ---1 = -1
551
552 1 - 2 - 3 = -4
553 1 - (2 - 3) = 2
554
555 2^2^3 = 256
556 (2^2)^3 = 64],
557 [486])
558
559 # Some syntax errors.
560 _AT_CHECK_CALC_ERROR([$1], [1], [0 0], [11],
561 [1.2: syntax error, unexpected "number"])
562 _AT_CHECK_CALC_ERROR([$1], [1], [1//2], [15],
563 [1.2: syntax error, unexpected '/', expecting "number" or '-' or '(' or '!'])
564 _AT_CHECK_CALC_ERROR([$1], [1], [error], [4],
565 [1.0: syntax error, unexpected $undefined])
566 _AT_CHECK_CALC_ERROR([$1], [1], [1 = 2 = 3], [22],
567 [1.6: syntax error, unexpected '='])
568 _AT_CHECK_CALC_ERROR([$1], [1],
569 [
570 +1],
571 [14],
572 [2.0: syntax error, unexpected '+'])
573 # Exercise error messages with EOF: work on an empty file.
574 _AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4],
575 [1.0: syntax error, unexpected "end of input"])
576
577 # Exercise the error token: without it, we die at the first error,
578 # hence be sure to
579 #
580 # - have several errors which exercise different shift/discardings
581 # - (): nothing to pop, nothing to discard
582 # - (1 + 1 + 1 +): a lot to pop, nothing to discard
583 # - (* * *): nothing to pop, a lot to discard
584 # - (1 + 2 * *): some to pop and discard
585 #
586 # - test the action associated to `error'
587 #
588 # - check the lookahead that triggers an error is not discarded
589 # when we enter error recovery. Below, the lookahead causing the
590 # first error is ")", which is needed to recover from the error and
591 # produce the "0" that triggers the "0 != 1" error.
592 #
593 _AT_CHECK_CALC_ERROR([$1], [0],
594 [() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1],
595 [156],
596 [1.1: syntax error, unexpected ')', expecting "number" or '-' or '(' or '!'
597 1.17: syntax error, unexpected ')', expecting "number" or '-' or '(' or '!'
598 1.22: syntax error, unexpected '*', expecting "number" or '-' or '(' or '!'
599 1.40: syntax error, unexpected '*', expecting "number" or '-' or '(' or '!'
600 calc: error: 4444 != 1])
601
602 # The same, but this time exercising explicitly triggered syntax errors.
603 # POSIX says the lookahead causing the error should not be discarded.
604 _AT_CHECK_CALC_ERROR([$1], [0], [(!) + (0 0) = 1], [64],
605 [1.9: syntax error, unexpected "number"
606 calc: error: 2222 != 1])
607 AT_CHECK_POPDEFS
608
609 AT_CLEANUP
610 ])# AT_CHECK_CALC
611
612
613
614
615 # ------------------------ #
616 # Simple LALR Calculator. #
617 # ------------------------ #
618
619 AT_BANNER([[Simple LALR Calculator.]])
620
621 # AT_CHECK_CALC_LALR([BISON-OPTIONS])
622 # -----------------------------------
623 # Start a testing chunk which compiles `calc' grammar with
624 # BISON-OPTIONS, and performs several tests over the parser.
625 m4_define([AT_CHECK_CALC_LALR],
626 [AT_CHECK_CALC($@)])
627
628 AT_CHECK_CALC_LALR()
629
630 AT_CHECK_CALC_LALR([%defines])
631 AT_CHECK_CALC_LALR([%locations])
632 AT_CHECK_CALC_LALR([%name-prefix="calc"])
633 AT_CHECK_CALC_LALR([%verbose])
634 AT_CHECK_CALC_LALR([%yacc])
635 AT_CHECK_CALC_LALR([%error-verbose])
636
637 AT_CHECK_CALC_LALR([%error-verbose %locations])
638
639 AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc])
640
641 AT_CHECK_CALC_LALR([%debug])
642 AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
643
644 AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
645
646 AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {value *result} %parse-param {int *count}])
647
648
649 # ----------------------- #
650 # Simple GLR Calculator. #
651 # ----------------------- #
652
653 AT_BANNER([[Simple GLR Calculator.]])
654
655 # AT_CHECK_CALC_GLR([BISON-OPTIONS])
656 # ----------------------------------
657 # Start a testing chunk which compiles `calc' grammar with
658 # BISON-OPTIONS and %glr-parser, and performs several tests over the parser.
659 m4_define([AT_CHECK_CALC_GLR],
660 [AT_CHECK_CALC([%glr-parser] $@)])
661
662
663 AT_CHECK_CALC_GLR()
664
665 AT_CHECK_CALC_GLR([%defines])
666 AT_CHECK_CALC_GLR([%locations])
667 AT_CHECK_CALC_GLR([%name-prefix="calc"])
668 AT_CHECK_CALC_GLR([%verbose])
669 AT_CHECK_CALC_GLR([%yacc])
670 AT_CHECK_CALC_GLR([%error-verbose])
671
672 AT_CHECK_CALC_GLR([%error-verbose %locations])
673
674 AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc])
675
676 AT_CHECK_CALC_GLR([%debug])
677 AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
678
679 AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
680
681 AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {value *result} %parse-param {int *count}])
682
683
684 # ----------------------------- #
685 # Simple LALR1 C++ Calculator. #
686 # ----------------------------- #
687
688 AT_BANNER([[Simple LALR1 C++ Calculator.]])
689
690 # AT_CHECK_CALC_LALR1_CC([BISON-OPTIONS])
691 # ---------------------------------------
692 # Start a testing chunk which compiles `calc' grammar with
693 # BISON-OPTIONS and %glr-parser, and performs several tests over the parser.
694 m4_define([AT_CHECK_CALC_LALR1_CC],
695 [AT_CHECK_CALC([%skeleton "lalr1.cc"] $@)])
696
697 # AT_CHECK_CALC_LALR1_CC()
698
699 AT_CHECK_CALC_LALR1_CC([%defines %pure-parser %locations])
700
701 # AT_CHECK_CALC_LALR1_CC([%defines])
702 # AT_CHECK_CALC_LALR1_CC([%locations])
703 # AT_CHECK_CALC_LALR1_CC([%name-prefix="calc"])
704 # AT_CHECK_CALC_LALR1_CC([%verbose])
705 # AT_CHECK_CALC_LALR1_CC([%yacc])
706 # AT_CHECK_CALC_LALR1_CC([%error-verbose])
707
708 # AT_CHECK_CALC_LALR1_CC([%error-verbose %locations])
709
710 # AT_CHECK_CALC_LALR1_CC([%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc])
711
712 # AT_CHECK_CALC_LALR1_CC([%debug])
713 # AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
714
715 # AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc])
716
717 # 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}])