mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 01:33:03 +00:00
Merge remote-tracking branch 'origin/maint'
* origin/maint: parser: accept #line NUM m4: use a safer pattern to enable/disable output tests: beware of gnulib's need for config.h gnulib: update yacc.c, glr.c: check and fix the display of locations formatting changes glr.c: remove stray macro Conflicts: data/c.m4 data/glr.cc data/lalr1.cc data/lalr1.java data/location.cc data/stack.hh data/yacc.c src/scan-gram.l
This commit is contained in:
1
THANKS
1
THANKS
@@ -58,6 +58,7 @@ Jim Kent jkent@arch.sel.sony.com
|
|||||||
Jim Meyering jim@meyering.net
|
Jim Meyering jim@meyering.net
|
||||||
Joel E. Denny joeldenny@joeldenny.org
|
Joel E. Denny joeldenny@joeldenny.org
|
||||||
Johan van Selst johans@stack.nl
|
Johan van Selst johans@stack.nl
|
||||||
|
Jonathan Fabrizio jonathan.fabrizio@lrde.epita.fr
|
||||||
Jonathan Nieder jrnieder@gmail.com
|
Jonathan Nieder jrnieder@gmail.com
|
||||||
Juan Manuel Guerrero juan.guerrero@gmx.de
|
Juan Manuel Guerrero juan.guerrero@gmx.de
|
||||||
Kees Zeelenberg kzlg@users.sourceforge.net
|
Kees Zeelenberg kzlg@users.sourceforge.net
|
||||||
|
|||||||
@@ -61,6 +61,30 @@ This special exception was added by the Free Software Foundation in
|
|||||||
version 2.2 of Bison.])])
|
version 2.2 of Bison.])])
|
||||||
|
|
||||||
|
|
||||||
|
## -------- ##
|
||||||
|
## Output. ##
|
||||||
|
## -------- ##
|
||||||
|
|
||||||
|
# b4_output_begin(FILE)
|
||||||
|
# ---------------------
|
||||||
|
# Enable output, i.e., send to diversion 0, expand after "#", and
|
||||||
|
# generate the tag to output into FILE. Must be followed by EOL.
|
||||||
|
m4_define([b4_output_begin],
|
||||||
|
[m4_changecom()
|
||||||
|
m4_divert_push(0)dnl
|
||||||
|
@output(m4_unquote([$1])@)@dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_output_end()
|
||||||
|
# ---------------
|
||||||
|
# Output nothing, restore # as comment character (no expansions after #).
|
||||||
|
m4_define([b4_output_end],
|
||||||
|
[m4_divert_pop(0)
|
||||||
|
m4_changecom([#])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Error handling. ##
|
## Error handling. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|||||||
40
data/c.m4
40
data/c.m4
@@ -610,14 +610,40 @@ m4_define([b4_yy_location_print_define],
|
|||||||
|
|
||||||
#ifndef YY_LOCATION_PRINT
|
#ifndef YY_LOCATION_PRINT
|
||||||
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||||
|
|
||||||
|
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
||||||
|
|
||||||
|
__attribute__((__unused__))
|
||||||
|
]b4_function_define([yy_location_print_],
|
||||||
|
[static unsigned],
|
||||||
|
[[FILE *yyo], [yyo]],
|
||||||
|
[[YYLTYPE const * const yylocp], [yylocp]])[
|
||||||
|
{
|
||||||
|
unsigned res = 0;
|
||||||
|
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
|
||||||
|
if (0 <= yylocp->first_line)
|
||||||
|
{
|
||||||
|
res += fprintf (yyo, "%d", yylocp->first_line);
|
||||||
|
if (0 <= yylocp->first_column)
|
||||||
|
res += fprintf (yyo, ".%d", yylocp->first_column);
|
||||||
|
}
|
||||||
|
if (0 <= yylocp->last_line)
|
||||||
|
{
|
||||||
|
if (yylocp->first_line < yylocp->last_line)
|
||||||
|
{
|
||||||
|
res += fprintf (yyo, "-%d", yylocp->last_line);
|
||||||
|
if (0 <= end_col)
|
||||||
|
res += fprintf (yyo, ".%d", end_col);
|
||||||
|
}
|
||||||
|
else if (0 <= end_col && yylocp->first_column < end_col)
|
||||||
|
res += fprintf (yyo, "-%d", end_col);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
# define YY_LOCATION_PRINT(File, Loc) \
|
# define YY_LOCATION_PRINT(File, Loc) \
|
||||||
do { \
|
yy_location_print_ (File, &(Loc))
|
||||||
fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column); \
|
|
||||||
if ((Loc).first_line < (Loc).last_line) \
|
|
||||||
fprintf (File, "-%d.%d", (Loc).last_line, (Loc).last_column - 1); \
|
|
||||||
else if ((Loc).first_column < (Loc).last_column - 1) \
|
|
||||||
fprintf (File, "-%d", (Loc).last_column - 1); \
|
|
||||||
} while (0)
|
|
||||||
# else
|
# else
|
||||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
28
data/glr.c
28
data/glr.c
@@ -188,13 +188,10 @@ m4_if(b4_skeleton, ["glr.c"],
|
|||||||
## Output files. ##
|
## Output files. ##
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
|
|
||||||
# We do want M4 expansion after # for CPP macros.
|
b4_output_begin([b4_parser_file_name])
|
||||||
m4_changecom()
|
|
||||||
m4_divert_push(0)dnl
|
|
||||||
@output(b4_parser_file_name@)@
|
|
||||||
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
|
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
|
||||||
[2002-2012])
|
[2002-2012])[
|
||||||
[
|
|
||||||
/* C GLR parser skeleton written by Paul Hilfinger. */
|
/* C GLR parser skeleton written by Paul Hilfinger. */
|
||||||
|
|
||||||
]b4_identification
|
]b4_identification
|
||||||
@@ -305,13 +302,6 @@ b4_percent_code_get[]dnl
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]b4_locations_if([#define YYOPTIONAL_LOC(Name) Name],[
|
|
||||||
#ifdef __cplusplus
|
|
||||||
# define YYOPTIONAL_LOC(Name) /* empty */
|
|
||||||
#else
|
|
||||||
# define YYOPTIONAL_LOC(Name) Name __attribute__ ((__unused__))
|
|
||||||
#endif])[
|
|
||||||
|
|
||||||
#ifndef YYASSERT
|
#ifndef YYASSERT
|
||||||
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
|
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
|
||||||
#endif
|
#endif
|
||||||
@@ -2560,17 +2550,17 @@ yypdumpstack (yyGLRStack* yystackp)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
]b4_epilogue[]dnl
|
]b4_epilogue[]dnl
|
||||||
dnl
|
b4_output_end()
|
||||||
dnl glr.cc produces its own header.
|
|
||||||
dnl
|
# glr.cc produces its own header.
|
||||||
m4_if(b4_skeleton, ["glr.c"],
|
m4_if(b4_skeleton, ["glr.c"],
|
||||||
[b4_defines_if(
|
[b4_defines_if(
|
||||||
[@output(b4_spec_defines_file@)@
|
[b4_output_begin([b4_spec_defines_file])
|
||||||
b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
||||||
[2002-2012])[
|
[2002-2012])[
|
||||||
|
|
||||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
]b4_shared_declarations[
|
]b4_shared_declarations[
|
||||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||||
]])])dnl
|
]b4_output_end()
|
||||||
m4_divert_pop(0)
|
])])
|
||||||
|
|||||||
@@ -319,8 +319,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
|||||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
]b4_shared_declarations[
|
]b4_shared_declarations[
|
||||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||||
]m4_divert_pop(0)
|
]b4_output_end()])
|
||||||
m4_changecom[#])])
|
|
||||||
|
|
||||||
# Let glr.c (and b4_shared_declarations) believe that the user
|
# Let glr.c (and b4_shared_declarations) believe that the user
|
||||||
# arguments include the parser itself.
|
# arguments include the parser itself.
|
||||||
|
|||||||
@@ -352,12 +352,11 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
|
|||||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||||
]b4_shared_declarations[
|
]b4_shared_declarations[
|
||||||
]b4_cpp_guard_close([b4_spec_defines_file])
|
]b4_cpp_guard_close([b4_spec_defines_file])
|
||||||
m4_divert_pop(0)dnl
|
b4_output_end()
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
m4_divert_push(0)dnl
|
b4_output_begin([b4_parser_file_name])
|
||||||
@output(b4_parser_file_name@)@
|
|
||||||
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])
|
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])
|
||||||
b4_percent_code_get([[top]])[]dnl
|
b4_percent_code_get([[top]])[]dnl
|
||||||
m4_if(b4_prefix, [yy], [],
|
m4_if(b4_prefix, [yy], [],
|
||||||
@@ -1141,5 +1140,7 @@ b4_error_verbose_if([state_type yystate, int yytoken],
|
|||||||
]b4_token_ctor_if([], [b4_yytranslate_define])[
|
]b4_token_ctor_if([], [b4_yytranslate_define])[
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
]b4_epilogue[]dnl
|
]b4_epilogue[]dnl
|
||||||
m4_divert_pop(0)
|
b4_output_end()
|
||||||
|
|
||||||
|
|
||||||
m4_popdef([b4_copyright_years])dnl
|
m4_popdef([b4_copyright_years])dnl
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ m4_define([b4_symbol_no_destructor_assert],
|
|||||||
[b4_symbol_action_location([$1], [destructor])])])])
|
[b4_symbol_action_location([$1], [destructor])])])])
|
||||||
b4_symbol_foreach([b4_symbol_no_destructor_assert])
|
b4_symbol_foreach([b4_symbol_no_destructor_assert])
|
||||||
|
|
||||||
m4_divert_push(0)dnl
|
b4_output_begin([b4_parser_file_name])
|
||||||
@output(b4_parser_file_name@)@
|
|
||||||
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
||||||
[2007-2012])
|
[2007-2012])
|
||||||
|
|
||||||
@@ -874,4 +873,4 @@ b4_percent_code_get[]dnl
|
|||||||
}
|
}
|
||||||
|
|
||||||
b4_epilogue[]dnl
|
b4_epilogue[]dnl
|
||||||
m4_divert_pop(0)dnl
|
b4_output_end()
|
||||||
|
|||||||
@@ -268,8 +268,7 @@ m4_define([b4_location_define],
|
|||||||
# We do want M4 expansion after # for CPP macros.
|
# We do want M4 expansion after # for CPP macros.
|
||||||
m4_changecom()
|
m4_changecom()
|
||||||
b4_defines_if([
|
b4_defines_if([
|
||||||
m4_divert_push(0)dnl
|
b4_output_begin([b4_dir_prefix[]position.hh])
|
||||||
@output(b4_dir_prefix[]position.hh@)@
|
|
||||||
b4_copyright([Positions for Bison parsers in C++])[
|
b4_copyright([Positions for Bison parsers in C++])[
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -289,7 +288,10 @@ b4_copyright([Positions for Bison parsers in C++])[
|
|||||||
]b4_position_define[
|
]b4_position_define[
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
|
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
|
||||||
@output(b4_dir_prefix[]location.hh@)@
|
b4_output_end()
|
||||||
|
|
||||||
|
|
||||||
|
b4_output_begin([b4_dir_prefix[]location.hh])
|
||||||
b4_copyright([Locations for Bison parsers in C++])[
|
b4_copyright([Locations for Bison parsers in C++])[
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -305,7 +307,8 @@ b4_copyright([Locations for Bison parsers in C++])[
|
|||||||
]b4_location_define[
|
]b4_location_define[
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
|
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
|
||||||
m4_divert_pop(0)
|
b4_output_end()
|
||||||
])# b4_defines_if
|
])
|
||||||
m4_popdef([b4_copyright_years])dnl
|
|
||||||
m4_changecom([#])
|
|
||||||
|
m4_popdef([b4_copyright_years])
|
||||||
|
|||||||
@@ -119,10 +119,7 @@ m4_define([b4_stack_define],
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
b4_defines_if(
|
b4_defines_if(
|
||||||
[# We do want M4 expansion after # for CPP macros.
|
[b4_output_begin([b4_dir_prefix[]stack.hh])
|
||||||
m4_changecom()
|
|
||||||
m4_divert_push(0)dnl
|
|
||||||
@output(b4_dir_prefix[]stack.hh@)@
|
|
||||||
b4_copyright([Stack handling for Bison parsers in C++])[
|
b4_copyright([Stack handling for Bison parsers in C++])[
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -139,7 +136,7 @@ b4_copyright([Stack handling for Bison parsers in C++])[
|
|||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
|
|
||||||
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
|
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
|
||||||
m4_divert_pop(0)
|
b4_output_end()
|
||||||
m4_popdef([b4_copyright_years])dnl
|
|
||||||
m4_changecom([#])
|
|
||||||
])
|
])
|
||||||
|
|
||||||
|
m4_popdef([b4_copyright_years])
|
||||||
|
|||||||
16
data/yacc.c
16
data/yacc.c
@@ -326,10 +326,7 @@ m4_define([b4_shared_declarations],
|
|||||||
## Output files. ##
|
## Output files. ##
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
|
|
||||||
# We do want M4 expansion after # for CPP macros.
|
b4_output_begin([b4_parser_file_name])
|
||||||
m4_changecom()
|
|
||||||
m4_divert_push(0)dnl
|
|
||||||
@output(b4_parser_file_name@)@
|
|
||||||
b4_copyright([Bison implementation for Yacc-like parsers in C])[
|
b4_copyright([Bison implementation for Yacc-like parsers in C])[
|
||||||
|
|
||||||
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
||||||
@@ -1941,11 +1938,12 @@ yypushreturn:]])[
|
|||||||
return yyresult;
|
return yyresult;
|
||||||
}
|
}
|
||||||
]b4_epilogue[]dnl
|
]b4_epilogue[]dnl
|
||||||
|
b4_output_end()
|
||||||
|
|
||||||
b4_defines_if(
|
b4_defines_if(
|
||||||
[@output(b4_spec_defines_file@)@
|
[b4_output_begin([b4_spec_defines_file])[
|
||||||
b4_copyright([Bison interface for Yacc-like parsers in C])[
|
]b4_copyright([Bison interface for Yacc-like parsers in C])[
|
||||||
|
|
||||||
]b4_shared_declarations[
|
]b4_shared_declarations[
|
||||||
]])dnl b4_defines_if
|
]b4_output_end()
|
||||||
m4_divert_pop(0)
|
])# b4_defines_if
|
||||||
m4_popdef([b4_copyright_years])
|
|
||||||
|
|||||||
6
lib/.gitignore
vendored
6
lib/.gitignore
vendored
@@ -273,3 +273,9 @@
|
|||||||
/xstrndup.h
|
/xstrndup.h
|
||||||
/binary-io.c
|
/binary-io.c
|
||||||
/xsize.c
|
/xsize.c
|
||||||
|
/bitrotate.c
|
||||||
|
/math.c
|
||||||
|
/sig-handler.c
|
||||||
|
/stdio.c
|
||||||
|
/unistd.c
|
||||||
|
/wctype-h.c
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int yyerror (char const *);
|
int yyerror (char const *);
|
||||||
|
|||||||
1
m4/.gitignore
vendored
1
m4/.gitignore
vendored
@@ -48,7 +48,6 @@
|
|||||||
/hash.m4
|
/hash.m4
|
||||||
/iconv.m4
|
/iconv.m4
|
||||||
/include_next.m4
|
/include_next.m4
|
||||||
/inline.m4
|
|
||||||
/intdiv0.m4
|
/intdiv0.m4
|
||||||
/intl.m4
|
/intl.m4
|
||||||
/intl.m4~
|
/intl.m4~
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ location_print (FILE *out, location loc)
|
|||||||
quotearg_n_style (3, escape_quoting_style, loc.start.file));
|
quotearg_n_style (3, escape_quoting_style, loc.start.file));
|
||||||
if (0 <= loc.start.line)
|
if (0 <= loc.start.line)
|
||||||
{
|
{
|
||||||
res += fprintf(out, ":%d", loc.start.line);
|
res += fprintf (out, ":%d", loc.start.line);
|
||||||
if (0 <= loc.start.column)
|
if (0 <= loc.start.column)
|
||||||
res += fprintf (out, ".%d", loc.start.column);
|
res += fprintf (out, ".%d", loc.start.column);
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ location_print (FILE *out, location loc)
|
|||||||
loc.end.file));
|
loc.end.file));
|
||||||
if (0 <= loc.end.line)
|
if (0 <= loc.end.line)
|
||||||
{
|
{
|
||||||
res += fprintf(out, ":%d", loc.end.line);
|
res += fprintf (out, ":%d", loc.end.line);
|
||||||
if (0 <= end_col)
|
if (0 <= end_col)
|
||||||
res += fprintf (out, ".%d", end_col);
|
res += fprintf (out, ".%d", end_col);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ eqopt ([[:space:]]*=)?
|
|||||||
|
|
||||||
/* #line directives are not documented, and may be withdrawn or
|
/* #line directives are not documented, and may be withdrawn or
|
||||||
modified in future versions of Bison. */
|
modified in future versions of Bison. */
|
||||||
^"#line "{int}" \"".*"\"\n" {
|
^"#line "{int}(" \"".*"\"")?"\n" {
|
||||||
handle_syncline (yytext + sizeof "#line " - 1, *loc);
|
handle_syncline (yytext + sizeof "#line " - 1, *loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -974,23 +974,27 @@ convert_ucn_to_byte (char const *ucn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------.
|
/*---------------------------------------------------------------------.
|
||||||
| Handle '#line INT "FILE"'. ARGS has already skipped '#line '. |
|
| Handle '#line INT( "FILE")?\n'. ARGS has already skipped '#line '. |
|
||||||
`----------------------------------------------------------------*/
|
`---------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_syncline (char *args, location loc)
|
handle_syncline (char *args, location loc)
|
||||||
{
|
{
|
||||||
char *after_num;
|
char *file;
|
||||||
unsigned long int lineno = strtoul (args, &after_num, 10);
|
unsigned long int lineno = strtoul (args, &file, 10);
|
||||||
char *file = strchr (after_num, '"') + 1;
|
|
||||||
*strchr (file, '"') = '\0';
|
|
||||||
if (INT_MAX <= lineno)
|
if (INT_MAX <= lineno)
|
||||||
{
|
{
|
||||||
complain (&loc, Wother, _("line number overflow"));
|
complain (&loc, Wother, _("line number overflow"));
|
||||||
lineno = INT_MAX;
|
lineno = INT_MAX;
|
||||||
}
|
}
|
||||||
current_file = uniqstr_new (file);
|
|
||||||
|
file = strchr (file, '"');
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
*strchr (file + 1, '"') = '\0';
|
||||||
|
current_file = uniqstr_new (file + 1);
|
||||||
|
}
|
||||||
boundary_set (&scanner_cursor, current_file, lineno, 1);
|
boundary_set (&scanner_cursor, current_file, lineno, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -174,6 +174,81 @@ m4_popdef([AT_TEST])
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Location Print. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
# AT_TEST(SKELETON-NAME, DIRECTIVES, [MORE-DIRECTIVES], [LOCATION = 1.1])
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# Check that the initial location is correct.
|
||||||
|
m4_pushdef([AT_TEST],
|
||||||
|
[AT_SETUP([Location print: $1 $2])
|
||||||
|
|
||||||
|
AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" $2])
|
||||||
|
AT_DATA_GRAMMAR([[input.y]],
|
||||||
|
[[%defines /* FIXME: Required by lalr1.cc in Bison 2.6. */
|
||||||
|
%locations
|
||||||
|
%debug
|
||||||
|
%skeleton "$1"
|
||||||
|
]$2[
|
||||||
|
]$3[
|
||||||
|
%code
|
||||||
|
{
|
||||||
|
# include <stdio.h>
|
||||||
|
# include <stdlib.h> // getenv
|
||||||
|
]AT_YYERROR_DECLARE[
|
||||||
|
]AT_YYLEX_DECLARE[
|
||||||
|
}
|
||||||
|
%%
|
||||||
|
exp:;
|
||||||
|
%%
|
||||||
|
]AT_YYERROR_DEFINE[
|
||||||
|
]AT_YYLEX_DEFINE[
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
#define TEST(L1, C1, L2, C2) \
|
||||||
|
]AT_LOC_FIRST_LINE[ = L1; \
|
||||||
|
]AT_LOC_FIRST_COLUMN[ = C1; \
|
||||||
|
]AT_LOC_LAST_LINE[ = L2; \
|
||||||
|
]AT_LOC_LAST_COLUMN[ = C2; \
|
||||||
|
]YY_LOCATION_PRINT(stdout, AT_LOC)[;\
|
||||||
|
putchar ('\n');
|
||||||
|
|
||||||
|
TEST(1, 1, 1, 1);
|
||||||
|
TEST(2, 1, 2, 10);
|
||||||
|
TEST(3, 1, 4, 1);
|
||||||
|
TEST(5, 1, 6, 10);
|
||||||
|
|
||||||
|
TEST(7, 2, 0, 2);
|
||||||
|
TEST(8, 0, 8, 0);
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
|
||||||
|
AT_FULL_COMPILE([input])
|
||||||
|
AT_PARSER_CHECK([./input], 0,
|
||||||
|
[[1.1
|
||||||
|
2.1-9
|
||||||
|
3.1-4.0
|
||||||
|
5.1-6.9
|
||||||
|
7.2
|
||||||
|
8.0
|
||||||
|
]])
|
||||||
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
AT_CLEANUP
|
||||||
|
])
|
||||||
|
|
||||||
|
## FIXME: test Java, and iterate over skeletons.
|
||||||
|
AT_TEST([yacc.c])
|
||||||
|
AT_TEST([glr.c])
|
||||||
|
#AT_TEST([lalr1.cc])
|
||||||
|
#AT_TEST([glr.cc])
|
||||||
|
|
||||||
|
m4_popdef([AT_TEST])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Exotic Dollars. ##
|
## Exotic Dollars. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|||||||
@@ -114,10 +114,10 @@ main (void)
|
|||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
|
||||||
AT_DATA([[input-cmd-line.y]],
|
AT_DATA_GRAMMAR([[input-cmd-line.y]],
|
||||||
[AT_GRAM])
|
[AT_GRAM])
|
||||||
|
|
||||||
AT_DATA([[input-gram.y]],
|
AT_DATA_GRAMMAR([[input-gram.y]],
|
||||||
[[%skeleton "yacc.c"]
|
[[%skeleton "yacc.c"]
|
||||||
AT_GRAM])
|
AT_GRAM])
|
||||||
|
|
||||||
|
|||||||
@@ -269,6 +269,7 @@ print <<EOF;
|
|||||||
%error-verbose
|
%error-verbose
|
||||||
%debug
|
%debug
|
||||||
%{
|
%{
|
||||||
|
]AT_DATA_SOURCE_PROLOGUE[
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
@@ -383,7 +384,7 @@ m4_define([AT_DATA_STACK_TORTURE],
|
|||||||
[AT_BISON_OPTION_PUSHDEFS([$2])
|
[AT_BISON_OPTION_PUSHDEFS([$2])
|
||||||
# A grammar of parens growing the stack thanks to right recursion.
|
# A grammar of parens growing the stack thanks to right recursion.
|
||||||
# exp:
|
# exp:
|
||||||
AT_DATA([input.y],
|
AT_DATA_GRAMMAR([input.y],
|
||||||
[[%{
|
[[%{
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user