mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +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:
@@ -61,6 +61,30 @@ This special exception was added by the Free Software Foundation in
|
||||
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. ##
|
||||
## ---------------- ##
|
||||
|
||||
40
data/c.m4
40
data/c.m4
@@ -610,14 +610,40 @@ m4_define([b4_yy_location_print_define],
|
||||
|
||||
#ifndef YY_LOCATION_PRINT
|
||||
# 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) \
|
||||
do { \
|
||||
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)
|
||||
yy_location_print_ (File, &(Loc))
|
||||
|
||||
# else
|
||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||
# endif
|
||||
|
||||
28
data/glr.c
28
data/glr.c
@@ -188,13 +188,10 @@ m4_if(b4_skeleton, ["glr.c"],
|
||||
## Output files. ##
|
||||
## -------------- ##
|
||||
|
||||
# We do want M4 expansion after # for CPP macros.
|
||||
m4_changecom()
|
||||
m4_divert_push(0)dnl
|
||||
@output(b4_parser_file_name@)@
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
|
||||
[2002-2012])
|
||||
[
|
||||
[2002-2012])[
|
||||
|
||||
/* C GLR parser skeleton written by Paul Hilfinger. */
|
||||
|
||||
]b4_identification
|
||||
@@ -305,13 +302,6 @@ b4_percent_code_get[]dnl
|
||||
# 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
|
||||
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
|
||||
#endif
|
||||
@@ -2560,17 +2550,17 @@ yypdumpstack (yyGLRStack* yystackp)
|
||||
}
|
||||
#endif
|
||||
]b4_epilogue[]dnl
|
||||
dnl
|
||||
dnl glr.cc produces its own header.
|
||||
dnl
|
||||
b4_output_end()
|
||||
|
||||
# glr.cc produces its own header.
|
||||
m4_if(b4_skeleton, ["glr.c"],
|
||||
[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],
|
||||
[2002-2012])[
|
||||
|
||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
]b4_shared_declarations[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||
]])])dnl
|
||||
m4_divert_pop(0)
|
||||
]b4_output_end()
|
||||
])])
|
||||
|
||||
@@ -319,8 +319,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
]b4_shared_declarations[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||
]m4_divert_pop(0)
|
||||
m4_changecom[#])])
|
||||
]b4_output_end()])
|
||||
|
||||
# Let glr.c (and b4_shared_declarations) believe that the user
|
||||
# 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_shared_declarations[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])
|
||||
m4_divert_pop(0)dnl
|
||||
b4_output_end()
|
||||
])
|
||||
|
||||
|
||||
m4_divert_push(0)dnl
|
||||
@output(b4_parser_file_name@)@
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])
|
||||
b4_percent_code_get([[top]])[]dnl
|
||||
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_namespace_close[
|
||||
]b4_epilogue[]dnl
|
||||
m4_divert_pop(0)
|
||||
b4_output_end()
|
||||
|
||||
|
||||
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_foreach([b4_symbol_no_destructor_assert])
|
||||
|
||||
m4_divert_push(0)dnl
|
||||
@output(b4_parser_file_name@)@
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
||||
[2007-2012])
|
||||
|
||||
@@ -874,4 +873,4 @@ b4_percent_code_get[]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.
|
||||
m4_changecom()
|
||||
b4_defines_if([
|
||||
m4_divert_push(0)dnl
|
||||
@output(b4_dir_prefix[]position.hh@)@
|
||||
b4_output_begin([b4_dir_prefix[]position.hh])
|
||||
b4_copyright([Positions for Bison parsers in C++])[
|
||||
|
||||
/**
|
||||
@@ -289,7 +288,10 @@ b4_copyright([Positions for Bison parsers in C++])[
|
||||
]b4_position_define[
|
||||
]b4_namespace_close[
|
||||
]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++])[
|
||||
|
||||
/**
|
||||
@@ -305,7 +307,8 @@ b4_copyright([Locations for Bison parsers in C++])[
|
||||
]b4_location_define[
|
||||
]b4_namespace_close[
|
||||
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
|
||||
m4_divert_pop(0)
|
||||
])# b4_defines_if
|
||||
m4_popdef([b4_copyright_years])dnl
|
||||
m4_changecom([#])
|
||||
b4_output_end()
|
||||
])
|
||||
|
||||
|
||||
m4_popdef([b4_copyright_years])
|
||||
|
||||
@@ -119,10 +119,7 @@ m4_define([b4_stack_define],
|
||||
]])
|
||||
|
||||
b4_defines_if(
|
||||
[# We do want M4 expansion after # for CPP macros.
|
||||
m4_changecom()
|
||||
m4_divert_push(0)dnl
|
||||
@output(b4_dir_prefix[]stack.hh@)@
|
||||
[b4_output_begin([b4_dir_prefix[]stack.hh])
|
||||
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_cpp_guard_close([b4_dir_prefix[]stack.hh])
|
||||
m4_divert_pop(0)
|
||||
m4_popdef([b4_copyright_years])dnl
|
||||
m4_changecom([#])
|
||||
b4_output_end()
|
||||
])
|
||||
|
||||
m4_popdef([b4_copyright_years])
|
||||
|
||||
16
data/yacc.c
16
data/yacc.c
@@ -326,10 +326,7 @@ m4_define([b4_shared_declarations],
|
||||
## Output files. ##
|
||||
## -------------- ##
|
||||
|
||||
# We do want M4 expansion after # for CPP macros.
|
||||
m4_changecom()
|
||||
m4_divert_push(0)dnl
|
||||
@output(b4_parser_file_name@)@
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Bison implementation for Yacc-like parsers in C])[
|
||||
|
||||
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
||||
@@ -1941,11 +1938,12 @@ yypushreturn:]])[
|
||||
return yyresult;
|
||||
}
|
||||
]b4_epilogue[]dnl
|
||||
b4_output_end()
|
||||
|
||||
b4_defines_if(
|
||||
[@output(b4_spec_defines_file@)@
|
||||
b4_copyright([Bison interface for Yacc-like parsers in C])[
|
||||
[b4_output_begin([b4_spec_defines_file])[
|
||||
]b4_copyright([Bison interface for Yacc-like parsers in C])[
|
||||
|
||||
]b4_shared_declarations[
|
||||
]])dnl b4_defines_if
|
||||
m4_divert_pop(0)
|
||||
m4_popdef([b4_copyright_years])
|
||||
]b4_output_end()
|
||||
])# b4_defines_if
|
||||
|
||||
Reference in New Issue
Block a user