YYLLOC_DEFAULT: factor, and don't export it in headers.

* data/c++.m4, data/c.m4 (b4_yylloc_default_define): New.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: Use it.
* data/glr.cc: Do not define YYLLOC_DEFAULT in the header file,
but in the implementation one.
This commit is contained in:
Akim Demaille
2012-07-04 11:41:06 +02:00
parent 9104636b03
commit 426903aa75
6 changed files with 69 additions and 88 deletions

View File

@@ -90,11 +90,13 @@ m4_define([b4_yy_symbol_print_generate],
]])
# Declare yyerror.
# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT
# and declaration of yyerror.
m4_append([b4_post_prologue],
[b4_syncline([@oline@], [@ofile@])
b4_c_ansi_function_decl([yyerror],
[b4_syncline([@oline@], [@ofile@])[
]b4_yylloc_default_define[
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
]b4_c_ansi_function_decl([yyerror],
[static void],
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
[yylocationp]],
@@ -241,25 +243,6 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
]b4_YYDEBUG_define[
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */
# ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
(Current).end = YYRHSLOC (Rhs, N).end; \
} \
else \
{ \
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
} \
while (/*CONSTCOND*/ 0)
# endif
]b4_namespace_open[
/// A Bison parser.
class ]b4_parser_class_name[