mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 16:53:02 +00:00
tests: factor the declaration/definition of yyerror and yylex.
* tests/local.at (AT_YYERROR_DECLARE, AT_YYERROR_DECLARE_EXTERN) (AT_YYERROR_DEFINE, AT_YYLEX_DECLARE, AT_YYLEX_DECLARE_EXTERN) (AT_YYLEX_DEFINE): New. Must be used inside AT_BISON_OPTION_PUSHDEFS/POPDEFS pair. * tests/actions.at, tests/conflicts.at, tests/glr-regression.at, * tests/headers.at, tests/input.at, tests/named-refs.at, * tests/regression.at, tests/skeletons.at, tests/synclines.at, * tests/torture.at: Use them.
This commit is contained in:
265
tests/actions.at
265
tests/actions.at
@@ -28,14 +28,13 @@ AT_SETUP([Mid-rule actions])
|
|||||||
# instead of being attached to the empty rule dedicated to this
|
# instead of being attached to the empty rule dedicated to this
|
||||||
# action.
|
# action.
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%error-verbose
|
[[%error-verbose
|
||||||
%debug
|
%debug
|
||||||
%{
|
%{
|
||||||
# include <stdio.h>
|
]AT_YYERROR_DECLARE[
|
||||||
# include <stdlib.h>
|
]AT_YYLEX_DECLARE[
|
||||||
static void yyerror (const char *msg);
|
|
||||||
static int yylex (void);
|
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
exp: { putchar ('0'); }
|
exp: { putchar ('0'); }
|
||||||
@@ -51,28 +50,15 @@ exp: { putchar ('0'); }
|
|||||||
{ putchar ('\n'); }
|
{ putchar ('\n'); }
|
||||||
;
|
;
|
||||||
%%
|
%%
|
||||||
static int
|
]AT_YYERROR_DEFINE[
|
||||||
yylex (void)
|
]AT_YYLEX_DEFINE(123456789)[
|
||||||
{
|
|
||||||
static char const input[] = "123456789";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-d -v -o input.c input.y])
|
AT_BISON_CHECK([-d -v -o input.c input.y])
|
||||||
AT_COMPILE([input])
|
AT_COMPILE([input])
|
||||||
@@ -92,14 +78,13 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Exotic Dollars])
|
AT_SETUP([Exotic Dollars])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%error-verbose
|
[[%error-verbose
|
||||||
%debug
|
%debug
|
||||||
%{
|
%{
|
||||||
# include <stdio.h>
|
]AT_YYERROR_DECLARE[
|
||||||
# include <stdlib.h>
|
]AT_YYLEX_DECLARE[
|
||||||
static void yyerror (const char *msg);
|
|
||||||
static int yylex (void);
|
|
||||||
# define USE(Var)
|
# define USE(Var)
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -130,21 +115,8 @@ sum_of_the_five_previous_values:
|
|||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
static int
|
]AT_YYERROR_DEFINE[
|
||||||
yylex (void)
|
]AT_YYLEX_DEFINE([])[
|
||||||
{
|
|
||||||
static int called;
|
|
||||||
if (called++)
|
|
||||||
abort ();
|
|
||||||
return EOF;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -164,9 +136,9 @@ AT_PARSER_CHECK([./input], 0,
|
|||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
static int yylex (void);
|
]AT_YYERROR_DECLARE[
|
||||||
static void yyerror (char const *msg);
|
]AT_YYLEX_DECLARE[
|
||||||
typedef struct { int val; } stype;
|
typedef struct { int val; } stype;
|
||||||
# define YYSTYPE stype
|
# define YYSTYPE stype
|
||||||
%}
|
%}
|
||||||
@@ -185,12 +157,7 @@ yylex (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -204,6 +171,7 @@ AT_PARSER_CHECK([[./input]], [[0]],
|
|||||||
[[6
|
[[6
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
@@ -245,7 +213,7 @@ AT_LALR1_CC_IF([%define global_tokens_and_yystype])
|
|||||||
m4_ifval([$6], [[%code provides {]], [[%code {]])
|
m4_ifval([$6], [[%code provides {]], [[%code {]])
|
||||||
AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])
|
AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])
|
||||||
[static int yylex (]AT_LEX_FORMALS[);
|
[static int yylex (]AT_LEX_FORMALS[);
|
||||||
]AT_LALR1_CC_IF([], [static void yyerror (const char *msg);])
|
]AT_LALR1_CC_IF([], [AT_YYERROR_DECLARE])
|
||||||
[}
|
[}
|
||||||
|
|
||||||
]m4_ifval([$6], [%type <ival> '(' 'x' 'y' ')' ';' thing line input END])[
|
]m4_ifval([$6], [%type <ival> '(' 'x' 'y' ')' ';' thing line input END])[
|
||||||
@@ -593,7 +561,8 @@ Parsing FAILED (status 2).
|
|||||||
]])
|
]])
|
||||||
])
|
])
|
||||||
|
|
||||||
])
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
])# _AT_CHECK_PRINTER_AND_DESTRUCTOR
|
||||||
|
|
||||||
|
|
||||||
# AT_CHECK_PRINTER_AND_DESTRUCTOR([BISON-OPTIONS], [UNION-FLAG], [SKIP_FLAG])
|
# AT_CHECK_PRINTER_AND_DESTRUCTOR([BISON-OPTIONS], [UNION-FLAG], [SKIP_FLAG])
|
||||||
@@ -632,7 +601,7 @@ AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser], [with union])
|
|||||||
# called for $end, and that $$ and @$ work correctly.
|
# called for $end, and that $$ and @$ work correctly.
|
||||||
|
|
||||||
AT_SETUP([Default tagless %printer and %destructor])
|
AT_SETUP([Default tagless %printer and %destructor])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([%locations])
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%error-verbose
|
[[%error-verbose
|
||||||
%debug
|
%debug
|
||||||
@@ -645,8 +614,8 @@ AT_DATA_GRAMMAR([[input.y]],
|
|||||||
%{
|
%{
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (const char *msg);
|
]AT_YYLEX_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYERROR_DECLARE[
|
||||||
# define USE(SYM)
|
# define USE(SYM)
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -677,25 +646,8 @@ AT_DATA_GRAMMAR([[input.y]],
|
|||||||
start: 'a' 'b' 'c' 'd' 'e' { $$ = 'S'; USE(($1, $2, $3, $4, $5)); } ;
|
start: 'a' 'b' 'c' 'd' 'e' { $$ = 'S'; USE(($1, $2, $3, $4, $5)); } ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
]AT_YYLEX_DEFINE([abcd], [[yylval = res]])[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "abcd";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
yylval = input[toknum++];
|
|
||||||
yylloc.first_line = yylloc.last_line = 1;
|
|
||||||
yylloc.first_column = yylloc.last_column = toknum;
|
|
||||||
return yylval;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -741,6 +693,7 @@ Cleanup: discarding lookahead token $end (1.5-1.5: )
|
|||||||
Stack now 0
|
Stack now 0
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
@@ -750,7 +703,7 @@ AT_CLEANUP
|
|||||||
## ------------------------------------------------------ ##
|
## ------------------------------------------------------ ##
|
||||||
|
|
||||||
AT_SETUP([Default tagged and per-type %printer and %destructor])
|
AT_SETUP([Default tagged and per-type %printer and %destructor])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%error-verbose
|
[[%error-verbose
|
||||||
%debug
|
%debug
|
||||||
@@ -758,8 +711,8 @@ AT_DATA_GRAMMAR([[input.y]],
|
|||||||
%{
|
%{
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
# define USE(SYM)
|
# define USE(SYM)
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -805,22 +758,8 @@ start:
|
|||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
]AT_YYLEX_DEFINE([abcdef])[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "abcdef";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -878,6 +817,7 @@ Cleanup: discarding lookahead token $end ()
|
|||||||
Stack now 0
|
Stack now 0
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
@@ -895,6 +835,7 @@ m4_define([_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN],
|
|||||||
[m4_pushdef([kind], []) m4_pushdef([not_kind], [*])],
|
[m4_pushdef([kind], []) m4_pushdef([not_kind], [*])],
|
||||||
[m4_pushdef([kind], [*]) m4_pushdef([not_kind], [])])
|
[m4_pushdef([kind], [*]) m4_pushdef([not_kind], [])])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([%locations])
|
||||||
AT_DATA_GRAMMAR([[input]]$1[[.y]],
|
AT_DATA_GRAMMAR([[input]]$1[[.y]],
|
||||||
[[%error-verbose
|
[[%error-verbose
|
||||||
%debug
|
%debug
|
||||||
@@ -907,8 +848,8 @@ AT_DATA_GRAMMAR([[input]]$1[[.y]],
|
|||||||
%{
|
%{
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
# define USE(SYM)
|
# define USE(SYM)
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -950,12 +891,7 @@ yylex (void)
|
|||||||
yylloc.first_column = yylloc.last_column = 1;
|
yylloc.first_column = yylloc.last_column = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -964,6 +900,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-o input$1.c input$1.y])
|
AT_BISON_CHECK([-o input$1.c input$1.y])
|
||||||
AT_COMPILE([input$1])
|
AT_COMPILE([input$1])
|
||||||
@@ -1010,15 +947,15 @@ AT_SETUP([Default %printer and %destructor are not for error or $undefined])
|
|||||||
# semantic value, which would be initialized from the lookahead, which
|
# semantic value, which would be initialized from the lookahead, which
|
||||||
# would be destroyed separately.
|
# would be destroyed separately.
|
||||||
# - For $undefined, who knows what the semantic value would be.
|
# - For $undefined, who knows what the semantic value would be.
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%debug
|
[[%debug
|
||||||
|
|
||||||
%{
|
%{
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
# define USE(SYM)
|
# define USE(SYM)
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -1039,24 +976,8 @@ start:
|
|||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
]AT_YYLEX_DEFINE([abd], [yylval = res])[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "abd";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
yylval = input[toknum++];
|
|
||||||
return yylval;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -1064,6 +985,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
AT_COMPILE([input])
|
AT_COMPILE([input])
|
||||||
@@ -1125,14 +1047,15 @@ AT_SETUP([Default %printer and %destructor are not for $accept])
|
|||||||
# true for $undefined and the error token, so there are three warnings for
|
# true for $undefined and the error token, so there are three warnings for
|
||||||
# %printer and three for %destructor.)
|
# %printer and three for %destructor.)
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%debug /* So that %printer is actually compiled. */
|
[[%debug /* So that %printer is actually compiled. */
|
||||||
|
|
||||||
%{
|
%{
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
# define USE(SYM)
|
# define USE(SYM)
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -1153,28 +1076,15 @@ AT_DATA_GRAMMAR([[input.y]],
|
|||||||
start: { USE($$); } ;
|
start: { USE($$); } ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
]AT_YYLEX_DEFINE([])[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static int called;
|
|
||||||
if (called++)
|
|
||||||
abort ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
AT_COMPILE([input])
|
AT_COMPILE([input])
|
||||||
@@ -1189,14 +1099,15 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Default %printer and %destructor for mid-rule values])
|
AT_SETUP([Default %printer and %destructor for mid-rule values])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%debug /* So that %printer is actually compiled. */
|
[[%debug /* So that %printer is actually compiled. */
|
||||||
|
|
||||||
%{
|
%{
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
# define USE(SYM)
|
# define USE(SYM)
|
||||||
# define YYLTYPE int
|
# define YYLTYPE int
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) (void)(Rhs)
|
# define YYLLOC_DEFAULT(Current, Rhs, N) (void)(Rhs)
|
||||||
@@ -1220,22 +1131,8 @@ start:
|
|||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
]AT_YYLEX_DEFINE([])[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static int called;
|
|
||||||
if (called++)
|
|
||||||
abort ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -1243,6 +1140,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-o input.c input.y], 0,,
|
AT_BISON_CHECK([-o input.c input.y], 0,,
|
||||||
[[input.y:33.3-23: warning: unset value: $$
|
[[input.y:33.3-23: warning: unset value: $$
|
||||||
@@ -1296,15 +1194,15 @@ AT_CLEANUP
|
|||||||
# Bison once forgot to check for @$ in actions other than semantic actions.
|
# Bison once forgot to check for @$ in actions other than semantic actions.
|
||||||
|
|
||||||
# AT_CHECK_ACTION_LOCATIONS(ACTION-DIRECTIVE)
|
# AT_CHECK_ACTION_LOCATIONS(ACTION-DIRECTIVE)
|
||||||
# -------------------------------------------------------
|
# -------------------------------------------
|
||||||
m4_define([AT_CHECK_ACTION_LOCATIONS],
|
m4_define([AT_CHECK_ACTION_LOCATIONS],
|
||||||
[AT_SETUP([[@$ in ]$1[ implies %locations]])
|
[AT_SETUP([[@$ in ]$1[ implies %locations]])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static int yylex (void);
|
]AT_YYERROR_DECLARE[
|
||||||
static void yyerror (char const *msg);
|
]AT_YYLEX_DECLARE[
|
||||||
}
|
}
|
||||||
|
|
||||||
%debug
|
%debug
|
||||||
@@ -1325,12 +1223,7 @@ yylex (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -1340,7 +1233,7 @@ main (void)
|
|||||||
|
|
||||||
AT_BISON_CHECK([[-o input.c input.y]])
|
AT_BISON_CHECK([[-o input.c input.y]])
|
||||||
AT_COMPILE([[input]])
|
AT_COMPILE([[input]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP])
|
AT_CLEANUP])
|
||||||
|
|
||||||
AT_CHECK_ACTION_LOCATIONS([[%initial-action]])
|
AT_CHECK_ACTION_LOCATIONS([[%initial-action]])
|
||||||
@@ -1357,7 +1250,7 @@ AT_SETUP([[Fix user actions without a trailing semicolon]])
|
|||||||
# This feature is undocumented, but we accidentally broke it in 2.3a,
|
# This feature is undocumented, but we accidentally broke it in 2.3a,
|
||||||
# and there was a complaint at:
|
# and there was a complaint at:
|
||||||
# <http://lists.gnu.org/archive/html/bug-bison/2008-11/msg00001.html>.
|
# <http://lists.gnu.org/archive/html/bug-bison/2008-11/msg00001.html>.
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA([input.y],
|
AT_DATA([input.y],
|
||||||
[[%%
|
[[%%
|
||||||
start: test2 test1 test0 testc;
|
start: test2 test1 test0 testc;
|
||||||
@@ -1407,6 +1300,7 @@ no_semi
|
|||||||
[]"broken\" $ @ $$ @$ [];\
|
[]"broken\" $ @ $$ @$ [];\
|
||||||
string;"}
|
string;"}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o input.c input.y]], [0], [],
|
AT_BISON_CHECK([[-o input.c input.y]], [0], [],
|
||||||
[[input.y:8.48: warning: a ';' might be needed at the end of action code
|
[[input.y:8.48: warning: a ';' might be needed at the end of action code
|
||||||
@@ -1462,13 +1356,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([[Destroying lookahead assigned by semantic action]])
|
AT_SETUP([[Destroying lookahead assigned by semantic action]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[
|
[[
|
||||||
%code {
|
%code {
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
#define USE(Var)
|
#define USE(Var)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1496,27 +1391,15 @@ accept: /*empty*/ {
|
|||||||
} ;
|
} ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void
|
]AT_YYLEX_DEFINE([a])[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const *input = "a";
|
|
||||||
return *input++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_BISON_CHECK([[-o input.c input.y]])
|
AT_BISON_CHECK([[-o input.c input.y]])
|
||||||
AT_COMPILE([[input]])
|
AT_COMPILE([[input]])
|
||||||
AT_PARSER_CHECK([[./input]], [[0]], [],
|
AT_PARSER_CHECK([[./input]], [[0]], [],
|
||||||
@@ -1532,6 +1415,8 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([[YYBACKUP]])
|
AT_SETUP([[YYBACKUP]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([%pure-parser])
|
||||||
|
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[
|
[[
|
||||||
%error-verbose
|
%error-verbose
|
||||||
@@ -1542,7 +1427,7 @@ AT_DATA_GRAMMAR([input.y],
|
|||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
|
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (YYSTYPE *yylval);
|
static int yylex (YYSTYPE *yylval);
|
||||||
}
|
}
|
||||||
%%
|
%%
|
||||||
@@ -1557,6 +1442,7 @@ exp:
|
|||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
static int
|
||||||
yylex (YYSTYPE *yylval)
|
yylex (YYSTYPE *yylval)
|
||||||
{
|
{
|
||||||
@@ -1567,12 +1453,6 @@ yylex (YYSTYPE *yylval)
|
|||||||
return input[toknum++];
|
return input[toknum++];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -1580,6 +1460,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o input.c input.y]])
|
AT_BISON_CHECK([[-o input.c input.y]])
|
||||||
AT_COMPILE([[input]])
|
AT_COMPILE([[input]])
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([%nonassoc and eof])
|
AT_SETUP([%nonassoc and eof])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
@@ -58,12 +59,7 @@ AT_DATA_GRAMMAR([input.y],
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define YYERROR_VERBOSE 1
|
#define YYERROR_VERBOSE 1
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The current argument. */
|
/* The current argument. */
|
||||||
static const char *input;
|
static const char *input;
|
||||||
|
|
||||||
@@ -93,6 +89,7 @@ main (int argc, const char *argv[])
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
m4_pushdef([AT_NONASSOC_AND_EOF_CHECK],
|
m4_pushdef([AT_NONASSOC_AND_EOF_CHECK],
|
||||||
[AT_BISON_CHECK([$1[ -o input.c input.y]])
|
[AT_BISON_CHECK([$1[ -o input.c input.y]])
|
||||||
@@ -171,7 +168,7 @@ AT_SKEL_JAVA_IF([AT_DATA], [AT_DATA_GRAMMAR])([input.y],
|
|||||||
#include <string>]], [[
|
#include <string>]], [[
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *msg);]])[
|
]AT_YYERROR_DECLARE])[
|
||||||
]AT_YYLEX_PROTOTYPE[;
|
]AT_YYLEX_PROTOTYPE[;
|
||||||
#define USE(Var)
|
#define USE(Var)
|
||||||
}
|
}
|
||||||
@@ -212,31 +209,11 @@ public Object getLVal ()
|
|||||||
*lvalp = 1;
|
*lvalp = 1;
|
||||||
return *input++;
|
return *input++;
|
||||||
}]])[
|
}]])[
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
/*----------.
|
]AT_SKEL_JAVA_IF([[
|
||||||
| yyerror. |
|
|
||||||
`----------*/]AT_SKEL_JAVA_IF([[
|
|
||||||
|
|
||||||
public void yyerror (String msg)
|
|
||||||
{
|
|
||||||
System.err.println (msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
%%]], [AT_SKEL_CC_IF([[
|
%%]])[
|
||||||
|
|
||||||
void
|
|
||||||
yy::parser::error (const yy::location &, std::string const &msg)
|
|
||||||
{
|
|
||||||
std::cerr << msg << std::endl;
|
|
||||||
}]], [[
|
|
||||||
|
|
||||||
void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}]])])[
|
|
||||||
|
|
||||||
/*-------.
|
/*-------.
|
||||||
| main. |
|
| main. |
|
||||||
@@ -471,12 +448,12 @@ AT_CLEANUP
|
|||||||
# with minimal LR parser tables.
|
# with minimal LR parser tables.
|
||||||
|
|
||||||
AT_SETUP([[LAC: %nonassoc requires splitting canonical LR states]])
|
AT_SETUP([[LAC: %nonassoc requires splitting canonical LR states]])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
}
|
}
|
||||||
|
|
||||||
%error-verbose
|
%error-verbose
|
||||||
@@ -513,19 +490,8 @@ look:
|
|||||||
reduce-nonassoc: %prec 'a';
|
reduce-nonassoc: %prec 'a';
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
void
|
]AT_YYLEX_DEFINE([aaa])[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
char const *input = "aaa";
|
|
||||||
return *input++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -533,6 +499,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
# Show canonical LR's failure.
|
# Show canonical LR's failure.
|
||||||
AT_BISON_CHECK([[-Dlr.type=canonical-lr -o input.c input.y]],
|
AT_BISON_CHECK([[-Dlr.type=canonical-lr -o input.c input.y]],
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ AT_BANNER([[GLR Regression Tests]])
|
|||||||
|
|
||||||
AT_SETUP([Badly Collapsed GLR States])
|
AT_SETUP([Badly Collapsed GLR States])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr1.y],
|
AT_DATA_GRAMMAR([glr-regr1.y],
|
||||||
[[/* Regression Test: Improper state compression */
|
[[/* Regression Test: Improper state compression */
|
||||||
/* Reported by Scott McPeak */
|
/* Reported by Scott McPeak */
|
||||||
@@ -34,8 +35,8 @@ AT_DATA_GRAMMAR([glr-regr1.y],
|
|||||||
|
|
||||||
#define YYSTYPE int
|
#define YYSTYPE int
|
||||||
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
|
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
@@ -71,12 +72,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
@@ -94,6 +90,7 @@ yylex (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr1.c glr-regr1.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr1.c glr-regr1.y]], 0, [],
|
||||||
[glr-regr1.y: conflicts: 1 shift/reduce
|
[glr-regr1.y: conflicts: 1 shift/reduce
|
||||||
@@ -119,6 +116,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Improper handling of embedded actions and dollar(-N) in GLR parsers])
|
AT_SETUP([Improper handling of embedded actions and dollar(-N) in GLR parsers])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr2a.y],
|
AT_DATA_GRAMMAR([glr-regr2a.y],
|
||||||
[[/* Regression Test: Improper handling of embedded actions and $-N */
|
[[/* Regression Test: Improper handling of embedded actions and $-N */
|
||||||
/* Reported by S. Eken */
|
/* Reported by S. Eken */
|
||||||
@@ -130,8 +128,8 @@ AT_DATA_GRAMMAR([glr-regr2a.y],
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -171,7 +169,7 @@ var_printer: 'v'
|
|||||||
{ printf ("Variable: '%s'\n", $-1); }
|
{ printf ("Variable: '%s'\n", $-1); }
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
FILE *input;
|
FILE *input;
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -181,7 +179,8 @@ yylex (void)
|
|||||||
char *s;
|
char *s;
|
||||||
if (feof (stdin))
|
if (feof (stdin))
|
||||||
abort ();
|
abort ();
|
||||||
switch (fscanf (input, " %1[a-z,]", buf)) {
|
switch (fscanf (input, " %1[a-z,]", buf))
|
||||||
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return buf[0];
|
return buf[0];
|
||||||
case EOF:
|
case EOF:
|
||||||
@@ -199,11 +198,6 @@ yylex (void)
|
|||||||
return 'V';
|
return 'V';
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
yyerror (char const *s)
|
|
||||||
{ printf ("%s\n", s);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -212,6 +206,7 @@ main (int argc, char **argv)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr2a.c glr-regr2a.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr2a.c glr-regr2a.y]], 0, [],
|
||||||
[glr-regr2a.y: conflicts: 2 shift/reduce
|
[glr-regr2a.y: conflicts: 2 shift/reduce
|
||||||
@@ -238,6 +233,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Improper merging of GLR delayed action sets])
|
AT_SETUP([Improper merging of GLR delayed action sets])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr3.y],
|
AT_DATA_GRAMMAR([glr-regr3.y],
|
||||||
[[/* Regression Test: Improper merging of GLR delayed action sets. */
|
[[/* Regression Test: Improper merging of GLR delayed action sets. */
|
||||||
/* Reported by M. Rosien */
|
/* Reported by M. Rosien */
|
||||||
@@ -248,8 +244,8 @@ AT_DATA_GRAMMAR([glr-regr3.y],
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
static int MergeRule (int x0, int x1);
|
static int MergeRule (int x0, int x1);
|
||||||
static void yyerror (char const * s);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
|
|
||||||
#define RULE(x) (1 << (x))
|
#define RULE(x) (1 << (x))
|
||||||
|
|
||||||
@@ -290,13 +286,12 @@ NT6 : P1 NT1 O1 T3 P2 { $$ = RULE(11) | $2; } %merge<MergeRule>
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static int MergeRule (int x0, int x1) {
|
static int
|
||||||
|
MergeRule (int x0, int x1)
|
||||||
|
{
|
||||||
return x0 | x1;
|
return x0 | x1;
|
||||||
}
|
}
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void yyerror(char const * s) {
|
|
||||||
fprintf(stderr,"error: %s\n",s);
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE *input = YY_NULL;
|
FILE *input = YY_NULL;
|
||||||
|
|
||||||
@@ -320,12 +315,15 @@ int yylex (void)
|
|||||||
return BAD_CHAR;
|
return BAD_CHAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int
|
||||||
|
main(int argc, char* argv[])
|
||||||
|
{
|
||||||
input = stdin;
|
input = stdin;
|
||||||
if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
|
if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr3.c glr-regr3.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr3.c glr-regr3.y]], 0, [],
|
||||||
[glr-regr3.y: conflicts: 1 shift/reduce, 1 reduce/reduce
|
[glr-regr3.y: conflicts: 1 shift/reduce, 1 reduce/reduce
|
||||||
@@ -347,6 +345,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Duplicate representation of merged trees])
|
AT_SETUP([Duplicate representation of merged trees])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr4.y],
|
AT_DATA_GRAMMAR([glr-regr4.y],
|
||||||
[[
|
[[
|
||||||
%union { char *ptr; }
|
%union { char *ptr; }
|
||||||
@@ -359,8 +358,8 @@ AT_DATA_GRAMMAR([glr-regr4.y],
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
static char *merge (YYSTYPE, YYSTYPE);
|
static char *merge (YYSTYPE, YYSTYPE);
|
||||||
static char *make_value (char const *, char const *);
|
static char *make_value (char const *, char const *);
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static char *ptrs[100];
|
static char *ptrs[100];
|
||||||
static char **ptrs_next = ptrs;
|
static char **ptrs_next = ptrs;
|
||||||
%}
|
%}
|
||||||
@@ -384,16 +383,8 @@ A2: 'a' { $$ = make_value ("A2", "'a'"); } ;
|
|||||||
B: 'a' { $$ = make_value ("B", "'a'"); } ;
|
B: 'a' { $$ = make_value ("B", "'a'"); } ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static int
|
]AT_YYLEX_DEFINE([a])[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "a";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -423,13 +414,8 @@ merge (YYSTYPE s1, YYSTYPE s2)
|
|||||||
sprintf (value, format, s1.ptr, s2.ptr);
|
sprintf (value, format, s1.ptr, s2.ptr);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr4.c glr-regr4.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr4.c glr-regr4.y]], 0, [],
|
||||||
[glr-regr4.y: conflicts: 1 reduce/reduce
|
[glr-regr4.y: conflicts: 1 reduce/reduce
|
||||||
@@ -450,13 +436,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([User destructor for unresolved GLR semantic value])
|
AT_SETUP([User destructor for unresolved GLR semantic value])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr5.y],
|
AT_DATA_GRAMMAR([glr-regr5.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
enum { MAGIC_VALUE = -1057808125 }; /* originally chosen at random */
|
enum { MAGIC_VALUE = -1057808125 }; /* originally chosen at random */
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -480,29 +467,15 @@ start:
|
|||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYLEX_DEFINE(a)[
|
||||||
static int
|
]AT_YYERROR_DEFINE[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "a";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse () != 1;
|
return yyparse () != 1;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr5.c glr-regr5.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr5.c glr-regr5.y]], 0, [],
|
||||||
[glr-regr5.y: conflicts: 1 reduce/reduce
|
[glr-regr5.y: conflicts: 1 reduce/reduce
|
||||||
@@ -523,13 +496,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([User destructor after an error during a split parse])
|
AT_SETUP([User destructor after an error during a split parse])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr6.y],
|
AT_DATA_GRAMMAR([glr-regr6.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -556,18 +530,14 @@ yylex (void)
|
|||||||
return input[toknum++];
|
return input[toknum++];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse () != 1;
|
return yyparse () != 1;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr6.c glr-regr6.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr6.c glr-regr6.y]], 0, [],
|
||||||
[glr-regr6.y: conflicts: 1 reduce/reduce
|
[glr-regr6.y: conflicts: 1 reduce/reduce
|
||||||
@@ -590,13 +560,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Duplicated user destructor for lookahead])
|
AT_SETUP([Duplicated user destructor for lookahead])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr7.y],
|
AT_DATA_GRAMMAR([glr-regr7.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
#define YYSTACKEXPANDABLE 0
|
#define YYSTACKEXPANDABLE 0
|
||||||
typedef struct count_node {
|
typedef struct count_node {
|
||||||
int count;
|
int count;
|
||||||
@@ -641,12 +612,7 @@ yylex (void)
|
|||||||
return 'a';
|
return 'a';
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -660,6 +626,7 @@ main (void)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr7.c glr-regr7.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr7.c glr-regr7.y]], 0, [],
|
||||||
[glr-regr7.y: conflicts: 2 reduce/reduce
|
[glr-regr7.y: conflicts: 2 reduce/reduce
|
||||||
@@ -682,14 +649,15 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Incorrectly initialized location for empty right-hand side in GLR])
|
AT_SETUP([Incorrectly initialized location for empty right-hand side in GLR])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr8.y],
|
AT_DATA_GRAMMAR([glr-regr8.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%token T_CONSTANT
|
%token T_CONSTANT
|
||||||
@@ -723,12 +691,7 @@ OptSignalWord : /* empty */
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int lexIndex;
|
static int lexIndex;
|
||||||
|
|
||||||
int yylex (void)
|
int yylex (void)
|
||||||
@@ -758,6 +721,7 @@ main (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr8.c glr-regr8.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr8.c glr-regr8.y]], 0, [],
|
||||||
[glr-regr8.y: conflicts: 1 reduce/reduce
|
[glr-regr8.y: conflicts: 1 reduce/reduce
|
||||||
@@ -780,13 +744,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([No users destructors if stack 0 deleted])
|
AT_SETUP([No users destructors if stack 0 deleted])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr9.y],
|
AT_DATA_GRAMMAR([glr-regr9.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
# define YYSTACKEXPANDABLE 0
|
# define YYSTACKEXPANDABLE 0
|
||||||
static int tokens = 0;
|
static int tokens = 0;
|
||||||
static int destructors = 0;
|
static int destructors = 0;
|
||||||
@@ -822,12 +787,7 @@ yylex (void)
|
|||||||
return 'a';
|
return 'a';
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -841,6 +801,7 @@ main (void)
|
|||||||
return !exit_status;
|
return !exit_status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr9.c glr-regr9.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr9.c glr-regr9.y]], 0, [],
|
||||||
[glr-regr9.y: conflicts: 1 reduce/reduce
|
[glr-regr9.y: conflicts: 1 reduce/reduce
|
||||||
@@ -860,13 +821,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Corrupted semantic options if user action cuts parse])
|
AT_SETUP([Corrupted semantic options if user action cuts parse])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr10.y],
|
AT_DATA_GRAMMAR([glr-regr10.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
#define GARBAGE_SIZE 50
|
#define GARBAGE_SIZE 50
|
||||||
static char garbage[GARBAGE_SIZE];
|
static char garbage[GARBAGE_SIZE];
|
||||||
%}
|
%}
|
||||||
@@ -884,12 +846,7 @@ start:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -908,6 +865,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr10.c glr-regr10.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr10.c glr-regr10.y]], 0, [],
|
||||||
[glr-regr10.y: conflicts: 1 reduce/reduce
|
[glr-regr10.y: conflicts: 1 reduce/reduce
|
||||||
@@ -925,12 +883,13 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Undesirable destructors if user action cuts parse])
|
AT_SETUP([Undesirable destructors if user action cuts parse])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr11.y],
|
AT_DATA_GRAMMAR([glr-regr11.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static int destructors = 0;
|
static int destructors = 0;
|
||||||
# define USE(val)
|
# define USE(val)
|
||||||
%}
|
%}
|
||||||
@@ -949,21 +908,8 @@ start:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
]AT_YYLEX_DEFINE([a])[
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "a";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
@@ -977,6 +923,7 @@ main (void)
|
|||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr11.c glr-regr11.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr11.c glr-regr11.y]], 0, [],
|
||||||
[glr-regr11.y: conflicts: 1 reduce/reduce
|
[glr-regr11.y: conflicts: 1 reduce/reduce
|
||||||
@@ -994,6 +941,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Leaked semantic values if user action cuts parse])
|
AT_SETUP([Leaked semantic values if user action cuts parse])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr12.y],
|
AT_DATA_GRAMMAR([glr-regr12.y],
|
||||||
[[
|
[[
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -1007,8 +955,8 @@ AT_DATA_GRAMMAR([glr-regr12.y],
|
|||||||
%{
|
%{
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static int merge (YYSTYPE, YYSTYPE);
|
static int merge (YYSTYPE, YYSTYPE);
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static int parent_rhs_before_value = 0;
|
static int parent_rhs_before_value = 0;
|
||||||
static int merged_value = 0;
|
static int merged_value = 0;
|
||||||
static int parent_rhs_after_value = 0;
|
static int parent_rhs_after_value = 0;
|
||||||
@@ -1068,12 +1016,7 @@ merge (YYSTYPE s1, YYSTYPE s2)
|
|||||||
return dummy;
|
return dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -1108,6 +1051,7 @@ main (void)
|
|||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr12.c glr-regr12.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr12.c glr-regr12.y]], 0, [],
|
||||||
[glr-regr12.y: conflicts: 1 shift/reduce, 1 reduce/reduce
|
[glr-regr12.y: conflicts: 1 shift/reduce, 1 reduce/reduce
|
||||||
@@ -1127,6 +1071,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Incorrect lookahead during deterministic GLR])
|
AT_SETUP([Incorrect lookahead during deterministic GLR])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr13.y],
|
AT_DATA_GRAMMAR([glr-regr13.y],
|
||||||
[[
|
[[
|
||||||
/* Tests:
|
/* Tests:
|
||||||
@@ -1138,8 +1083,8 @@ AT_DATA_GRAMMAR([glr-regr13.y],
|
|||||||
|
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static void print_lookahead (char const *);
|
static void print_lookahead (char const *);
|
||||||
#define USE(value)
|
#define USE(value)
|
||||||
%}
|
%}
|
||||||
@@ -1190,12 +1135,7 @@ change_lookahead:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -1237,6 +1177,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr13.c glr-regr13.y]], 0, [], [])
|
AT_BISON_CHECK([[-o glr-regr13.c glr-regr13.y]], 0, [], [])
|
||||||
AT_COMPILE([glr-regr13])
|
AT_COMPILE([glr-regr13])
|
||||||
@@ -1263,6 +1204,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Incorrect lookahead during nondeterministic GLR])
|
AT_SETUP([Incorrect lookahead during nondeterministic GLR])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr14.y],
|
AT_DATA_GRAMMAR([glr-regr14.y],
|
||||||
[[
|
[[
|
||||||
/* Tests:
|
/* Tests:
|
||||||
@@ -1289,8 +1231,8 @@ AT_DATA_GRAMMAR([glr-regr14.y],
|
|||||||
%{
|
%{
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static void print_lookahead (char const *);
|
static void print_lookahead (char const *);
|
||||||
static char merge (union YYSTYPE, union YYSTYPE);
|
static char merge (union YYSTYPE, union YYSTYPE);
|
||||||
#define USE(value)
|
#define USE(value)
|
||||||
@@ -1399,12 +1341,7 @@ no_look:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -1453,6 +1390,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr14.c glr-regr14.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr14.c glr-regr14.y]], 0, [],
|
||||||
[glr-regr14.y: conflicts: 3 reduce/reduce
|
[glr-regr14.y: conflicts: 3 reduce/reduce
|
||||||
@@ -1483,6 +1421,7 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Leaked semantic values when reporting ambiguity])
|
AT_SETUP([Leaked semantic values when reporting ambiguity])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr15.y],
|
AT_DATA_GRAMMAR([glr-regr15.y],
|
||||||
[[
|
[[
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -1490,8 +1429,8 @@ AT_DATA_GRAMMAR([glr-regr15.y],
|
|||||||
|
|
||||||
%{
|
%{
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static int parent_rhs_before_value = 0;
|
static int parent_rhs_before_value = 0;
|
||||||
# define USE(val)
|
# define USE(val)
|
||||||
%}
|
%}
|
||||||
@@ -1530,12 +1469,7 @@ ambiguity2: ;
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -1557,6 +1491,7 @@ main (void)
|
|||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr15.c glr-regr15.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr15.c glr-regr15.y]], 0, [],
|
||||||
[glr-regr15.y: conflicts: 2 reduce/reduce
|
[glr-regr15.y: conflicts: 2 reduce/reduce
|
||||||
@@ -1575,6 +1510,8 @@ AT_CLEANUP
|
|||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Leaked lookahead after nondeterministic parse syntax error])
|
AT_SETUP([Leaked lookahead after nondeterministic parse syntax error])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr16.y],
|
AT_DATA_GRAMMAR([glr-regr16.y],
|
||||||
[[
|
[[
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -1582,8 +1519,8 @@ AT_DATA_GRAMMAR([glr-regr16.y],
|
|||||||
|
|
||||||
%{
|
%{
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static int lookahead_value = 0;
|
static int lookahead_value = 0;
|
||||||
# define USE(val)
|
# define USE(val)
|
||||||
%}
|
%}
|
||||||
@@ -1596,12 +1533,7 @@ alt2: ;
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -1626,6 +1558,7 @@ main (void)
|
|||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr16.c glr-regr16.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr16.c glr-regr16.y]], 0, [],
|
||||||
[glr-regr16.y: conflicts: 1 reduce/reduce
|
[glr-regr16.y: conflicts: 1 reduce/reduce
|
||||||
@@ -1644,6 +1577,8 @@ AT_CLEANUP
|
|||||||
## ------------------------------------------------------------------------- ##
|
## ------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Uninitialized location when reporting ambiguity])
|
AT_SETUP([Uninitialized location when reporting ambiguity])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr17.y],
|
AT_DATA_GRAMMAR([glr-regr17.y],
|
||||||
[[
|
[[
|
||||||
%glr-parser
|
%glr-parser
|
||||||
@@ -1713,6 +1648,7 @@ main (void)
|
|||||||
return yyparse () != 1;
|
return yyparse () != 1;
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [],
|
AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [],
|
||||||
[glr-regr17.y: conflicts: 3 reduce/reduce
|
[glr-regr17.y: conflicts: 3 reduce/reduce
|
||||||
@@ -1731,12 +1667,14 @@ AT_CLEANUP
|
|||||||
## -------------------------------------------------------------##
|
## -------------------------------------------------------------##
|
||||||
|
|
||||||
AT_SETUP([Missed %merge type warnings when LHS type is declared later])
|
AT_SETUP([Missed %merge type warnings when LHS type is declared later])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([glr-regr18.y],
|
AT_DATA_GRAMMAR([glr-regr18.y],
|
||||||
[[%glr-parser
|
[[%glr-parser
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex ();
|
static int yylex ();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -1758,27 +1696,15 @@ sym3: %merge<merge> { $$ = 0; } ;
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
]AT_YYLEX_DEFINE()[
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
yylex ()
|
|
||||||
{
|
|
||||||
static int called;
|
|
||||||
if (called++)
|
|
||||||
abort ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [],
|
AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [],
|
||||||
[glr-regr18.y:26.18-24: result type clash on merge function 'merge': <type2> != <type1>
|
[glr-regr18.y:26.18-24: result type clash on merge function 'merge': <type2> != <type1>
|
||||||
@@ -1796,13 +1722,14 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Ambiguity reports])
|
AT_SETUP([Ambiguity reports])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%debug
|
%debug
|
||||||
@@ -1816,23 +1743,8 @@ start:
|
|||||||
b: 'b';
|
b: 'b';
|
||||||
d: /* nada. */;
|
d: /* nada. */;
|
||||||
%%
|
%%
|
||||||
|
]AT_YYLEX_DEFINE([abc])[
|
||||||
static int
|
]AT_YYERROR_DEFINE[
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const input[] = "abc";
|
|
||||||
static size_t toknum;
|
|
||||||
if (! (toknum < sizeof input))
|
|
||||||
abort ();
|
|
||||||
return input[toknum++];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -1840,6 +1752,7 @@ main (void)
|
|||||||
return !!yyparse ();
|
return !!yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o input.c input.y]], 0, [],
|
AT_BISON_CHECK([[-o input.c input.y]], 0, [],
|
||||||
[input.y: conflicts: 1 reduce/reduce
|
[input.y: conflicts: 1 reduce/reduce
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ AT_BISON_CHECK([--defines input.y])
|
|||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
## Invalid CPP headers. ##
|
## Invalid CPP headers. ##
|
||||||
## --------------------- ##
|
## --------------------- ##
|
||||||
@@ -51,7 +50,7 @@ AT_CLEANUP
|
|||||||
# FIXME: Much of this can be covered by calc.at.
|
# FIXME: Much of this can be covered by calc.at.
|
||||||
m4_define([AT_TEST_CPP_GUARD_H],
|
m4_define([AT_TEST_CPP_GUARD_H],
|
||||||
[AT_SETUP([Invalid CPP guards: $2 --defines=$1.h])
|
[AT_SETUP([Invalid CPP guards: $2 --defines=$1.h])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([$2])
|
||||||
# Possibly create inner directories.
|
# Possibly create inner directories.
|
||||||
dirname=`AS_DIRNAME([$1])`
|
dirname=`AS_DIRNAME([$1])`
|
||||||
AS_MKDIR_P([$dirname])
|
AS_MKDIR_P([$dirname])
|
||||||
@@ -60,8 +59,8 @@ AT_DATA_GRAMMAR([$1.y],
|
|||||||
[$2
|
[$2
|
||||||
%{
|
%{
|
||||||
#include <$1.h>
|
#include <$1.h>
|
||||||
void yyerror (const char *);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
dummy:;
|
dummy:;
|
||||||
@@ -73,6 +72,7 @@ AT_BISON_CHECK([--defines=$1.h --output=$1.c $1.y])
|
|||||||
|
|
||||||
AT_COMPILE([$1.o], [-I. -c $1.c])
|
AT_COMPILE([$1.o], [-I. -c $1.c])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
@@ -468,8 +468,8 @@ char quote[] = "@:>@@:>@,";
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
%{
|
%{
|
||||||
static void yyerror (const char *s);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%type <ival> '@<:@'
|
%type <ival> '@<:@'
|
||||||
@@ -621,14 +621,15 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Symbols])
|
AT_SETUP([Symbols])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%token WITH-DASH
|
[[%token WITH-DASH
|
||||||
%token WITHOUT_DASH "WITHOUT-DASH"
|
%token WITHOUT_DASH "WITHOUT-DASH"
|
||||||
%token WITH.PERIOD
|
%token WITH.PERIOD
|
||||||
%token WITHOUT_PERIOD "WITHOUT.PERIOD"
|
%token WITHOUT_PERIOD "WITHOUT.PERIOD"
|
||||||
%code {
|
%code {
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
}
|
}
|
||||||
%%
|
%%
|
||||||
start: with-dash without_dash with.period without_period;
|
start: with-dash without_dash with.period without_period;
|
||||||
@@ -637,7 +638,10 @@ without_dash: "WITHOUT-DASH";
|
|||||||
with.period: WITH.PERIOD;
|
with.period: WITH.PERIOD;
|
||||||
without_period: "WITHOUT.PERIOD";
|
without_period: "WITHOUT.PERIOD";
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
|
]AT_YYLEX_DEFINE[
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
# POSIX Yacc accept periods, but not dashes.
|
# POSIX Yacc accept periods, but not dashes.
|
||||||
AT_BISON_CHECK([--yacc input.y], [1], [],
|
AT_BISON_CHECK([--yacc input.y], [1], [],
|
||||||
|
|||||||
@@ -267,6 +267,73 @@ m4_define([AT_DATA_GRAMMAR],
|
|||||||
$2])
|
$2])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# AT_YYLEX_DECLARE_EXTERN
|
||||||
|
# AT_YYLEX_DECLARE
|
||||||
|
# AT_YYLEX_DEFINE(INPUT-STRING, [ACTION])
|
||||||
|
# ---------------------------------------
|
||||||
|
m4_define([AT_YYLEX_DECLARE_EXTERN],
|
||||||
|
[int yylex (void);dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
m4_define([AT_YYLEX_DECLARE],
|
||||||
|
[static AT_YYLEX_DECLARE_EXTERN[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
m4_define([AT_YYLEX_DEFINE],
|
||||||
|
[[#include <stdlib.h> /* abort */
|
||||||
|
static int
|
||||||
|
yylex (void)
|
||||||
|
{
|
||||||
|
static char const input[] = "$1";
|
||||||
|
static size_t toknum = 0;
|
||||||
|
int res;
|
||||||
|
if (! (toknum < sizeof input))
|
||||||
|
abort ();
|
||||||
|
res = input[toknum++];
|
||||||
|
]$2;[]AT_LOCATION_IF([[
|
||||||
|
yylloc.first_line = yylloc.last_line = 1;
|
||||||
|
yylloc.first_column = yylloc.last_column = toknum;]])[
|
||||||
|
return res;
|
||||||
|
}]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# AT_YYERROR_DECLARE_EXTERN
|
||||||
|
# AT_YYERROR_DECLARE
|
||||||
|
# AT_YYERROR_DEFINE
|
||||||
|
# -------------------------
|
||||||
|
# Beware that must be called inside a AT_BISON_OPTION_PUSHDEFS/POPDEFS
|
||||||
|
# pair.
|
||||||
|
m4_define([AT_YYERROR_DECLARE_EXTERN],
|
||||||
|
[void yyerror (const char *msg);dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
m4_define([AT_YYERROR_DECLARE],
|
||||||
|
[static AT_YYERROR_DECLARE_EXTERN[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
m4_define([AT_YYERROR_DEFINE],
|
||||||
|
[AT_SKEL_JAVA_IF([[
|
||||||
|
public void yyerror (String msg)
|
||||||
|
{
|
||||||
|
System.err.println (msg);
|
||||||
|
}]], [AT_SKEL_CC_IF([[
|
||||||
|
void
|
||||||
|
yy::parser::error (const yy::location &, std::string const &msg)
|
||||||
|
{
|
||||||
|
std::cerr << msg << std::endl;
|
||||||
|
}]], [[
|
||||||
|
#include <stdio.h>
|
||||||
|
static void
|
||||||
|
yyerror (char const *msg)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s\n", msg);
|
||||||
|
}]])])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
## --------------- ##
|
||||||
|
## Running Bison. ##
|
||||||
|
## --------------- ##
|
||||||
|
|
||||||
# AT_BISON_CHECK(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
# AT_BISON_CHECK(BISON_ARGS, [OTHER_AT_CHECK_ARGS])
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# Check Bison by invoking `bison BISON_ARGS'. BISON_ARGS should not contain
|
# Check Bison by invoking `bison BISON_ARGS'. BISON_ARGS should not contain
|
||||||
@@ -588,12 +655,12 @@ m4_define([AT_TEST_TABLES_AND_PARSE],
|
|||||||
[m4_pushdef([AT_COND_CASE], [m4_case([$2], $][@)])
|
[m4_pushdef([AT_COND_CASE], [m4_case([$2], $][@)])
|
||||||
|
|
||||||
AT_SETUP([$1])
|
AT_SETUP([$1])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([$4])
|
||||||
AT_DATA_GRAMMAR([[input.y]],
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
}
|
}
|
||||||
|
|
||||||
]$4[
|
]$4[
|
||||||
@@ -603,13 +670,7 @@ AT_DATA_GRAMMAR([[input.y]],
|
|||||||
]$5[
|
]$5[
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -665,6 +726,7 @@ AT_PARSER_CHECK([[./input]],
|
|||||||
m4_ifval([$11], [m4_dquote($11)]),
|
m4_ifval([$11], [m4_dquote($11)]),
|
||||||
m4_ifval([$12], [m4_dquote($12)]))
|
m4_ifval([$12], [m4_dquote($12)]))
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
m4_popdef([AT_COND_CASE])])
|
m4_popdef([AT_COND_CASE])])
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
AT_BANNER([[Named references tests.]])
|
AT_BANNER([[Named references tests.]])
|
||||||
|
|
||||||
AT_SETUP([Tutorial calculator])
|
AT_SETUP([Tutorial calculator])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([test.y],
|
AT_DATA_GRAMMAR([test.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
@@ -33,8 +33,8 @@ FILE *input;
|
|||||||
static semantic_value global_result = 0;
|
static semantic_value global_result = 0;
|
||||||
static int global_count = 0;
|
static int global_count = 0;
|
||||||
static int power (int base, int exponent);
|
static int power (int base, int exponent);
|
||||||
static void yyerror (const char *s);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union
|
%union
|
||||||
@@ -83,12 +83,7 @@ exp:
|
|||||||
| '-' error { $$ = 0; YYERROR; }
|
| '-' error { $$ = 0; YYERROR; }
|
||||||
;
|
;
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
static void yyerror (const char *s)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_char (void)
|
static int get_char (void)
|
||||||
{
|
{
|
||||||
int res = getc (input);
|
int res = getc (input);
|
||||||
@@ -119,7 +114,8 @@ static int read_signed_integer (void)
|
|||||||
return sign * n;
|
return sign * n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int yylex (void)
|
static int
|
||||||
|
yylex (void)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
/* Skip white space. */
|
/* Skip white space. */
|
||||||
@@ -190,6 +186,7 @@ AT_DATA([input.txt],
|
|||||||
AT_BISON_CHECK([-o test.c test.y])
|
AT_BISON_CHECK([-o test.c test.y])
|
||||||
AT_COMPILE([[test]])
|
AT_COMPILE([[test]])
|
||||||
AT_PARSER_CHECK([./test input.txt], 0, [], [stderr])
|
AT_PARSER_CHECK([./test input.txt], 0, [], [stderr])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
@@ -198,13 +195,13 @@ AT_CLEANUP
|
|||||||
|
|
||||||
|
|
||||||
AT_SETUP([Undefined and ambiguous references])
|
AT_SETUP([Undefined and ambiguous references])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([test.y],
|
AT_DATA_GRAMMAR([test.y],
|
||||||
[[
|
[[
|
||||||
%{
|
%{
|
||||||
static int power (int base, int exponent);
|
static int power (int base, int exponent);
|
||||||
static void yyerror (const char *s);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union
|
%union
|
||||||
@@ -268,6 +265,7 @@ test.y:55.3-53: symbol not found in production: r12
|
|||||||
test.y:56.29-33: invalid reference: '$expo'
|
test.y:56.29-33: invalid reference: '$expo'
|
||||||
test.y:56.3-46: symbol not found in production: expo
|
test.y:56.3-46: symbol not found in production: expo
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ AT_SETUP([Trivial grammars])
|
|||||||
|
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
#define YYSTYPE int *
|
#define YYSTYPE int *
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -54,8 +54,8 @@ AT_SETUP([YYSTYPE typedef])
|
|||||||
|
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
typedef union { char const *val; } YYSTYPE;
|
typedef union { char const *val; } YYSTYPE;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -85,8 +85,8 @@ AT_SETUP([Early token definitions with --yacc])
|
|||||||
|
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union
|
%union
|
||||||
@@ -124,8 +124,8 @@ AT_SETUP([Early token definitions without --yacc])
|
|||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
void print_my_token (void);
|
void print_my_token (void);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -433,8 +433,8 @@ AT_DATA_GRAMMAR([input.y],
|
|||||||
[%{
|
[%{
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
[%error-verbose
|
[%error-verbose
|
||||||
%token MYEOF 0 "end of file"
|
%token MYEOF 0 "end of file"
|
||||||
@@ -498,19 +498,21 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Characters Escapes])
|
AT_SETUP([Characters Escapes])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[%{
|
[%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
[%%
|
[%%
|
||||||
exp:
|
exp:
|
||||||
'\'' "\'"
|
'\'' "\'"
|
||||||
| '\"' "\""
|
| '\"' "\""
|
||||||
| '"' "'"
|
| '"' "'" /* Pacify font-lock-mode: ". */
|
||||||
;
|
;
|
||||||
]])
|
]])
|
||||||
# Pacify font-lock-mode: "
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
AT_COMPILE([input.o], [-c input.c])
|
AT_COMPILE([input.o], [-c input.c])
|
||||||
@@ -837,7 +839,7 @@ static int yylex (AT_LALR1_CC_IF([int *], [void]));
|
|||||||
AT_LALR1_CC_IF([],
|
AT_LALR1_CC_IF([],
|
||||||
[#include <stdlib.h>
|
[#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static void yyerror (const char *);])
|
]AT_YYERROR_DECLARE[])
|
||||||
%}
|
%}
|
||||||
$1
|
$1
|
||||||
%token ARROW INVALID NUMBER STRING DATA
|
%token ARROW INVALID NUMBER STRING DATA
|
||||||
@@ -965,7 +967,7 @@ static int yylex (AT_LALR1_CC_IF([int *], [void]));
|
|||||||
AT_LALR1_CC_IF([],
|
AT_LALR1_CC_IF([],
|
||||||
[#include <stdio.h>
|
[#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
static void yyerror (const char *);])
|
]AT_YYERROR_DECLARE[])
|
||||||
%}
|
%}
|
||||||
$1
|
$1
|
||||||
%defines
|
%defines
|
||||||
@@ -1056,12 +1058,12 @@ AT_SETUP([Braced code in declaration in rules section])
|
|||||||
|
|
||||||
# Bison once mistook braced code in a declaration in the rules section to be a
|
# Bison once mistook braced code in a declaration in the rules section to be a
|
||||||
# rule action.
|
# rule action.
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
static void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%error-verbose
|
%error-verbose
|
||||||
@@ -1080,12 +1082,7 @@ start:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -1099,6 +1096,7 @@ main (void)
|
|||||||
return !yyparse ();
|
return !yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([-t -o input.c input.y])
|
AT_BISON_CHECK([-t -o input.c input.y])
|
||||||
AT_COMPILE([input])
|
AT_COMPILE([input])
|
||||||
@@ -1196,12 +1194,12 @@ AT_SETUP([[Token number in precedence declaration]])
|
|||||||
|
|
||||||
# POSIX says token numbers can be declared in %left, %right, and %nonassoc, but
|
# POSIX says token numbers can be declared in %left, %right, and %nonassoc, but
|
||||||
# we lost this in Bison 1.50.
|
# we lost this in Bison 1.50.
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%error-verbose
|
%error-verbose
|
||||||
@@ -1221,12 +1219,7 @@ sr_conflict:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -1241,6 +1234,7 @@ main (void)
|
|||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
|
AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
|
||||||
[[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start
|
[[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start
|
||||||
@@ -1283,11 +1277,12 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([[%error-verbose and YYSTACK_USE_ALLOCA]])
|
AT_SETUP([[%error-verbose and YYSTACK_USE_ALLOCA]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
#define YYSTACK_USE_ALLOCA 1
|
#define YYSTACK_USE_ALLOCA 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1323,28 +1318,18 @@ syntax_error:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
/* Induce two syntax error messages (which requires full error
|
||||||
{
|
recovery by shifting 3 tokens) in order to detect any loss of the
|
||||||
fprintf (stderr, "%s\n", msg);
|
reallocated buffer. */
|
||||||
}
|
]AT_YYLEX_DEFINE([abc])[
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
/* Induce two syntax error messages (which requires full error
|
|
||||||
recovery by shifting 3 tokens) in order to detect any loss of the
|
|
||||||
reallocated buffer. */
|
|
||||||
static char const *input = "abc";
|
|
||||||
return *input++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse ();
|
return yyparse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|
||||||
AT_BISON_CHECK([[-o input.c input.y]])
|
AT_BISON_CHECK([[-o input.c input.y]])
|
||||||
AT_COMPILE([[input]])
|
AT_COMPILE([[input]])
|
||||||
@@ -1370,12 +1355,12 @@ AT_CLEANUP
|
|||||||
# yyparse would invoke yyerror using the old contents of yymsg.
|
# yyparse would invoke yyerror using the old contents of yymsg.
|
||||||
|
|
||||||
AT_SETUP([[%error-verbose overflow]])
|
AT_SETUP([[%error-verbose overflow]])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
|
|
||||||
/* This prevents this test case from having to induce error messages
|
/* This prevents this test case from having to induce error messages
|
||||||
large enough to overflow size_t. */
|
large enough to overflow size_t. */
|
||||||
@@ -1441,21 +1426,10 @@ syntax_error2:
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
/* Induce two syntax error messages (which requires full error
|
||||||
{
|
recovery by shifting 3 tokens). */
|
||||||
fprintf (stderr, "%s\n", msg);
|
]AT_YYLEX_DEFINE([abc])[
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
/* Induce two syntax error messages (which requires full error
|
|
||||||
recovery by shifting 3 tokens). */
|
|
||||||
static char const *input = "abc";
|
|
||||||
return *input++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -1481,7 +1455,7 @@ AT_PARSER_CHECK([[./input]], [[2]], [],
|
|||||||
syntax error
|
syntax error
|
||||||
memory exhausted
|
memory exhausted
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
@@ -1499,7 +1473,7 @@ AT_BISON_OPTION_PUSHDEFS([$1])
|
|||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (]AT_PURE_IF([[YYSTYPE *]], [[void]])[);
|
int yylex (]AT_PURE_IF([[YYSTYPE *]], [[void]])[);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1520,13 +1494,7 @@ B: 'b' ;
|
|||||||
C: /*empty*/ { printf ("consistent default reduction\n"); } ;
|
C: /*empty*/ { printf ("consistent default reduction\n"); } ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
void
|
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
yylex (]AT_PURE_IF([[YYSTYPE *v]], [[void]])[)
|
yylex (]AT_PURE_IF([[YYSTYPE *v]], [[void]])[)
|
||||||
{
|
{
|
||||||
@@ -1592,13 +1560,13 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([[LAC: Memory exhaustion]])
|
AT_SETUP([[LAC: Memory exhaustion]])
|
||||||
|
|
||||||
m4_pushdef([AT_LAC_CHECK], [
|
m4_pushdef([AT_LAC_CHECK],
|
||||||
|
[AT_BISON_OPTION_PUSHDEFS
|
||||||
AT_DATA_GRAMMAR([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%code {
|
[[%code {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
#define YYMAXDEPTH 8
|
#define YYMAXDEPTH 8
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1610,20 +1578,8 @@ S: A A A A A A A A A ;
|
|||||||
A: /*empty*/ | 'a' ;
|
A: /*empty*/ | 'a' ;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
void
|
]AT_YYLEX_DEFINE([$1])[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
yylex (void)
|
|
||||||
{
|
|
||||||
static char const *input = "]$1[";
|
|
||||||
return *input++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@@ -1637,12 +1593,12 @@ AT_BISON_CHECK([[-Dparse.lac=full -Dparse.lac.es-capacity-initial=1 \
|
|||||||
[[input.y: conflicts: 8 shift/reduce
|
[[input.y: conflicts: 8 shift/reduce
|
||||||
]])
|
]])
|
||||||
AT_COMPILE([[input]])
|
AT_COMPILE([[input]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
])
|
])
|
||||||
|
|
||||||
# Check for memory exhaustion during parsing.
|
# Check for memory exhaustion during parsing.
|
||||||
AT_LAC_CHECK([[]])
|
AT_LAC_CHECK([])
|
||||||
AT_PARSER_CHECK([[./input]], [[2]], [[]],
|
AT_PARSER_CHECK([[./input]], [[2]], [],
|
||||||
[[Starting parse
|
[[Starting parse
|
||||||
Entering state 0
|
Entering state 0
|
||||||
Reading a token: Now at end of input.
|
Reading a token: Now at end of input.
|
||||||
@@ -1655,8 +1611,8 @@ Stack now 0
|
|||||||
|
|
||||||
# Induce an immediate syntax error with an undefined token, and check
|
# Induce an immediate syntax error with an undefined token, and check
|
||||||
# for memory exhaustion while building syntax error message.
|
# for memory exhaustion while building syntax error message.
|
||||||
AT_LAC_CHECK([[z]], [[0]])
|
AT_LAC_CHECK([z], [[0]])
|
||||||
AT_PARSER_CHECK([[./input]], [[2]], [[]],
|
AT_PARSER_CHECK([[./input]], [[2]], [],
|
||||||
[[Starting parse
|
[[Starting parse
|
||||||
Entering state 0
|
Entering state 0
|
||||||
Reading a token: Next token is token $undefined ()
|
Reading a token: Next token is token $undefined ()
|
||||||
|
|||||||
@@ -83,10 +83,11 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([[Installed skeleton file names]])
|
AT_SETUP([[Installed skeleton file names]])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
m4_pushdef([AT_GRAM],
|
m4_pushdef([AT_GRAM],
|
||||||
[[%{
|
[[%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void yyerror (char const *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
int yylex (void);
|
int yylex (void);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -99,12 +100,7 @@ start: ;
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (char const *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -139,6 +135,7 @@ AT_PARSER_CHECK([[./input-gram]], [[1]], [],
|
|||||||
|
|
||||||
m4_popdef([AT_GRAM])
|
m4_popdef([AT_GRAM])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ AT_CHECK([[sed -e '/^distcc\[[0-9]*\] /d' \
|
|||||||
# to issue ERROR-MSG.
|
# to issue ERROR-MSG.
|
||||||
m4_define([AT_TEST_SYNCLINE],
|
m4_define([AT_TEST_SYNCLINE],
|
||||||
[AT_SETUP([$1])
|
[AT_SETUP([$1])
|
||||||
|
AT_BISON_OPTION_PUSHDEFS
|
||||||
# It seems impossible to find a generic scheme to check the location
|
# It seems impossible to find a generic scheme to check the location
|
||||||
# of an error. Even requiring GCC is not sufficient, since for instance
|
# of an error. Even requiring GCC is not sufficient, since for instance
|
||||||
# the version modified by Apple:
|
# the version modified by Apple:
|
||||||
@@ -98,6 +98,7 @@ AT_DATA([[input.y]], [$2])
|
|||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
AT_SYNCLINES_COMPILE([input.c])
|
AT_SYNCLINES_COMPILE([input.c])
|
||||||
AT_CHECK([cat stdout], 0, [$3])
|
AT_CHECK([cat stdout], 0, [$3])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -110,11 +111,12 @@ AT_CLEANUP
|
|||||||
AT_TEST_SYNCLINE([Prologue synch line],
|
AT_TEST_SYNCLINE([Prologue synch line],
|
||||||
[[%{
|
[[%{
|
||||||
#error "2"
|
#error "2"
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
exp: '0';
|
exp: '0';
|
||||||
|
%%
|
||||||
]],
|
]],
|
||||||
[input.y:2: #error "2"
|
[input.y:2: #error "2"
|
||||||
])
|
])
|
||||||
@@ -130,11 +132,12 @@ AT_TEST_SYNCLINE([%union synch line],
|
|||||||
char dummy;
|
char dummy;
|
||||||
}
|
}
|
||||||
%{
|
%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
exp: '0';
|
exp: '0';
|
||||||
|
%%
|
||||||
]],
|
]],
|
||||||
[input.y:2: #error "2"
|
[input.y:2: #error "2"
|
||||||
])
|
])
|
||||||
@@ -146,8 +149,8 @@ exp: '0';
|
|||||||
|
|
||||||
AT_TEST_SYNCLINE([Postprologue synch line],
|
AT_TEST_SYNCLINE([Postprologue synch line],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
@@ -158,6 +161,7 @@ int yylex (void);
|
|||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
exp: '0';
|
exp: '0';
|
||||||
|
%%
|
||||||
]],
|
]],
|
||||||
[input.y:10: #error "10"
|
[input.y:10: #error "10"
|
||||||
])
|
])
|
||||||
@@ -169,8 +173,8 @@ exp: '0';
|
|||||||
|
|
||||||
AT_TEST_SYNCLINE([Action synch line],
|
AT_TEST_SYNCLINE([Action synch line],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
exp:
|
exp:
|
||||||
@@ -188,8 +192,8 @@ exp:
|
|||||||
|
|
||||||
AT_TEST_SYNCLINE([Epilogue synch line],
|
AT_TEST_SYNCLINE([Epilogue synch line],
|
||||||
[[%{
|
[[%{
|
||||||
void yyerror (const char *s);
|
]AT_YYERROR_DECLARE_EXTERN[
|
||||||
int yylex (void);
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
exp: '0';
|
exp: '0';
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ print <<EOF;
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
@@ -171,8 +171,8 @@ print <<EOF;
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%token
|
%token
|
||||||
@@ -278,8 +278,8 @@ print <<EOF;
|
|||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
|
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
@@ -390,7 +390,8 @@ AT_CLEANUP
|
|||||||
# ------------------------------------------------
|
# ------------------------------------------------
|
||||||
# A parser specialized in torturing the stack size.
|
# A parser specialized in torturing the stack size.
|
||||||
m4_define([AT_DATA_STACK_TORTURE],
|
m4_define([AT_DATA_STACK_TORTURE],
|
||||||
[# A grammar of parens growing the stack thanks to right recursion.
|
[AT_BISON_OPTION_PUSHDEFS([$2])
|
||||||
|
# A grammar of parens growing the stack thanks to right recursion.
|
||||||
# exp:
|
# exp:
|
||||||
AT_DATA([input.y],
|
AT_DATA([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
@@ -399,8 +400,8 @@ AT_DATA([input.y],
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
]$1[
|
]$1[
|
||||||
static int yylex (void);
|
]AT_YYLEX_DECLARE[
|
||||||
static void yyerror (const char *msg);
|
]AT_YYERROR_DECLARE[
|
||||||
%}
|
%}
|
||||||
]$2[
|
]$2[
|
||||||
%error-verbose
|
%error-verbose
|
||||||
@@ -409,12 +410,7 @@ AT_DATA([input.y],
|
|||||||
%%
|
%%
|
||||||
exp: WAIT_FOR_EOF exp | ;
|
exp: WAIT_FOR_EOF exp | ;
|
||||||
%%
|
%%
|
||||||
static void
|
]AT_YYERROR_DEFINE[
|
||||||
yyerror (const char *msg)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
yylex (void)
|
||||||
{
|
{
|
||||||
@@ -462,6 +458,7 @@ main (int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS([$2])
|
||||||
AT_BISON_CHECK([-o input.c input.y])
|
AT_BISON_CHECK([-o input.c input.y])
|
||||||
AT_COMPILE([input])
|
AT_COMPILE([input])
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user