mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* data/c.m4 (b4_dirname): New.
(b4_syncline): Also output the location of its invocation (from the skeleton). (b4_user_action, b4_define_user_action, b4_user_actions) (b4_user_initial_action, b4_user_post_prologue, b4_user_start_header) (b4_user_stype): New. * data/yacc.c, data/glr.c, data/lalr1.cc, data/glr.cc: Use them.
This commit is contained in:
42
data/c.m4
42
data/c.m4
@@ -403,12 +403,52 @@ m4_define([b4_c_arg],
|
||||
## Synclines. ##
|
||||
## ----------- ##
|
||||
|
||||
# b4_basename(NAME)
|
||||
# -----------------
|
||||
# Beware that NAME is not evaluated.
|
||||
m4_define([b4_basename],
|
||||
[m4_case([$1],
|
||||
[/], [/],
|
||||
[m4_bpatsubst([$1], [^.*/\([^/]+\)/?$], [\1])])])
|
||||
|
||||
|
||||
# b4_syncline(LINE, FILE)
|
||||
# -----------------------
|
||||
m4_define([b4_syncline],
|
||||
[b4_flag_if([synclines], [[#]line $1 $2])])
|
||||
[b4_flag_if([synclines],
|
||||
[/* Line __line__ of b4_basename(m4_quote(__file__)). */
|
||||
[#]line $1 $2])])
|
||||
|
||||
|
||||
# b4_user_code(USER-CODE)
|
||||
# -----------------------
|
||||
# Emit code from the user, ending it with synclines.
|
||||
m4_define([b4_user_code],
|
||||
[$1
|
||||
b4_syncline([@oline@], [@ofile@])])
|
||||
|
||||
|
||||
# b4_define_user_code(MACRO)
|
||||
# --------------------------
|
||||
# From b4_MACRO, build b4_user_MACRO that includes the synclines.
|
||||
m4_define([b4_define_user_code],
|
||||
[m4_define([b4_user_$1],
|
||||
[b4_user_code([b4_$1])])])
|
||||
|
||||
|
||||
# b4_user_actions
|
||||
# b4_user_initial_action
|
||||
# b4_user_post_prologue
|
||||
# b4_user_start_header
|
||||
# b4_user_stype
|
||||
# ----------------------
|
||||
# Macros that issue user code, ending with synclines.
|
||||
b4_define_user_code([actions])
|
||||
b4_define_user_code([initial_action])
|
||||
b4_define_user_code([post_prologue])
|
||||
b4_define_user_code([start_header])
|
||||
b4_define_user_code([stype])
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## User actions. ##
|
||||
|
||||
19
data/glr.c
19
data/glr.c
@@ -178,9 +178,7 @@ b4_token_enums(b4_tokens)
|
||||
[#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
]m4_ifdef([b4_stype],
|
||||
[typedef union b4_union_name
|
||||
b4_stype
|
||||
/* Line __line__ of glr.c. */
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_user_stype
|
||||
YYSTYPE;],
|
||||
[typedef int YYSTYPE;])[
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
@@ -237,11 +235,8 @@ b4_defines_if([#include @output_header_name@],
|
||||
static YYSTYPE yyval_default;
|
||||
|
||||
/* Copy the second part of user declarations. */
|
||||
]b4_post_prologue[
|
||||
]b4_user_post_prologue[
|
||||
|
||||
]/* Line __line__ of glr.c. */
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
[
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -934,9 +929,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
|
||||
]])[
|
||||
switch (yyn)
|
||||
{
|
||||
]b4_actions
|
||||
/* Line __line__ of glr.c. */
|
||||
b4_syncline([@oline@], [@ofile@])[
|
||||
]b4_user_actions[
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -2318,11 +2311,9 @@ m4_ifdef([b4_initial_action], [
|
||||
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
||||
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
||||
/* User initialization code. */
|
||||
b4_initial_action
|
||||
b4_user_initial_action
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
m4_popdef([b4_at_dollar])dnl
|
||||
/* Line __line__ of glr.c. */
|
||||
b4_syncline([@oline@], [@ofile@])])dnl
|
||||
m4_popdef([b4_at_dollar])])dnl
|
||||
[
|
||||
if (! yyinitGLRStack (yystackp, YYINITDEPTH))
|
||||
goto yyexhaustedlab;
|
||||
|
||||
15
data/glr.cc
15
data/glr.cc
@@ -90,8 +90,7 @@ m4_define([b4_yy_symbol_print_generate],
|
||||
|
||||
# Declare yyerror.
|
||||
m4_append([b4_post_prologue],
|
||||
[/* Line __line__ of glr.cc. */
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
[b4_syncline([@oline@], [@ofile@])
|
||||
|
||||
b4_c_ansi_function_decl([yyerror],
|
||||
[static void],
|
||||
@@ -102,8 +101,7 @@ b4_c_ansi_function_decl([yyerror],
|
||||
|
||||
# Define yyerror.
|
||||
m4_append([b4_epilogue],
|
||||
[/* Line __line__ of glr.cc. */
|
||||
b4_syncline([@oline@], [@ofile@])[
|
||||
[b4_syncline([@oline@], [@ofile@])[
|
||||
/*------------------.
|
||||
| Report an error. |
|
||||
`------------------*/
|
||||
@@ -237,10 +235,7 @@ namespace ]b4_namespace[
|
||||
|
||||
]m4_ifdef([b4_start_header],
|
||||
[[/* Copy the %start-header blocks. */
|
||||
]b4_start_header])[]dnl
|
||||
|
||||
[/* Line __line__ of glr.cc. */
|
||||
]b4_syncline([@oline@], [@ofile@])[
|
||||
]b4_user_start_header])[
|
||||
|
||||
#include "location.hh"
|
||||
|
||||
@@ -291,9 +286,7 @@ namespace ]b4_namespace[
|
||||
#ifndef YYSTYPE
|
||||
]m4_ifdef([b4_stype],
|
||||
[ union semantic_type
|
||||
b4_stype
|
||||
/* Line __line__ of lalr1.cc. */
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_user_stype
|
||||
;],
|
||||
[ typedef int semantic_type;])[
|
||||
#else
|
||||
|
||||
@@ -55,10 +55,7 @@ namespace ]b4_namespace[
|
||||
|
||||
]m4_ifdef([b4_start_header],
|
||||
[[/* Copy the %start-header blocks. */
|
||||
]b4_start_header])[]dnl
|
||||
|
||||
[/* Line __line__ of lalr1.cc. */
|
||||
]b4_syncline([@oline@], [@ofile@])[
|
||||
]b4_user_start_header])[
|
||||
|
||||
]dnl Include location.hh here: it might depend on headers included above.
|
||||
[#include "location.hh"
|
||||
@@ -111,9 +108,7 @@ namespace ]b4_namespace[
|
||||
#ifndef YYSTYPE
|
||||
]m4_ifdef([b4_stype],
|
||||
[ union semantic_type
|
||||
b4_stype
|
||||
/* Line __line__ of lalr1.cc. */
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_user_stype
|
||||
;],
|
||||
[ typedef int semantic_type;])[
|
||||
#else
|
||||
@@ -321,10 +316,7 @@ b4_defines_if([
|
||||
#include @output_header_name@])[
|
||||
|
||||
/* User implementation prologue. */
|
||||
]b4_post_prologue[
|
||||
|
||||
]/* Line __line__ of lalr1.cc. */
|
||||
b4_syncline([@oline@], [@ofile@])[
|
||||
]b4_user_post_prologue[
|
||||
|
||||
#ifndef YY_
|
||||
# if YYENABLE_NLS
|
||||
@@ -557,11 +549,9 @@ namespace ]b4_namespace[
|
||||
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
||||
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
||||
/* User initialization code. */
|
||||
b4_initial_action
|
||||
b4_user_initial_action
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
m4_popdef([b4_at_dollar])dnl
|
||||
/* Line __line__ of yacc.c. */
|
||||
b4_syncline([@oline@], [@ofile@])])dnl
|
||||
m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
[ /* Initialize the stacks. The initial state will be pushed in
|
||||
yynewstate, since the latter expects the semantical and the
|
||||
@@ -680,9 +670,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
|
||||
YY_REDUCE_PRINT (yyn);
|
||||
switch (yyn)
|
||||
{
|
||||
]b4_actions
|
||||
/* Line __line__ of lalr1.cc. */
|
||||
b4_syncline([@oline@], [@ofile@])[
|
||||
]b4_user_actions[
|
||||
default: break;
|
||||
}
|
||||
YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
|
||||
|
||||
24
data/yacc.c
24
data/yacc.c
@@ -190,9 +190,7 @@ b4_token_enums_defines(b4_tokens)[
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
]m4_ifdef([b4_stype],
|
||||
[[typedef union ]b4_union_name
|
||||
b4_stype
|
||||
/* Line __line__ of yacc.c. */
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_user_stype
|
||||
YYSTYPE;],
|
||||
[typedef int YYSTYPE;])[
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
@@ -218,10 +216,7 @@ m4_ifdef([b4_end_header],
|
||||
]b4_end_header])[]dnl
|
||||
|
||||
[/* Copy the second part of user declarations. */
|
||||
]b4_post_prologue
|
||||
|
||||
[/* Line __line__ of yacc.c. */
|
||||
]b4_syncline([@oline@], [@ofile@])[
|
||||
]b4_user_post_prologue[
|
||||
|
||||
#ifdef short
|
||||
# undef short
|
||||
@@ -1077,12 +1072,9 @@ m4_ifdef([b4_initial_action], [
|
||||
m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl
|
||||
m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl
|
||||
/* User initialization code. */
|
||||
b4_initial_action
|
||||
b4_user_initial_action
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
m4_popdef([b4_at_dollar])dnl
|
||||
/* Line __line__ of yacc.c. */
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
])dnl
|
||||
m4_popdef([b4_at_dollar])])dnl
|
||||
m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
|
||||
]])dnl
|
||||
m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
|
||||
@@ -1270,9 +1262,7 @@ yyreduce:
|
||||
YY_REDUCE_PRINT (yyn);
|
||||
switch (yyn)
|
||||
{
|
||||
]b4_actions
|
||||
/* Line __line__ of yacc.c. */
|
||||
b4_syncline([@oline@], [@ofile@])[
|
||||
]b4_user_actions[
|
||||
default: break;
|
||||
}
|
||||
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
||||
@@ -1507,9 +1497,7 @@ b4_token_enums_defines(b4_tokens)
|
||||
[#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
]m4_ifdef([b4_stype],
|
||||
[[typedef union ]b4_union_name
|
||||
b4_stype
|
||||
/* Line __line__ of yacc.c. */
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
b4_user_stype
|
||||
YYSTYPE;],
|
||||
[typedef int YYSTYPE;])[
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
|
||||
Reference in New Issue
Block a user