1 # Simple calculator. -*- Autotest -*-
3 # Copyright (C) 2000-2015, 2018-2020 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 ## ---------------------------------------------------- ##
19 ## Compile the grammar described in the documentation. ##
20 ## ---------------------------------------------------- ##
23 m4_pushdef([AT_CALC_MAIN], [AT_LANG_DISPATCH([$0], $@)])
24 m4_pushdef([AT_CALC_YYLEX], [AT_LANG_DISPATCH([$0], $@)])
31 # _AT_DATA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES])
32 # -----------------------------------------------
33 # Produce 'calc.y' and, if %header was specified, 'calc-lex.c' or
36 # Don't call this macro directly, because it contains some occurrences
37 # of '$1' etc. which will be interpreted by m4. So you should call it
38 # with $1, $2, and $3 as arguments, which is what AT_DATA_CALC_Y does.
40 # When %header is not passed, generate a single self-contained file.
41 # Otherwise, generate three: calc.y with the parser, calc-lex.c with
42 # the scanner, and calc-main.c with "main()". This is in order to
43 # stress the use of the generated parser header. To avoid code
44 # duplication, AT_CALC_YYLEX and AT_CALC_MAIN contain the body of these
46 m4_pushdef([_AT_DATA_CALC_Y],
47 [m4_if([$1$2$3], $[1]$[2]$[3], [],
48 [m4_fatal([$0: Invalid arguments: $@])])dnl
49 AT_LANG_DISPATCH([$0], $@)])
58 m4_define([AT_CALC_MAIN(c)],
60 #include <stdlib.h> /* exit */
61 #include <string.h> /* strcmp */
67 /* A C++ ]AT_NAME_PREFIX[parse that simulates the C signature. */
69 ]AT_NAME_PREFIX[parse (]AT_PARAM_IF([semantic_value *result, int *count, int *nerrs]))[
71 ]AT_NAME_PREFIX[::parser parser]AT_PARAM_IF([ (result, count, nerrs)])[;
72 #if ]AT_API_PREFIX[DEBUG
73 parser.set_debug_level (1);
75 return parser.parse ();
80 /* Value of the last computation. */
81 semantic_value global_result = 0;
82 /* Total number of computations. */
84 /* Total number of errors. */
88 open_file (const char *file)
90 FILE *res = (file && *file && strcmp (file, "-")) ? fopen (file, "r") : stdin;
99 /* A C main function. */
101 main (int argc, const char **argv)
103 semantic_value result = 0;
108 /* This used to be alarm (10), but that isn't enough time for a July
109 1995 vintage DEC Alphastation 200 4/100 system, according to
110 Nelson H. F. Beebe. 100 seconds was enough for regular users,
111 but the Hydra build farm, which is heavily loaded needs more. */
115 ]AT_CXX_IF([], [AT_DEBUG_IF([ ]AT_NAME_PREFIX[debug = 1;])])[
119 for (i = 1; i < argc; ++i)
122 if (!strcmp (argv[i], "--exp") && i+1 < argc)
124 input = open_file (argv[i+1]);
126 ]AT_NAME_PREFIX[parse_exp_t res = ]AT_NAME_PREFIX[parse_exp ();
127 printf ("exp => %d (status: %d, errors: %d)\n",
128 res.yystatus == 0 ? res.yyvalue : 0, res.yystatus, res.yynerrs);
129 status = res.yystatus;
132 else if (!strcmp (argv[i], "--num") && i+1 < argc)
134 input = open_file (argv[i+1]);
136 ]AT_NAME_PREFIX[parse_NUM_t res = ]AT_NAME_PREFIX[parse_NUM ();
137 printf ("NUM => %d (status: %d, errors: %d)\n",
138 res.yystatus == 0 ? res.yyvalue : 0, res.yystatus, res.yynerrs);
139 status = res.yystatus;
144 input = open_file (argv[i]);
145 status = ]AT_NAME_PREFIX[parse (]AT_PARAM_IF([[&result, &count, &nerrs]])[);
147 if (input != stdin && fclose (input))
152 assert (global_result == result); (void) result;
153 assert (global_count == count); (void) count;
154 assert (global_nerrs == nerrs); (void) nerrs;
155 printf ("final: %d %d %d\n", global_result, global_count, global_nerrs);]])[
162 m4_define([AT_CALC_YYLEX(c)],
165 ]AT_YYLEX_DECLARE_EXTERN[
168 static AT_YYLTYPE last_yylloc;
171 get_char (]AT_YYLEX_FORMALS[)
173 int res = getc (input);
176 last_yylloc = AT_LOC;
180 AT_LOC_LAST_COLUMN = 1;
183 AT_LOC_LAST_COLUMN++;
189 unget_char (]AT_YYLEX_PRE_FORMALS[ int c)
193 /* Wrong when C == '\n'. */
194 AT_LOC = last_yylloc;
200 read_integer (]AT_YYLEX_FORMALS[)
202 int c = get_char (]AT_YYLEX_ARGS[);
208 res = 10 * res + (c - '0');
209 c = get_char (]AT_YYLEX_ARGS[);
212 unget_char (]AT_YYLEX_PRE_ARGS[ c);
218 /*---------------------------------------------------------------.
219 | Lexical analyzer returns an integer on the stack and the token |
220 | NUM, or the ASCII character read if not a number. Skips all |
221 | blanks and tabs, returns 0 for EOF. |
222 `---------------------------------------------------------------*/
227 /* Skip white spaces. */
231 AT_LOC_FIRST_COLUMN = AT_LOC_LAST_COLUMN;
232 AT_LOC_FIRST_LINE = AT_LOC_LAST_LINE;
235 while ((c = get_char (]AT_YYLEX_ARGS[)) == ' '
237 || (ignore_eol && c == '\n'));
239 /* Process numbers. */
242 unget_char (]AT_YYLEX_PRE_ARGS[ c);
243 ]AT_VAL[.]AT_VALUE_UNION_IF([NUM], [ival])[ = read_integer (]AT_YYLEX_ARGS[);
244 return ]AT_CXX_IF([AT_NAMESPACE::parser::token::])[]AT_TOKEN_PREFIX[NUM;
247 /* Return end-of-file. */
249 return ]AT_CXX_IF([AT_NAMESPACE::parser::token::])[]AT_TOKEN_PREFIX[CALC_EOF;
251 /* An explicit error raised by the scanner. */
254 fprintf (stderr, "%d.%d: ",
255 AT_LOC_FIRST_LINE, AT_LOC_FIRST_COLUMN);])[
256 fputs ("syntax error: invalid character: '#'\n", stderr);
257 return ]AT_CXX_IF([AT_NAMESPACE::parser::token::])[]AT_TOKEN_PREFIX[]AT_API_PREFIX[error;
260 /* Return single chars. */
266 m4_define([_AT_DATA_CALC_Y(c)],
267 [AT_DATA_GRAMMAR([calc.y],
268 [[/* Infix notation calculator--calc */
272 ]AT_LOCATION_TYPE_SPAN_IF([[
285 # define YYLLOC_DEFAULT(Current, Rhs, N) \
289 (Current).first = YYRHSLOC (Rhs, 1).first; \
290 (Current).last = YYRHSLOC (Rhs, N).last; \
294 (Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \
300 void location_print (FILE *o, Span s);
301 #define LOCATION_PRINT location_print
305 /* Exercise pre-prologue dependency to %union. */
306 typedef int semantic_value;
309 ]AT_VALUE_UNION_IF([],
310 [[/* Exercise %union. */
315 %printer { ]AT_CXX_IF([[yyo << $$]],
316 [[fprintf (yyo, "%d", $$)]])[; } <]AT_VALUE_UNION_IF([int], [ival])[>;
323 /* Whether \n is a blank. */
324 extern int ignore_eol;
325 extern semantic_value global_result;
326 extern int global_count;
327 extern int global_nerrs;
338 static int power (int base, int exponent);
341 ]AT_YYLEX_DECLARE_EXTERN[
343 ]AT_TOKEN_TRANSLATE_IF([[
349 if (strcmp (cp, "end of input") == 0)
350 return "end of file";
351 else if (strcmp (cp, "number") == 0)
359 ]AT_LOCATION_TYPE_SPAN_IF([[
362 @$.first.l = @$.first.c = 1;
366 /* Bison Declarations */
367 %token CALC_EOF 0 ]AT_TOKEN_TRANSLATE_IF([_("end of input")], ["end of input"])[
368 %token <]AT_VALUE_UNION_IF([int], [ival])[> NUM "number"
369 %type <]AT_VALUE_UNION_IF([int], [ival])[> exp
371 %nonassoc '=' /* comparison */
374 %precedence NEG /* negation--unary minus */
375 %right '^' /* exponentiation */
377 /* Grammar follows */
381 | input line { ]AT_PARAM_IF([++*count; ++global_count;])[ }
386 | exp '\n' { ]AT_PARAM_IF([*result = global_result = $1;], [USE ($1);])[ }
393 if ($1 != $3)]AT_LANG_CASE(
397 snprintf (buf, sizeof buf, "error: %d != %d", $1, $3);]AT_YYERROR_ARG_LOC_IF([[
398 yyerror (&@$, ]AT_PARAM_IF([result, count, nerrs, ])[buf);]], [[
400 YYLTYPE old_yylloc = yylloc;
402 yyerror (]AT_PARAM_IF([result, count, nerrs, ])[buf);
410 snprintf (buf, sizeof buf, "error: %d != %d", $1, $3);
411 ]AT_GLR_IF([[yyparser.]])[error (]AT_LOCATION_IF([[@$, ]])[buf);
415 | exp '+' exp { $$ = $1 + $3; }
416 | exp '-' exp { $$ = $1 - $3; }
417 | exp '*' exp { $$ = $1 * $3; }
420 if ($3 == 0)]AT_LANG_CASE(
422 {]AT_YYERROR_ARG_LOC_IF([[
423 yyerror (&@3, ]AT_PARAM_IF([result, count, nerrs, ])["error: null divisor");]], [[
425 YYLTYPE old_yylloc = yylloc;
427 yyerror (]AT_PARAM_IF([result, count, nerrs, ])["error: null divisor");
434 ]AT_GLR_IF([[yyparser.]])[error (]AT_LOCATION_IF([[@3, ]])["error: null divisor");
439 | '-' exp %prec NEG { $$ = -$2; }
440 | exp '^' exp { $$ = power ($1, $3); }
441 | '(' exp ')' { $$ = $2; }
442 | '(' error ')' { $$ = 1111; yyerrok; }
443 | '!' { $$ = 0; YYERROR; }
444 | '-' error { $$ = 0; YYERROR; }
449 power (int base, int exponent)
452 assert (0 <= exponent);
453 for (/* Niente */; exponent; --exponent)
458 ]AT_LOCATION_TYPE_SPAN_IF([AT_CXX_IF([[
463 operator<< (std::ostream& o, const Span& s)
465 o << s.first.l << '.' << s.first.c;
466 if (s.first.l != s.last.l)
467 o << '-' << s.last.l << '.' << s.last.c - 1;
468 else if (s.first.c != s.last.c - 1)
469 o << '-' << s.last.c - 1;
475 location_print (FILE *o, Span s)
477 fprintf (o, "%d.%d", s.first.l, s.first.c);
478 if (s.first.l != s.last.l)
479 fprintf (o, "-%d.%d", s.last.l, s.last.c - 1);
480 else if (s.first.c != s.last.c - 1)
481 fprintf (o, "-%d", s.last.c - 1);
489 AT_HEADER_IF([AT_DATA_SOURCE([[calc-lex.]AT_LANG_EXT],
490 [[#include "calc.]AT_LANG_HDR["
493 AT_DATA_SOURCE([[calc-main.]AT_LANG_EXT],
494 [[#include "calc.]AT_LANG_HDR["
498 ])# _AT_DATA_CALC_Y(c)
506 m4_copy([AT_CALC_MAIN(c)], [AT_CALC_MAIN(c++)])
507 m4_copy([AT_CALC_YYLEX(c)], [AT_CALC_YYLEX(c++)])
508 m4_copy([_AT_DATA_CALC_Y(c)], [_AT_DATA_CALC_Y(c++)])
516 m4_define([AT_CALC_MAIN(d)],
517 [[int main (string[] args)
519 semantic_value result = 0;
522 File input = args.length == 2 ? File (args[1], "r") : stdin;
523 auto l = calcLexer (input);
524 auto p = new YYParser (l);]AT_DEBUG_IF([[
525 p.setDebugLevel (1);]])[
530 m4_define([AT_CALC_YYLEX(d)],
531 [[import std.range.primitives;
534 auto calcLexer(R)(R range)
535 if (isInputRange!R && is (ElementType!R : dchar))
537 return new CalcLexer!R(range);
540 auto calcLexer (File f)
542 import std.algorithm : map, joiner;
543 import std.utf : byDchar;
545 return f.byChunk(1024) // avoid making a syscall roundtrip per char
546 .map!(chunk => cast(char[]) chunk) // because byChunk returns ubyte[]
547 .joiner // combine chunks into a single virtual range of char
548 .calcLexer; // forward to other overload
551 class CalcLexer(R) : Lexer
552 if (isInputRange!R && is (ElementType!R : dchar))
562 YYSemanticType semanticVal_;]AT_LOCATION_IF([[
563 YYLocation location = new YYLocation;
565 public final @property YYPosition startPos()
567 return location.begin;
570 public final @property YYPosition endPos()
575 public final @property YYSemanticType semanticVal()
583 import std.uni : isNumber;
584 while (input.front.isNumber)
586 res = res * 10 + (input.front - '0');]AT_LOCATION_IF([[
587 location.end.column += 1;]])[
595 location.begin = location.end;]])[
597 import std.uni : isWhite, isNumber;
599 // Skip initial spaces
600 while (!input.empty && input.front != '\n' && isWhite (input.front))
602 input.popFront;]AT_LOCATION_IF([[
603 location.begin.column += 1;
604 location.end.column += 1;]])[
609 return TokenKind.]AT_TOKEN_PREFIX[CALC_EOF;
612 if (input.front.isNumber)
614 semanticVal_.ival = parseInt;
615 return TokenKind.]AT_TOKEN_PREFIX[NUM;
618 // Individual characters
619 auto c = input.front;]AT_LOCATION_IF([[
622 location.end.line += 1;
623 location.end.column = 1;
626 location.end.column += 1;]])[
629 // An explicit error raised by the scanner. */
632 stderr.writeln (]AT_LOCATION_IF([location, ": ", ])["syntax error: invalid character: '#'");
633 return TokenKind.]AT_TOKEN_PREFIX[YYerror;
638 case '+': return TokenKind.]AT_TOKEN_PREFIX[PLUS;
639 case '-': return TokenKind.]AT_TOKEN_PREFIX[MINUS;
640 case '*': return TokenKind.]AT_TOKEN_PREFIX[STAR;
641 case '/': return TokenKind.]AT_TOKEN_PREFIX[SLASH;
642 case '(': return TokenKind.]AT_TOKEN_PREFIX[LPAR;
643 case ')': return TokenKind.]AT_TOKEN_PREFIX[RPAR;
644 case '\n': return TokenKind.]AT_TOKEN_PREFIX[EOL;
645 case '=': return TokenKind.]AT_TOKEN_PREFIX[EQUAL;
646 case '^': return TokenKind.]AT_TOKEN_PREFIX[POW;
647 case '!': return TokenKind.]AT_TOKEN_PREFIX[NOT;
648 default: return TokenKind.]AT_TOKEN_PREFIX[YYUNDEF;
654 m4_define([_AT_DATA_CALC_Y(d)],
655 [AT_DATA_GRAMMAR([calc.y],
656 [[/* Infix notation calculator--calc */
659 alias semantic_value = int;
661 /* Exercise %union. */
666 %printer { fprintf (yyo, "%d", $$); } <ival>;
668 /* Bison Declarations */
669 %token CALC_EOF 0 ]AT_TOKEN_TRANSLATE_IF([_("end of input")], ["end of input"])[
670 %token <ival> NUM "number"
684 %nonassoc "=" /* comparison */
687 %precedence NEG /* negation--unary minus */
688 %right "^" /* exponentiation */
690 /* Grammar follows */
694 | input line { ]AT_PARAM_IF([++*count; ++global_count;])[ }
699 | exp EOL { ]AT_PARAM_IF([*result = global_result = $1;])[ }
707 yyerror (]AT_LOCATION_IF([[@$, ]])[format ("error: %d != %d", $1, $3));
710 | exp "+" exp { $$ = $1 + $3; }
711 | exp "-" exp { $$ = $1 - $3; }
712 | exp "*" exp { $$ = $1 * $3; }
716 yyerror (]AT_LOCATION_IF([[@3, ]])["error: null divisor");
720 | "-" exp %prec NEG { $$ = -$2; }
721 | exp "^" exp { $$ = power ($1, $3); }
722 | "(" exp ")" { $$ = $2; }
723 | "(" error ")" { $$ = 1111; }
724 | "!" { $$ = 0; return YYERROR; }
725 | "-" error { $$ = 0; return YYERROR; }
730 power (int base, int exponent)
733 assert (0 <= exponent);
734 for (/* Niente */; exponent; --exponent)
742 ])# _AT_DATA_CALC_Y(d)
750 m4_define([AT_CALC_MAIN(java)],
751 [[public static void main (String[] args) throws IOException
753 Calc p = new Calc (System.in);]], [[
754 CalcLexer l = new CalcLexer (System.in);
755 Calc p = new Calc (l);]])AT_DEBUG_IF([[
756 p.setDebugLevel (1);]])[
757 boolean success = p.parse ();
763 m4_define([AT_CALC_YYLEX(java)],
764 [AT_LEXPARAM_IF([[%code lexer {]],
765 [[%code epilogue { class CalcLexer implements Calc.Lexer {]])[
766 StreamTokenizer st;]AT_LOCATION_IF([[
767 PositionReader reader;]])[
769 public ]AT_LEXPARAM_IF([[YYLexer]], [[CalcLexer]])[ (InputStream is)
771 reader = new PositionReader (new InputStreamReader (is));
772 st = new StreamTokenizer (reader);]], [[
773 st = new StreamTokenizer (new InputStreamReader (is));]])[
775 st.eolIsSignificant (true);
776 st.wordChars ('0', '9');
780 Position start = new Position (1, 0);
781 Position end = new Position (1, 0);
783 public Position getStartPos () {
784 return new Position (start);
787 public Position getEndPos () {
788 return new Position (end);
796 public Object getLVal () {
800 public int yylex () throws IOException {;]AT_LOCATION_IF([[
801 start.set (reader.getPosition ());]])[
802 int tkind = st.nextToken ();]AT_LOCATION_IF([[
803 end.set (reader.getPosition ());]])[
806 case StreamTokenizer.TT_EOF:
808 case StreamTokenizer.TT_EOL:;]AT_LOCATION_IF([[
812 case StreamTokenizer.TT_WORD:
813 yylval = new Integer (st.sval);]AT_LOCATION_IF([[
814 end.set (reader.getPreviousPosition ());]])[
819 System.err.println(]AT_LOCATION_IF([[start + ": " + ]])["syntax error: invalid character: '#'");
825 ]AT_LEXPARAM_IF([], [[}]])[
829 m4_define([_AT_DATA_CALC_Y(java)],
830 [AT_DATA_GRAMMAR([Calc.y],
831 [[/* Infix notation calculator--calc */
832 %define api.prefix {Calc}
833 %define api.parser.class {Calc}
838 %code imports {]AT_LOCATION_IF([[
839 import java.io.BufferedReader;]])[
840 import java.io.IOException;
841 import java.io.InputStream;
842 import java.io.InputStreamReader;
843 import java.io.Reader;
844 import java.io.StreamTokenizer;
850 ]AT_TOKEN_TRANSLATE_IF([[
851 static String i18n(String s)
853 if (s.equals ("end of input"))
854 return "end of file";
855 else if (s.equals ("number"))
863 /* Bison Declarations */
864 %token CALC_EOF 0 ]AT_TOKEN_TRANSLATE_IF([_("end of input")], ["end of input"])[
865 %token <Integer> NUM "number"
868 %nonassoc '=' /* comparison */
871 %precedence NEG /* negation--unary minus */
872 %right '^' /* exponentiation */
874 /* Grammar follows */
890 if ($1.intValue () != $3.intValue ())
891 yyerror (]AT_LOCATION_IF([[@$, ]])["error: " + $1 + " != " + $3);
893 | exp '+' exp { $$ = $1 + $3; }
894 | exp '-' exp { $$ = $1 - $3; }
895 | exp '*' exp { $$ = $1 * $3; }
898 if ($3.intValue () == 0)
899 yyerror (]AT_LOCATION_IF([[@3, ]])["error: null divisor");
903 | '-' exp %prec NEG { $$ = -$2; }
904 | exp '^' exp { $$ = (int) Math.pow ($1, $3); }
905 | '(' exp ')' { $$ = $2; }
906 | '(' error ')' { $$ = 1111; }
907 | '!' { $$ = 0; return YYERROR; }
908 | '-' error { $$ = 0; return YYERROR; }
913 ]AT_JAVA_POSITION_DEFINE])[
915 ])# _AT_DATA_JAVA_CALC_Y
920 ## ------------------ ##
921 ## Calculator tests. ##
922 ## ------------------ ##
925 # AT_DATA_CALC_Y([BISON-OPTIONS])
926 # -------------------------------
927 # Produce 'calc.y' and, if %header was specified, 'calc-lex.c' or
929 m4_define([AT_DATA_CALC_Y],
930 [_AT_DATA_CALC_Y($[1], $[2], $[3], [$1])
934 # _AT_CHECK_CALC(CALC-OPTIONS, INPUT, [STDOUT], [NUM-STDERR-LINES])
935 # -----------------------------------------------------------------
936 # Run 'calc' on INPUT and expect no STDOUT nor STDERR.
938 # If BISON-OPTIONS contains '%debug' but not '%glr-parser', then
939 # NUM-STDERR-LINES is the number of expected lines on stderr.
940 # Currently this is ignored, though, since the output format is fluctuating.
942 # We don't count GLR's traces yet, since its traces are somewhat
943 # different from LALR's. Likewise for D.
945 # The push traces are the same, except for "Return for a new token", don't
947 m4_define([_AT_CHECK_CALC],
952 [AT_JAVA_PARSER_CHECK([Calc $1 < input], 0, [m4_ifvaln(m4_quote($3), [$3])], [stderr])],
953 [AT_PARSER_CHECK([calc $1 input], 0, [m4_ifvaln(m4_quote($3), [$3])], [stderr])])
954 AT_LANG_MATCH([c\|c++\|java],
956 [AT_CHECK([grep -c -v 'Return for a new token:' stderr],
958 [m4_n([AT_DEBUG_IF([$4], [0])])])])])
962 # _AT_CHECK_CALC_ERROR($1 = BISON-OPTIONS, $2 = EXIT-STATUS, $3 = INPUT,
964 # $5 = [NUM-STDERR-LINES],
965 # $6 = [CUSTOM-ERROR-MESSAGE])
966 # $7 = [CALC-OPTIONS])
967 # ----------------------------------------------------------------------
968 # Run 'calc' on INPUT, and expect a 'syntax error' message.
970 # If INPUT starts with a slash, it is used as absolute input file name,
971 # otherwise as contents.
973 # NUM-STDERR-LINES is the number of expected lines on stderr.
974 # If BISON-OPTIONS contains '%debug' but not '%glr', then NUM-STDERR-LINES
975 # is the number of expected lines on stderr.
977 # CUSTOM-ERROR-MESSAGE is the expected error message when parse.error
978 # is 'custom' and locations are enabled. Other expected formats are
980 m4_define([_AT_CHECK_CALC_ERROR],
981 [m4_bmatch([$3], [^/],
983 [AT_JAVA_PARSER_CHECK([Calc $7 < $3], $2, [m4_ifvaln(m4_quote($4), [$4])], [stderr])],
984 [AT_PARSER_CHECK([calc $7 $3], $2, [m4_ifvaln(m4_quote($4), [$4])], [stderr])])],
989 [AT_JAVA_PARSER_CHECK([Calc $7 < input], $2, [m4_ifvaln(m4_quote($4), [$4])], [stderr])],
990 [AT_PARSER_CHECK([calc $7 input], $2, [m4_ifvaln(m4_quote($4), [$4])], [stderr])])
993 # Normalize the observed and expected error messages, depending upon the
995 # 1. Remove the traces from observed.
1010 /^yydestructor:/d' stderr >at-stderr
1013 # 2. Create the reference error message.
1018 # 3. If locations are not used, remove them.
1019 AT_YYERROR_SEES_LOC_IF([],
1020 [[sed 's/^[-0-9.]*: //' expout >at-expout
1021 mv at-expout expout]])
1023 # 4. If parse.error is not custom, turn the expected message to
1024 # the traditional one.
1025 AT_ERROR_CUSTOM_IF([], [
1026 AT_PERL_REQUIRE([[-pi -e 'use strict;
1027 s{syntax error on token \[(.*?)\] \(expected: (.*)\)}
1030 my @exps = $][2 =~ /\[(.*?)\]/g;]AT_D_IF([[
1031 # In the case of D, there are no single quotes around the symbols.
1032 $unexp =~ s/'"'(.)'"'/$][1/g;
1033 s/'"'(.)'"'/$][1/g for @exps;]])[
1034 ($][#exps && $][#exps < 4)
1035 ? "syntax error, unexpected $unexp, expecting @{[join(\" or \", @exps)]}"
1036 : "syntax error, unexpected $unexp";
1041 # 5. If parse.error is simple, strip the', unexpected....' part.
1043 [[sed 's/syntax error, .*$/syntax error/' expout >at-expout
1044 mv at-expout expout]])
1046 # 6. Actually check.
1047 AT_CHECK([cat stderr], 0, [expout])
1051 # AT_CHECK_SPACES([FILES])
1052 # ------------------------
1053 # Make sure we did not introduce bad spaces. Checked here because all
1054 # the skeletons are (or should be) exercised here.
1055 m4_define([AT_CHECK_SPACES],
1056 [AT_PERL_CHECK([-ne '
1058 print "$ARGV:$.: {$_}\n"
1059 if (# No starting/ending empty lines.
1060 (eof || $. == 1) && /^\s*$/
1061 # No trailing space.
1070 # AT_CHECK_JAVA_GREP(FILE, [LINE], [COUNT=1])
1071 # -------------------------------------------
1072 # Check that FILE contains exactly COUNT lines matching ^LINE$
1073 # with grep. Unquoted so that COUNT can be a shell expression.
1074 m4_define([AT_CHECK_JAVA_GREP],
1075 [AT_CHECK_UNQUOTED([grep -c '^$2$' $1], [ignore], [m4_default([$3], [1])
1079 # AT_CHECK_CALC([BISON-OPTIONS], [COMPILER-OPTIONS])
1080 # --------------------------------------------------
1081 # Start a testing chunk which compiles 'calc' grammar with
1082 # BISON-OPTIONS, and performs several tests over the parser.
1083 m4_define([AT_CHECK_CALC],
1084 [m4_ifval([$3], [m4_fatal([$0: expected at most two arguments])])
1086 # We use integers to avoid dependencies upon the precision of doubles.
1087 AT_SETUP([Calculator $1 $2])
1089 AT_BISON_OPTION_PUSHDEFS([$1])
1091 AT_DATA_CALC_Y([$1])
1092 AT_FULL_COMPILE(AT_JAVA_IF([[Calc]], [[calc]]), AT_HEADER_IF([[lex], [main]], [[], []]), [$2], [-Wno-deprecated])
1095 [# No direct calls to malloc/free.
1096 AT_CHECK([[$EGREP '(malloc|free) *\(' calc.[ch] | $EGREP -v 'INFRINGES ON USER NAME SPACE']],
1099 AT_PUSH_IF([AT_JAVA_IF(
1100 [# Verify that this is a push parser.
1101 AT_CHECK_JAVA_GREP([[Calc.java]],
1102 [[.*public void push_parse_initialize ().*]])])])
1104 AT_CHECK_SPACES([AT_JAVA_IF([Calc], [calc]).AT_LANG_EXT AT_HEADER_IF([AT_JAVA_IF([Calc], [calc]).AT_LANG_HDR])])
1106 # Test the precedences.
1107 # The Java traces do not show the clean up sequence at the end,
1108 # since it does not support %destructor.
1123 [AT_PARAM_IF([final: 64 12 0])],
1124 [AT_JAVA_IF([1014], [1017])])
1126 # Some syntax errors.
1127 _AT_CHECK_CALC_ERROR([$1], [1], [1 2],
1128 [AT_PARAM_IF([final: 0 0 1])],
1130 [AT_JAVA_IF([1.3-1.4], [1.3])[: syntax error on token [number] (expected: ['='] ['-'] ['+'] ['*'] ['/'] ['^'] ['\n'])]])
1131 _AT_CHECK_CALC_ERROR([$1], [1], [1//2],
1132 [AT_PARAM_IF([final: 0 0 1])],
1134 [AT_JAVA_IF([1.3-1.4], [1.3])[: syntax error on token ['/'] (expected: [number] ['-'] ['('] ['!'])]])
1135 _AT_CHECK_CALC_ERROR([$1], [1], [error],
1136 [AT_PARAM_IF([final: 0 0 1])],
1138 [AT_JAVA_IF([1.1-1.2], [1.1])[: syntax error on token [invalid token] (expected: [number] ['-'] ['\n'] ['('] ['!'])]])
1139 _AT_CHECK_CALC_ERROR([$1], [1], [1 = 2 = 3],
1140 [AT_PARAM_IF([final: 0 0 1])],
1143 [AT_JAVA_IF([1.7-1.8], [1.7])[: syntax error on token ['='] (expected: ['-'] ['+'] ['*'] ['/'] ['^'] ['\n'])]],
1144 [AT_JAVA_IF([1.7-1.8], [1.7])[: syntax error on token ['='] (expected: ['-'] ['+'] ['*'] ['/'] ['^'])]])])
1145 _AT_CHECK_CALC_ERROR([$1], [1],
1148 [AT_PARAM_IF([final: 0 0 1])],
1150 [AT_JAVA_IF([2.1-2.2], [2.1])[: syntax error on token ['+'] (expected: ]AT_TOKEN_TRANSLATE_IF([[[end of file]]], [[[end of input]]])[ [number] ['-'] ['\n'] ['('] ['!'])]])
1151 # Exercise error messages with EOF: work on an empty file.
1152 _AT_CHECK_CALC_ERROR([$1], [1], [/dev/null],
1153 [AT_PARAM_IF([final: 0 0 1])],
1155 [[1.1: syntax error on token ]AT_TOKEN_TRANSLATE_IF([[[end of file]]], [[[end of input]]])[ (expected: [number] ['-'] ['\n'] ['('] ['!'])]])
1157 # Exercise the error token: without it, we die at the first error,
1160 # - have several errors which exercise different shift/discardings
1161 # - (): nothing to pop, nothing to discard
1162 # - (1 + 1 + 1 +): a lot to pop, nothing to discard
1163 # - (* * *): nothing to pop, a lot to discard
1164 # - (1 + 2 * *): some to pop and discard
1166 # - test the action associated to 'error'
1168 # - check the lookahead that triggers an error is not discarded
1169 # when we enter error recovery. Below, the lookahead causing the
1170 # first error is ")", which is needed to recover from the error and
1171 # produce the "0" that triggers the "0 != 1" error.
1173 _AT_CHECK_CALC_ERROR([$1], [0],
1174 [() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1],
1175 [AT_PARAM_IF([final: 4444 0 5])],
1177 [AT_JAVA_IF([1.2-1.3], [1.2])[: syntax error on token [')'] (expected: [number] ['-'] ['('] ['!'])
1178 ]AT_JAVA_IF([1.18-1.19], [1.18])[: syntax error on token [')'] (expected: [number] ['-'] ['('] ['!'])
1179 ]AT_JAVA_IF([1.23-1.24], [1.23])[: syntax error on token ['*'] (expected: [number] ['-'] ['('] ['!'])
1180 ]AT_JAVA_IF([1.41-1.42], [1.41])[: syntax error on token ['*'] (expected: [number] ['-'] ['('] ['!'])
1181 ]AT_JAVA_IF([1.1-1.47], [1.1-46])[: error: 4444 != 1]])
1183 # The same, but this time exercising explicitly triggered syntax errors.
1184 # POSIX says the lookahead causing the error should not be discarded.
1185 _AT_CHECK_CALC_ERROR([$1], [0], [(!) + (1 2) = 1],
1186 [AT_PARAM_IF([final: 2222 0 2])],
1188 [AT_JAVA_IF([1.10-1.11], [1.10])[: syntax error on token [number] (expected: ['='] ['-'] ['+'] ['*'] ['/'] ['^'] [')'])
1189 ]AT_JAVA_IF([1.1-1.16], [1.1-15])[: error: 2222 != 1]])
1191 _AT_CHECK_CALC_ERROR([$1], [0], [(- *) + (1 2) = 1],
1192 [AT_PARAM_IF([final: 2222 0 3])],
1194 [AT_JAVA_IF([1.4-1.5], [1.4])[: syntax error on token ['*'] (expected: [number] ['-'] ['('] ['!'])
1195 ]AT_JAVA_IF([1.12-1.13], [1.12])[: syntax error on token [number] (expected: ['='] ['-'] ['+'] ['*'] ['/'] ['^'] [')'])
1196 ]AT_JAVA_IF([1.1-1.18], [1.1-17])[: error: 2222 != 1]])
1198 # Check that yyerrok works properly: second error is not reported,
1199 # third and fourth are. Parse status is successful.
1200 _AT_CHECK_CALC_ERROR([$1], [0], [(* *) + (*) + (*)],
1201 [AT_PARAM_IF([final: 3333 0 3])],
1203 [AT_JAVA_IF([1.2-1.3], [1.2])[: syntax error on token ['*'] (expected: [number] ['-'] ['('] ['!'])
1204 ]AT_JAVA_IF([1.10-1.11], [1.10])[: syntax error on token ['*'] (expected: [number] ['-'] ['('] ['!'])
1205 ]AT_JAVA_IF([1.16-1.17], [1.16])[: syntax error on token ['*'] (expected: [number] ['-'] ['('] ['!'])]])
1210 # Check that returning YYerror from the scanner properly enters
1211 # error-recovery without issuing a second error message.
1213 _AT_CHECK_CALC_ERROR([$1], [0], [(#) + (#) = 2222],
1214 [AT_PARAM_IF([final: 2222 0 0])],
1216 [[1.2: syntax error: invalid character: '#'
1217 1.8: syntax error: invalid character: '#']])
1219 _AT_CHECK_CALC_ERROR([$1], [0], [(1 + #) = 1111],
1220 [AT_PARAM_IF([final: 1111 0 0])],
1222 [[1.6: syntax error: invalid character: '#']])
1224 _AT_CHECK_CALC_ERROR([$1], [0], [(# + 1) = 1111],
1225 [AT_PARAM_IF([final: 1111 0 0])],
1227 [[1.2: syntax error: invalid character: '#']])
1229 _AT_CHECK_CALC_ERROR([$1], [0], [(1 + # + 1) = 1111],
1230 [AT_PARAM_IF([final: 1111 0 0])],
1232 [[1.6: syntax error: invalid character: '#']])
1234 _AT_CHECK_CALC_ERROR([$1], [0], [(1 + 1) / (1 - 1)],
1235 [AT_PARAM_IF([final: 2 0 1])],
1237 [AT_JAVA_IF([1.11-1.18], [1.11-17])[: error: null divisor]])
1239 # Multiple start symbols.
1241 _AT_CHECK_CALC([--num], [[123]],
1242 [[NUM => 123 (status: 0, errors: 0)]],
1243 [AT_JAVA_IF([1014], [1017])])
1244 _AT_CHECK_CALC_ERROR([$1], [1], [1 + 2 * 3],
1245 [NUM => 0 (status: 1, errors: 1)],
1247 [[1.3: syntax error, unexpected '+', expecting end of file]],
1250 _AT_CHECK_CALC([--exp], [[1 + 2 * 3]],
1251 [[exp => 7 (status: 0, errors: 0)]],
1252 [AT_JAVA_IF([1014], [1017])])
1256 AT_BISON_OPTION_POPDEFS
1264 # ----------------- #
1265 # LALR Calculator. #
1266 # ----------------- #
1268 AT_BANNER([[LALR(1) Calculator.]])
1270 # AT_CHECK_CALC_LALR([BISON-OPTIONS])
1271 # -----------------------------------
1272 # Start a testing chunk which compiles 'calc' grammar with
1273 # BISON-OPTIONS, and performs several tests over the parser.
1274 m4_define([AT_CHECK_CALC_LALR],
1275 [AT_CHECK_CALC($@)])
1277 AT_CHECK_CALC_LALR([%define parse.trace])
1279 AT_CHECK_CALC_LALR([%header])
1280 AT_CHECK_CALC_LALR([%debug %locations])
1281 AT_CHECK_CALC_LALR([%locations %define api.location.type {Span}])
1283 AT_CHECK_CALC_LALR([%name-prefix "calc"])
1284 AT_CHECK_CALC_LALR([%verbose])
1285 AT_CHECK_CALC_LALR([%yacc])
1286 AT_CHECK_CALC_LALR([%define parse.error detailed])
1287 AT_CHECK_CALC_LALR([%define parse.error verbose])
1289 AT_CHECK_CALC_LALR([%define api.pure full %locations])
1290 AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %locations])
1291 AT_CHECK_CALC_LALR([%define parse.error detailed %locations])
1293 AT_CHECK_CALC_LALR([%define parse.error detailed %locations %header %define api.prefix {calc} %verbose %yacc])
1294 AT_CHECK_CALC_LALR([%define parse.error detailed %locations %header %name-prefix "calc" %define api.token.prefix {TOK_} %verbose %yacc])
1296 AT_CHECK_CALC_LALR([%debug])
1297 AT_CHECK_CALC_LALR([%define parse.error detailed %debug %locations %header %name-prefix "calc" %verbose %yacc])
1298 AT_CHECK_CALC_LALR([%define parse.error detailed %debug %locations %header %define api.prefix {calc} %verbose %yacc])
1300 AT_CHECK_CALC_LALR([%define api.pure full %define parse.error detailed %debug %locations %header %name-prefix "calc" %verbose %yacc])
1301 AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %define parse.error detailed %debug %locations %header %define api.prefix {calc} %verbose %yacc])
1303 AT_CHECK_CALC_LALR([%define api.pure %define parse.error detailed %debug %locations %header %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1305 AT_CHECK_CALC_LALR([%no-lines %define api.pure %define parse.error detailed %debug %locations %header %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1306 AT_CHECK_CALC_LALR([%no-lines %define api.pure %define parse.error verbose %debug %locations %header %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1307 AT_CHECK_CALC_LALR([%no-lines %define api.pure %define parse.error verbose %debug %locations %defines %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1309 # parse.error custom.
1310 AT_CHECK_CALC_LALR([%define parse.error custom])
1311 AT_CHECK_CALC_LALR([%define parse.error custom %locations %define api.prefix {calc}])
1312 AT_CHECK_CALC_LALR([%define parse.error custom %locations %define api.prefix {calc} %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1313 AT_CHECK_CALC_LALR([%define parse.error custom %locations %define api.prefix {calc} %parse-param {semantic_value *result}{int *count}{int *nerrs} %define api.push-pull both %define api.pure full])
1314 AT_CHECK_CALC_LALR([%define parse.error custom %locations %define api.prefix {calc} %parse-param {semantic_value *result}{int *count}{int *nerrs} %define api.push-pull both %define api.pure full %define parse.lac full])
1317 AT_CHECK_CALC_LALR([%start input exp NUM %define api.value.type union])
1318 AT_CHECK_CALC_LALR([%start input exp NUM %define api.value.type union %locations %define parse.error detailed])
1321 # ---------------- #
1323 # ---------------- #
1325 AT_BANNER([[GLR Calculator.]])
1327 m4_define([AT_CHECK_CALC_GLR],
1328 [AT_CHECK_CALC([%glr-parser] $@)])
1332 AT_CHECK_CALC_GLR([%header])
1333 AT_CHECK_CALC_GLR([%locations])
1334 AT_CHECK_CALC_GLR([%locations %define api.location.type {Span}])
1335 AT_CHECK_CALC_GLR([%name-prefix "calc"])
1336 AT_CHECK_CALC_GLR([%define api.prefix {calc}])
1337 AT_CHECK_CALC_GLR([%verbose])
1338 AT_CHECK_CALC_GLR([%define parse.error verbose])
1340 AT_CHECK_CALC_GLR([%define api.pure %locations])
1341 AT_CHECK_CALC_GLR([%define parse.error verbose %locations])
1343 AT_CHECK_CALC_GLR([%define parse.error custom %locations %header %name-prefix "calc" %verbose])
1344 AT_CHECK_CALC_GLR([%define parse.error detailed %locations %header %name-prefix "calc" %verbose])
1345 AT_CHECK_CALC_GLR([%define parse.error verbose %locations %header %name-prefix "calc" %verbose])
1347 AT_CHECK_CALC_GLR([%debug])
1348 AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %header %name-prefix "calc" %verbose])
1349 AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %header %define api.prefix {calc} %define api.token.prefix {TOK_} %verbose])
1351 AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %header %name-prefix "calc" %verbose])
1353 AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %header %name-prefix "calc" %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1354 AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %header %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1356 AT_CHECK_CALC_GLR([%no-lines %define api.pure %define parse.error verbose %debug %locations %header %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1359 # ---------------------- #
1360 # LALR1 C++ Calculator. #
1361 # ---------------------- #
1363 AT_BANNER([[LALR(1) C++ Calculator.]])
1365 # First let's try using %skeleton
1366 AT_CHECK_CALC([%skeleton "lalr1.cc" %header])
1368 m4_define([AT_CHECK_CALC_LALR1_CC],
1369 [AT_CHECK_CALC([%language "C++" $1], [$2])])
1371 AT_CHECK_CALC_LALR1_CC([])
1372 AT_CHECK_CALC_LALR1_CC([%locations])
1373 AT_CHECK_CALC_LALR1_CC([%locations], [$NO_EXCEPTIONS_CXXFLAGS])
1374 AT_CHECK_CALC_LALR1_CC([%locations %define api.location.type {Span}])
1375 AT_CHECK_CALC_LALR1_CC([%header %locations %define parse.error verbose %name-prefix "calc" %verbose])
1377 AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %define api.prefix {calc} %verbose])
1378 AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %name-prefix "calc" %verbose])
1380 AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define api.prefix {calc} %verbose])
1381 AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define api.prefix {calc} %define api.token.prefix {TOK_} %verbose])
1383 AT_CHECK_CALC_LALR1_CC([%header %locations %define parse.error verbose %debug %name-prefix "calc" %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1385 AT_CHECK_CALC_LALR1_CC([%define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1386 AT_CHECK_CALC_LALR1_CC([%header %locations %define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1388 AT_CHECK_CALC_LALR1_CC([%header %locations %define api.location.file none])
1389 AT_CHECK_CALC_LALR1_CC([%header %locations %define api.location.file "my-location.hh"])
1391 AT_CHECK_CALC_LALR1_CC([%no-lines %header %locations %define api.location.file "my-location.hh"])
1393 AT_CHECK_CALC_LALR1_CC([%locations %define parse.lac full %define parse.error verbose])
1394 AT_CHECK_CALC_LALR1_CC([%locations %define parse.lac full %define parse.error detailed])
1396 AT_CHECK_CALC_LALR1_CC([%define parse.error custom])
1397 AT_CHECK_CALC_LALR1_CC([%define parse.error custom %locations %define api.prefix {calc} %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1398 AT_CHECK_CALC_LALR1_CC([%define parse.error custom %locations %define api.prefix {calc} %parse-param {semantic_value *result}{int *count}{int *nerrs} %define parse.lac full])
1400 # -------------------- #
1401 # GLR C++ Calculator. #
1402 # -------------------- #
1404 AT_BANNER([[GLR C++ Calculator.]])
1406 # Again, we try also using %skeleton.
1407 AT_CHECK_CALC([%skeleton "glr.cc"])
1408 AT_CHECK_CALC([%skeleton "glr2.cc"])
1410 m4_define([AT_CHECK_CALC_GLR_CC],
1411 [AT_CHECK_CALC([%language "C++" %glr-parser] $@) # glr.cc
1412 AT_CHECK_CALC([%skeleton "glr2.cc"] $@)
1415 AT_CHECK_CALC_GLR_CC([])
1416 AT_CHECK_CALC_GLR_CC([%locations])
1417 AT_CHECK_CALC_GLR_CC([%locations %define api.location.type {Span}])
1418 AT_CHECK_CALC_GLR_CC([%header %define parse.error verbose %name-prefix "calc" %verbose])
1419 AT_CHECK_CALC_GLR_CC([%define parse.error verbose %define api.prefix {calc} %verbose])
1421 AT_CHECK_CALC_GLR_CC([%debug])
1423 AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %verbose])
1424 AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %define api.token.prefix {TOK_} %verbose])
1426 AT_CHECK_CALC_GLR_CC([%locations %header %define parse.error verbose %debug %name-prefix "calc" %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1427 AT_CHECK_CALC_GLR_CC([%locations %header %define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1429 AT_CHECK_CALC_GLR_CC([%no-lines %locations %header %define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1432 # -------------------- #
1433 # LALR1 D Calculator. #
1434 # -------------------- #
1436 AT_BANNER([[LALR(1) D Calculator.]])
1438 # First let's try using %skeleton
1439 AT_CHECK_CALC([%skeleton "lalr1.d"])
1441 m4_define([AT_CHECK_CALC_LALR1_D],
1442 [AT_CHECK_CALC([%language "D" $1], [$2])])
1444 AT_CHECK_CALC_LALR1_D([])
1445 AT_CHECK_CALC_LALR1_D([%locations])
1446 #AT_CHECK_CALC_LALR1_D([%locations %define api.location.type {Span}])
1447 AT_CHECK_CALC_LALR1_D([%define parse.error verbose %define api.prefix {calc} %verbose])
1449 AT_CHECK_CALC_LALR1_D([%debug])
1451 AT_CHECK_CALC_LALR1_D([%define parse.error verbose %debug %verbose])
1452 AT_CHECK_CALC_LALR1_D([%define parse.error verbose %debug %define api.token.prefix {TOK_} %verbose])
1453 AT_CHECK_CALC_LALR1_D([%define parse.error verbose %debug %define api.symbol.prefix {SYMB_} %verbose])
1454 AT_CHECK_CALC_LALR1_D([%define parse.error verbose %debug %define api.symbol.prefix {SYMB_} %define api.token.prefix {TOK_} %verbose])
1456 #AT_CHECK_CALC_LALR1_D([%locations %define parse.error verbose %debug %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1457 #AT_CHECK_CALC_LALR1_D([%locations %define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
1460 # ----------------------- #
1461 # LALR1 Java Calculator. #
1462 # ----------------------- #
1464 AT_BANNER([[LALR(1) Java Calculator.]])
1466 m4_define([AT_CHECK_CALC_LALR1_JAVA],
1467 [AT_CHECK_CALC([%language "Java" $1], [$2])])
1469 AT_CHECK_CALC_LALR1_JAVA
1470 AT_CHECK_CALC_LALR1_JAVA([%define parse.error custom])
1471 AT_CHECK_CALC_LALR1_JAVA([%define parse.error detailed])
1472 AT_CHECK_CALC_LALR1_JAVA([%define parse.error verbose])
1473 AT_CHECK_CALC_LALR1_JAVA([%locations %define parse.error custom])
1474 AT_CHECK_CALC_LALR1_JAVA([%locations %define parse.error detailed])
1475 AT_CHECK_CALC_LALR1_JAVA([%locations %define parse.error verbose])
1476 AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error verbose])
1477 AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error verbose %locations %lex-param {InputStream is}])
1479 AT_CHECK_CALC_LALR1_JAVA([%define api.push-pull both])
1480 AT_CHECK_CALC_LALR1_JAVA([%define api.push-pull both %define parse.error detailed %locations])
1481 AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error custom %locations %lex-param {InputStream is} %define api.push-pull both])
1482 AT_CHECK_CALC_LALR1_JAVA([%define parse.trace %define parse.error verbose %locations %lex-param {InputStream is} %define api.push-pull both])
1485 m4_popdef([AT_CALC_MAIN])
1486 m4_popdef([AT_CALC_YYLEX])