* data/bison.c++: Copy the prologue of bison.simple to fetch

useful M4 definitions, such as b4_header_guard.
This commit is contained in:
Akim Demaille
2002-02-28 11:41:00 +00:00
parent dc2546ac9f
commit a75c057f10
2 changed files with 51 additions and 17 deletions

View File

@@ -1,7 +1,13 @@
2002-02-28 Akim Demaille <akim@epita.fr>
* data/bison.c++: Copy the prologue of bison.simple to fetch
useful M4 definitions, such as b4_header_guard.
2002-02-25 Akim Demaille <akim@epita.fr> 2002-02-25 Akim Demaille <akim@epita.fr>
* src/getargs.c (version): Give the name of the authors, and use a * src/getargs.c (version): Give the name of the authors, and use a
translator friendly scheme for the copyright notice. translator friendly scheme for the bgr
copyright notice.
2002-02-25 Akim Demaille <akim@epita.fr> 2002-02-25 Akim Demaille <akim@epita.fr>

View File

@@ -1,3 +1,31 @@
m4_divert(-1)
# m4_define_default(MACRO, VALUE)
# -------------------------------
# Define MACRO to VALUE, unless already defined.
m4_define([m4_define_default],
[m4_ifdef([$1], [], [m4_define($@)])])
m4_define_default([b4_input_suffix], [.y])
m4_define_default([b4_output_parser_suffix],
[m4_translit(b4_input_suffix, [yY], [cC])])
m4_define_default([b4_output_parser_name],
[b4_output_prefix[]b4_output_infix[]b4_output_parser_suffix[]])
m4_define_default([b4_output_header_suffix],
[m4_translit(b4_input_suffix, [yY], [hH])])
m4_define_default([b4_output_header_name],
[b4_output_prefix[]b4_output_infix[]b4_output_header_suffix[]])
m4_define_default([b4_header_guard],
[m4_bpatsubst(m4_toupper([BISON_]b4_output_header_name),
[[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]], [_])])
m4_divert(0)dnl
#output "b4_output_prefix[]b4_output_infix[]-class.hh" #output "b4_output_prefix[]b4_output_infix[]-class.hh"
/* -*- C++ -*- */ /* -*- C++ -*- */
@@ -272,7 +300,7 @@ yy::b4_name::parse ()
} }
else if (n_ == 0) else if (n_ == 0)
goto yyerrlab; goto yyerrlab;
/* Accept? */ /* Accept? */
if (n_ == final_) if (n_ == final_)
goto yyacceptlab; goto yyacceptlab;
@@ -326,7 +354,7 @@ yy::b4_name::parse ()
YYFPRINTF (stderr, "-> %s\n", name_[[r1_[n_]]]); YYFPRINTF (stderr, "-> %s\n", name_[[r1_[n_]]]);
} }
#endif #endif
{ {
SemanticType& yyval (value); SemanticType& yyval (value);
LocationType& yyloc (location); LocationType& yyloc (location);
@@ -338,7 +366,7 @@ yy::b4_name::parse ()
b4_actions b4_actions
} }
} }
state_stack_.pop (len_); state_stack_.pop (len_);
semantic_stack_.pop (len_); semantic_stack_.pop (len_);
location_stack_.pop (len_); location_stack_.pop (len_);
@@ -347,13 +375,13 @@ yy::b4_name::parse ()
if (debug_) if (debug_)
{ {
YYFPRINTF (stderr, "state stack now"); YYFPRINTF (stderr, "state stack now");
for (StateStack::ConstIterator i = state_stack_.begin (); for (StateStack::ConstIterator i = state_stack_.begin ();
i != state_stack_.end (); ++i) i != state_stack_.end (); ++i)
YYFPRINTF (stderr, " %d", *i); YYFPRINTF (stderr, " %d", *i);
YYFPRINTF (stderr, "\n"); YYFPRINTF (stderr, "\n");
} }
#endif #endif
semantic_stack_.push (value); semantic_stack_.push (value);
location_stack_.push (location); location_stack_.push (location);
@@ -372,7 +400,7 @@ yy::b4_name::parse ()
if (!errstatus) if (!errstatus)
{ {
++nerrs; ++nerrs;
#if YYERROR_VERBOSE #if YYERROR_VERBOSE
n_ = pact_[[state_]]; n_ = pact_[[state_]];
if (n_ > flag_ && n_ < last_) if (n_ > flag_ && n_ < last_)
@@ -390,7 +418,7 @@ yy::b4_name::parse ()
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x) for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
if (check_[[x + n_]] == x) if (check_[[x + n_]] == x)
{ {
message += (!count++) ? ", expecting " : " or "; message += (!count++) ? ", expecting " : " or ";
message += name_[[x]]; message += name_[[x]];
} }
} }
@@ -402,7 +430,7 @@ yy::b4_name::parse ()
error_ (); error_ ();
} }
goto yyerrlab1; goto yyerrlab1;
/* Error raised explicitly by an action. */ /* Error raised explicitly by an action. */
yyerrlab1: yyerrlab1:
if (errstatus == 3) if (errstatus == 3)
@@ -436,10 +464,10 @@ yy::b4_name::parse ()
if (debug_) if (debug_)
{ {
YYFPRINTF (stderr, "Error: state stack now"); YYFPRINTF (stderr, "Error: state stack now");
for (StateStack::ConstIterator i = state_stack_.begin (); for (StateStack::ConstIterator i = state_stack_.begin ();
i != state_stack_.end (); ++i) i != state_stack_.end (); ++i)
YYFPRINTF (stderr, " %d", *i); YYFPRINTF (stderr, " %d", *i);
YYFPRINTF (stderr, "\n"); YYFPRINTF (stderr, "\n");
} }
#endif #endif
@@ -541,14 +569,14 @@ yy::b4_name::check_[[]] =
}; };
/* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives. */ /* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives. */
const short const short
yy::b4_name::r1_[[]] = yy::b4_name::r1_[[]] =
{ {
b4_r1 b4_r1
}; };
/* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN. */ /* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN. */
const short const short
yy::b4_name::r2_[[]] = yy::b4_name::r2_[[]] =
{ {
b4_r2 b4_r2
@@ -566,7 +594,7 @@ const yy::b4_name::name_[[]] =
#if YYDEBUG #if YYDEBUG
/* YYRHS -- A `-1'-separated list of the rules' RHS. */ /* YYRHS -- A `-1'-separated list of the rules' RHS. */
const short const short
yy::b4_name::rhs_[[]] = yy::b4_name::rhs_[[]] =
{ {
b4_rhs b4_rhs
@@ -592,8 +620,8 @@ yy::b4_name::rline_[[]] =
char char
yy::b4_name::translate_ (int token) yy::b4_name::translate_ (int token)
{ {
static static
const char const char
translate_[[]] = translate_[[]] =
{ {
b4_translate b4_translate
@@ -669,7 +697,7 @@ namespace yy
for (; n; --n) for (; n; --n)
seq_.pop_back (); seq_.pop_back ();
} }
inline inline
void void
reserve (unsigned n) reserve (unsigned n)