mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 08:43:03 +00:00
Apply --prefix to C++ skeletons too: they change the namespace.
The test suite already exercize these cases. * data/c++.m4 (b4_namespace): New. * data/lalr1.cc, data/glr.cc, data/location.cc: Use it instead of `yy'. * data/lalr1.cc (yytnameerr_): Move its definition into the namespace. * data/yacc.c, data/glr.c: Remove a useless `[]'. * doc/bison.texinfo: Document it. (Option Cross Key): Use @multitable in all formats. It looks nicer, even in TeX outputs. (Rules): Use the same code whatever the output type is. * tests/local.at (_AT_BISON_OPTION_PUSHDEFS) (_AT_BISON_OPTION_POPDEFS): Support AT_NAME_PREFIX. * tests/calc.at: Use it, instead of hard coding `yy'.
This commit is contained in:
16
ChangeLog
16
ChangeLog
@@ -1,3 +1,19 @@
|
|||||||
|
2006-03-12 Akim Demaille <akim@lrde.epita.fr>
|
||||||
|
|
||||||
|
Apply --prefix to C++ skeletons too: they change the namespace.
|
||||||
|
The test suite already exercize these cases.
|
||||||
|
* data/c++.m4 (b4_namespace): New.
|
||||||
|
* data/lalr1.cc, data/glr.cc, data/location.cc: Use it instead of `yy'.
|
||||||
|
* data/lalr1.cc (yytnameerr_): Move its definition into the namespace.
|
||||||
|
* data/yacc.c, data/glr.c: Remove a useless `[]'.
|
||||||
|
* doc/bison.texinfo: Document it.
|
||||||
|
(Option Cross Key): Use @multitable in all formats. It looks
|
||||||
|
nicer, even in TeX outputs.
|
||||||
|
(Rules): Use the same code whatever the output type is.
|
||||||
|
* tests/local.at (_AT_BISON_OPTION_PUSHDEFS)
|
||||||
|
(_AT_BISON_OPTION_POPDEFS): Support AT_NAME_PREFIX.
|
||||||
|
* tests/calc.at: Use it, instead of hard coding `yy'.
|
||||||
|
|
||||||
2006-03-10 Akim Demaille <akim@lrde.epita.fr>
|
2006-03-10 Akim Demaille <akim@lrde.epita.fr>
|
||||||
|
|
||||||
* TODO: Remove dead items.
|
* TODO: Remove dead items.
|
||||||
|
|||||||
4
NEWS
4
NEWS
@@ -3,7 +3,9 @@ Bison News
|
|||||||
|
|
||||||
Changes in version 2.1b:
|
Changes in version 2.1b:
|
||||||
|
|
||||||
* No user-visible changes.
|
* %name-prefix changes the namespace name in C++ outputs.
|
||||||
|
|
||||||
|
* The C++ parsers export their token_type.
|
||||||
|
|
||||||
Changes in version 2.1a, 2006-02-13:
|
Changes in version 2.1a, 2006-02-13:
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ m4_include(b4_pkgdatadir/[c.m4])
|
|||||||
m4_define_default([b4_parser_class_name], [parser])
|
m4_define_default([b4_parser_class_name], [parser])
|
||||||
m4_define_default([b4_location_type], [location])
|
m4_define_default([b4_location_type], [location])
|
||||||
m4_define_default([b4_filename_type], [std::string])
|
m4_define_default([b4_filename_type], [std::string])
|
||||||
|
m4_define_default([b4_namespace], m4_defn([b4_prefix]))
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ b4_copyright([Skeleton parser for GLR parsing with Bison],
|
|||||||
|
|
||||||
]b4_identification
|
]b4_identification
|
||||||
|
|
||||||
m4_if(b4_prefix[], [yy], [],
|
m4_if(b4_prefix, [yy], [],
|
||||||
[/* Substitute the variable and function names. */
|
[/* Substitute the variable and function names. */
|
||||||
#define yyparse b4_prefix[]parse
|
#define yyparse b4_prefix[]parse
|
||||||
#define yylex b4_prefix[]lex
|
#define yylex b4_prefix[]lex
|
||||||
|
|||||||
24
data/glr.cc
24
data/glr.cc
@@ -73,9 +73,9 @@ m4_define([b4_yy_symbol_print_generate],
|
|||||||
[static void],
|
[static void],
|
||||||
[[FILE *], []],
|
[[FILE *], []],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
[[const yy::b4_parser_class_name::semantic_type *yyvaluep],
|
[[const b4_namespace::b4_parser_class_name::semantic_type *yyvaluep],
|
||||||
[yyvaluep]],
|
[yyvaluep]],
|
||||||
[[const yy::b4_parser_class_name::location_type *yylocationp],
|
[[const b4_namespace::b4_parser_class_name::location_type *yylocationp],
|
||||||
[yylocationp]],
|
[yylocationp]],
|
||||||
b4_parse_param)[
|
b4_parse_param)[
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,7 @@ b4_syncline([@oline@], [@ofile@])
|
|||||||
|
|
||||||
b4_c_ansi_function_decl([yyerror],
|
b4_c_ansi_function_decl([yyerror],
|
||||||
[static void],
|
[static void],
|
||||||
[[yy::b4_parser_class_name::location_type *yylocationp], [yylocationp]],
|
[[b4_namespace::b4_parser_class_name::location_type *yylocationp], [yylocationp]],
|
||||||
b4_parse_param,
|
b4_parse_param,
|
||||||
[[const char* msg], [msg]])])
|
[[const char* msg], [msg]])])
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
|
|
||||||
]b4_c_ansi_function_def([yyerror],
|
]b4_c_ansi_function_def([yyerror],
|
||||||
[static void],
|
[static void],
|
||||||
[[yy::b4_parser_class_name::location_type *yylocationp], [yylocationp]],
|
[[b4_namespace::b4_parser_class_name::location_type *yylocationp], [yylocationp]],
|
||||||
b4_parse_param,
|
b4_parse_param,
|
||||||
[[const char* msg], [msg]])[
|
[[const char* msg], [msg]])[
|
||||||
{
|
{
|
||||||
@@ -116,7 +116,7 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace yy
|
namespace ]b4_namespace[
|
||||||
{
|
{
|
||||||
]dnl In this section, the parse param are the original parse_params.
|
]dnl In this section, the parse param are the original parse_params.
|
||||||
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||||
@@ -195,7 +195,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
|
|
||||||
#endif /* ! YYDEBUG */
|
#endif /* ! YYDEBUG */
|
||||||
]m4_popdef([b4_parse_param])dnl
|
]m4_popdef([b4_parse_param])dnl
|
||||||
[} // namespace yy
|
[} // namespace ]b4_namespace[
|
||||||
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -203,10 +203,10 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
# Let glr.c believe that the user arguments include the parser itself.
|
# Let glr.c believe that the user arguments include the parser itself.
|
||||||
m4_ifset([b4_parse_param],
|
m4_ifset([b4_parse_param],
|
||||||
[m4_pushdef([b4_parse_param],
|
[m4_pushdef([b4_parse_param],
|
||||||
m4_dquote([[[yy::b4_parser_class_name& yyparser], [[yyparser]]],]
|
m4_dquote([[[b4_namespace::b4_parser_class_name& yyparser], [[yyparser]]],]
|
||||||
m4_defn([b4_parse_param])))],
|
m4_defn([b4_parse_param])))],
|
||||||
[m4_pushdef([b4_parse_param],
|
[m4_pushdef([b4_parse_param],
|
||||||
[[[[yy::b4_parser_class_name& yyparser], [[yyparser]]]]])
|
[[[[b4_namespace::b4_parser_class_name& yyparser], [[yyparser]]]]])
|
||||||
])
|
])
|
||||||
m4_include(b4_pkgdatadir/[glr.c])
|
m4_include(b4_pkgdatadir/[glr.c])
|
||||||
m4_popdef([b4_parse_param])
|
m4_popdef([b4_parse_param])
|
||||||
@@ -227,7 +227,7 @@ b4_copyright([C++ Skeleton parser for GLALR(1) parsing with Bison],
|
|||||||
/* Using locations. */
|
/* Using locations. */
|
||||||
#define YYLSP_NEEDED ]b4_locations_flag[
|
#define YYLSP_NEEDED ]b4_locations_flag[
|
||||||
|
|
||||||
namespace yy
|
namespace ]b4_namespace[
|
||||||
{
|
{
|
||||||
class position;
|
class position;
|
||||||
class location;
|
class location;
|
||||||
@@ -287,7 +287,7 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
while (/*CONSTCOND*/ 0)
|
while (/*CONSTCOND*/ 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace yy
|
namespace ]b4_namespace[
|
||||||
{
|
{
|
||||||
/// A Bison parser.
|
/// A Bison parser.
|
||||||
class ]b4_parser_class_name[
|
class ]b4_parser_class_name[
|
||||||
@@ -384,10 +384,10 @@ m4_ifset([b4_global_tokens_and_yystype],
|
|||||||
[b4_token_defines(b4_tokens)])
|
[b4_token_defines(b4_tokens)])
|
||||||
[
|
[
|
||||||
#ifndef YYSTYPE
|
#ifndef YYSTYPE
|
||||||
# define YYSTYPE yy::]b4_parser_class_name[::semantic_type
|
# define YYSTYPE ]b4_namespace[::]b4_parser_class_name[::semantic_type
|
||||||
#endif
|
#endif
|
||||||
#ifndef YYLTYPE
|
#ifndef YYLTYPE
|
||||||
# define YYLTYPE yy::]b4_parser_class_name[::location_type
|
# define YYLTYPE ]b4_namespace[::]b4_parser_class_name[::location_type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ dnl FIXME: This is wrong, we want computed header guards.
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "stack.hh"
|
#include "stack.hh"
|
||||||
|
|
||||||
namespace yy
|
namespace ]b4_namespace[
|
||||||
{
|
{
|
||||||
class position;
|
class position;
|
||||||
class location;
|
class location;
|
||||||
@@ -94,7 +94,7 @@ do { \
|
|||||||
} while (false)
|
} while (false)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace yy
|
namespace ]b4_namespace[
|
||||||
{
|
{
|
||||||
|
|
||||||
/// A Bison parser.
|
/// A Bison parser.
|
||||||
@@ -291,7 +291,7 @@ b4_error_verbose_if([, int tok])[);
|
|||||||
|
|
||||||
#ifndef YYSTYPE
|
#ifndef YYSTYPE
|
||||||
/* Redirection for backward compatibility. */
|
/* Redirection for backward compatibility. */
|
||||||
# define YYSTYPE yy::b4_parser_class_name::semantic_type
|
# define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type
|
||||||
#endif
|
#endif
|
||||||
])[
|
])[
|
||||||
#endif /* ! defined PARSER_HEADER_H */]
|
#endif /* ! defined PARSER_HEADER_H */]
|
||||||
@@ -299,7 +299,7 @@ b4_error_verbose_if([, int tok])[);
|
|||||||
@output @output_parser_name@
|
@output @output_parser_name@
|
||||||
b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
|
b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
|
||||||
[2002, 2003, 2004, 2005, 2006])
|
[2002, 2003, 2004, 2005, 2006])
|
||||||
m4_if(b4_prefix[], [yy], [],
|
m4_if(b4_prefix, [yy], [],
|
||||||
[
|
[
|
||||||
// Take the name prefix into account.
|
// Take the name prefix into account.
|
||||||
#define yylex b4_prefix[]lex])
|
#define yylex b4_prefix[]lex])
|
||||||
@@ -370,49 +370,49 @@ do { \
|
|||||||
#define YYABORT goto yyabortlab
|
#define YYABORT goto yyabortlab
|
||||||
#define YYERROR goto yyerrorlab
|
#define YYERROR goto yyerrorlab
|
||||||
|
|
||||||
|
namespace ]b4_namespace[
|
||||||
|
{
|
||||||
#if YYERROR_VERBOSE
|
#if YYERROR_VERBOSE
|
||||||
|
|
||||||
/* Return YYSTR after stripping away unnecessary quotes and
|
/* Return YYSTR after stripping away unnecessary quotes and
|
||||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||||
that double-quoting is unnecessary unless the string contains an
|
that double-quoting is unnecessary unless the string contains an
|
||||||
apostrophe, a comma, or backslash (other than backslash-backslash).
|
apostrophe, a comma, or backslash (other than backslash-backslash).
|
||||||
YYSTR is taken from yytname. */
|
YYSTR is taken from yytname. */
|
||||||
std::string
|
std::string
|
||||||
yy::]b4_parser_class_name[::yytnamerr_ (const char *yystr)
|
]b4_parser_class_name[::yytnamerr_ (const char *yystr)
|
||||||
{
|
{
|
||||||
if (*yystr == '"')
|
if (*yystr == '"')
|
||||||
{
|
{
|
||||||
std::string yyr = "";
|
std::string yyr = "";
|
||||||
char const *yyp = yystr;
|
char const *yyp = yystr;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
switch (*++yyp)
|
switch (*++yyp)
|
||||||
{
|
{
|
||||||
case '\'':
|
case '\'':
|
||||||
case ',':
|
case ',':
|
||||||
goto do_not_strip_quotes;
|
goto do_not_strip_quotes;
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
if (*++yyp != '\\')
|
if (*++yyp != '\\')
|
||||||
goto do_not_strip_quotes;
|
goto do_not_strip_quotes;
|
||||||
/* Fall through. */
|
/* Fall through. */
|
||||||
default:
|
default:
|
||||||
yyr += *yyp;
|
yyr += *yyp;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '"':
|
case '"':
|
||||||
return yyr;
|
return yyr;
|
||||||
}
|
}
|
||||||
do_not_strip_quotes: ;
|
do_not_strip_quotes: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return yystr;
|
return yystr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace yy
|
|
||||||
{
|
|
||||||
/// Build a parser object.
|
/// Build a parser object.
|
||||||
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)
|
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)
|
||||||
: yydebug_ (false),
|
: yydebug_ (false),
|
||||||
@@ -1047,7 +1047,7 @@ b4_error_verbose_if([, int tok])[)
|
|||||||
const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[;
|
const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[;
|
||||||
const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
|
const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
|
||||||
|
|
||||||
} // namespace yy
|
} // namespace ]b4_namespace[
|
||||||
|
|
||||||
]b4_epilogue
|
]b4_epilogue
|
||||||
dnl
|
dnl
|
||||||
@@ -1060,7 +1060,7 @@ b4_copyright([stack handling for Bison C++ parsers],
|
|||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
namespace yy
|
namespace ]b4_namespace[
|
||||||
{
|
{
|
||||||
template <class T, class S = std::deque<T> >
|
template <class T, class S = std::deque<T> >
|
||||||
class stack
|
class stack
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ b4_copyright([Position class for Bison C++ parsers],
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
** \file position.hh
|
** \file position.hh
|
||||||
** Define the yy::position class.
|
** Define the ]b4_namespace[::position class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BISON_POSITION_HH
|
#ifndef BISON_POSITION_HH
|
||||||
@@ -37,7 +37,7 @@ b4_copyright([Position class for Bison C++ parsers],
|
|||||||
# include <iostream>
|
# include <iostream>
|
||||||
# include <string>
|
# include <string>
|
||||||
|
|
||||||
namespace yy
|
namespace ]b4_namespace[
|
||||||
{
|
{
|
||||||
/// Abstract a position.
|
/// Abstract a position.
|
||||||
class position
|
class position
|
||||||
@@ -140,7 +140,7 @@ b4_copyright([Location class for Bison C++ parsers],
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
** \file location.hh
|
** \file location.hh
|
||||||
** Define the yy::location class.
|
** Define the ]b4_namespace[::location class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BISON_LOCATION_HH
|
#ifndef BISON_LOCATION_HH
|
||||||
@@ -150,7 +150,7 @@ b4_copyright([Location class for Bison C++ parsers],
|
|||||||
# include <string>
|
# include <string>
|
||||||
# include "position.hh"
|
# include "position.hh"
|
||||||
|
|
||||||
namespace yy
|
namespace ]b4_namespace[
|
||||||
{
|
{
|
||||||
|
|
||||||
/// Abstract a location.
|
/// Abstract a location.
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
|
|||||||
USER NAME SPACE" below. */
|
USER NAME SPACE" below. */
|
||||||
|
|
||||||
]b4_identification
|
]b4_identification
|
||||||
m4_if(b4_prefix[], [yy], [],
|
m4_if(b4_prefix, [yy], [],
|
||||||
[/* Substitute the variable and function names. */
|
[/* Substitute the variable and function names. */
|
||||||
#define yyparse b4_prefix[]parse
|
#define yyparse b4_prefix[]parse
|
||||||
#define yylex b4_prefix[]lex
|
#define yylex b4_prefix[]lex
|
||||||
|
|||||||
@@ -515,8 +515,8 @@ int /* @r{keyword `int'} */
|
|||||||
square (int x) /* @r{identifier, open-paren, keyword `int',}
|
square (int x) /* @r{identifier, open-paren, keyword `int',}
|
||||||
@r{identifier, close-paren} */
|
@r{identifier, close-paren} */
|
||||||
@{ /* @r{open-brace} */
|
@{ /* @r{open-brace} */
|
||||||
return x * x; /* @r{keyword `return', identifier, asterisk,
|
return x * x; /* @r{keyword `return', identifier, asterisk,}
|
||||||
identifier, semicolon} */
|
@r{identifier, semicolon} */
|
||||||
@} /* @r{close-brace} */
|
@} /* @r{close-brace} */
|
||||||
@end example
|
@end example
|
||||||
@end ifinfo
|
@end ifinfo
|
||||||
@@ -1368,11 +1368,8 @@ under BSD Unix 4.3; each produces a usable, though limited, interactive
|
|||||||
desk-top calculator.
|
desk-top calculator.
|
||||||
|
|
||||||
These examples are simple, but Bison grammars for real programming
|
These examples are simple, but Bison grammars for real programming
|
||||||
languages are written the same way.
|
languages are written the same way. You can copy these examples into a
|
||||||
@ifinfo
|
source file to try them.
|
||||||
You can copy these examples out of the Info file and into a source file
|
|
||||||
to try them.
|
|
||||||
@end ifinfo
|
|
||||||
|
|
||||||
@menu
|
@menu
|
||||||
* RPN Calc:: Reverse polish notation calculator;
|
* RPN Calc:: Reverse polish notation calculator;
|
||||||
@@ -2936,15 +2933,6 @@ Usually there is only one action and it follows the components.
|
|||||||
Multiple rules for the same @var{result} can be written separately or can
|
Multiple rules for the same @var{result} can be written separately or can
|
||||||
be joined with the vertical-bar character @samp{|} as follows:
|
be joined with the vertical-bar character @samp{|} as follows:
|
||||||
|
|
||||||
@ifinfo
|
|
||||||
@example
|
|
||||||
@var{result}: @var{rule1-components}@dots{}
|
|
||||||
| @var{rule2-components}@dots{}
|
|
||||||
@dots{}
|
|
||||||
;
|
|
||||||
@end example
|
|
||||||
@end ifinfo
|
|
||||||
@iftex
|
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
@var{result}: @var{rule1-components}@dots{}
|
@var{result}: @var{rule1-components}@dots{}
|
||||||
@@ -2953,7 +2941,6 @@ be joined with the vertical-bar character @samp{|} as follows:
|
|||||||
;
|
;
|
||||||
@end group
|
@end group
|
||||||
@end example
|
@end example
|
||||||
@end iftex
|
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
They are still considered distinct rules even when joined in this way.
|
They are still considered distinct rules even when joined in this way.
|
||||||
@@ -4244,12 +4231,14 @@ accurate syntax error messages.
|
|||||||
@deffn {Directive} %name-prefix="@var{prefix}"
|
@deffn {Directive} %name-prefix="@var{prefix}"
|
||||||
Rename the external symbols used in the parser so that they start with
|
Rename the external symbols used in the parser so that they start with
|
||||||
@var{prefix} instead of @samp{yy}. The precise list of symbols renamed
|
@var{prefix} instead of @samp{yy}. The precise list of symbols renamed
|
||||||
|
in C parsers
|
||||||
is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
|
is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
|
||||||
@code{yylval}, @code{yylloc}, @code{yychar}, @code{yydebug}, and
|
@code{yylval}, @code{yylloc}, @code{yychar}, @code{yydebug}, and
|
||||||
possible @code{yylloc}. For example, if you use
|
possible @code{yylloc}. For example, if you use
|
||||||
@samp{%name-prefix="c_"}, the names become @code{c_parse}, @code{c_lex},
|
@samp{%name-prefix="c_"}, the names become @code{c_parse}, @code{c_lex},
|
||||||
and so on. @xref{Multiple Parsers, ,Multiple Parsers in the Same
|
and so on. In C++ parsers, it is only the surrounding namespace which is
|
||||||
Program}.
|
named @var{prefix} instead of @samp{yy}.
|
||||||
|
@xref{Multiple Parsers, ,Multiple Parsers in the Same Program}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@ifset defaultprec
|
@ifset defaultprec
|
||||||
@@ -6920,7 +6909,7 @@ Same as above, but save in the file @var{defines-file}.
|
|||||||
|
|
||||||
@item -b @var{file-prefix}
|
@item -b @var{file-prefix}
|
||||||
@itemx --file-prefix=@var{prefix}
|
@itemx --file-prefix=@var{prefix}
|
||||||
Pretend that @code{%verbose} was specified, i.e, specify prefix to use
|
Pretend that @code{%file-prefix} was specified, i.e, specify prefix to use
|
||||||
for all Bison output file names. @xref{Decl Summary}.
|
for all Bison output file names. @xref{Decl Summary}.
|
||||||
|
|
||||||
@item -r @var{things}
|
@item -r @var{things}
|
||||||
@@ -6970,48 +6959,27 @@ the output graph file.
|
|||||||
@node Option Cross Key
|
@node Option Cross Key
|
||||||
@section Option Cross Key
|
@section Option Cross Key
|
||||||
|
|
||||||
|
@c FIXME: How about putting the directives too?
|
||||||
Here is a list of options, alphabetized by long option, to help you find
|
Here is a list of options, alphabetized by long option, to help you find
|
||||||
the corresponding short option.
|
the corresponding short option.
|
||||||
|
|
||||||
@tex
|
@multitable {@option{--defines=@var{defines-file}}} {@option{-b @var{file-prefix}XXX}}
|
||||||
\def\leaderfill{\leaders\hbox to 1em{\hss.\hss}\hfill}
|
@headitem Long Option @tab Short Option
|
||||||
|
@item @option{--debug} @tab @option{-t}
|
||||||
{\tt
|
@item @option{--defines=@var{defines-file}} @tab @option{-d}
|
||||||
\line{ --debug \leaderfill -t}
|
@item @option{--file-prefix=@var{prefix}} @tab @option{-b @var{file-prefix}}
|
||||||
\line{ --defines \leaderfill -d}
|
@item @option{--graph=@var{graph-file}} @tab @option{-d}
|
||||||
\line{ --file-prefix \leaderfill -b}
|
@item @option{--help} @tab @option{-h}
|
||||||
\line{ --graph \leaderfill -g}
|
@item @option{--name-prefix=@var{prefix}} @tab @option{-p @var{name-prefix}}
|
||||||
\line{ --help \leaderfill -h}
|
@item @option{--no-lines} @tab @option{-l}
|
||||||
\line{ --name-prefix \leaderfill -p}
|
@item @option{--no-parser} @tab @option{-n}
|
||||||
\line{ --no-lines \leaderfill -l}
|
@item @option{--output=@var{outfile}} @tab @option{-o @var{outfile}}
|
||||||
\line{ --no-parser \leaderfill -n}
|
@item @option{--print-localedir} @tab
|
||||||
\line{ --output \leaderfill -o}
|
@item @option{--token-table} @tab @option{-k}
|
||||||
\line{ --print-localedir}
|
@item @option{--verbose} @tab @option{-v}
|
||||||
\line{ --token-table \leaderfill -k}
|
@item @option{--version} @tab @option{-V}
|
||||||
\line{ --verbose \leaderfill -v}
|
@item @option{--yacc} @tab @option{-y}
|
||||||
\line{ --version \leaderfill -V}
|
@end multitable
|
||||||
\line{ --yacc \leaderfill -y}
|
|
||||||
}
|
|
||||||
@end tex
|
|
||||||
|
|
||||||
@ifinfo
|
|
||||||
@example
|
|
||||||
--debug -t
|
|
||||||
--defines=@var{defines-file} -d
|
|
||||||
--file-prefix=@var{prefix} -b @var{file-prefix}
|
|
||||||
--graph=@var{graph-file} -d
|
|
||||||
--help -h
|
|
||||||
--name-prefix=@var{prefix} -p @var{name-prefix}
|
|
||||||
--no-lines -l
|
|
||||||
--no-parser -n
|
|
||||||
--output=@var{outfile} -o @var{outfile}
|
|
||||||
--print-localedir
|
|
||||||
--token-table -k
|
|
||||||
--verbose -v
|
|
||||||
--version -V
|
|
||||||
--yacc -y
|
|
||||||
@end example
|
|
||||||
@end ifinfo
|
|
||||||
|
|
||||||
@node Yacc Library
|
@node Yacc Library
|
||||||
@section Yacc Library
|
@section Yacc Library
|
||||||
@@ -7066,11 +7034,14 @@ int yyparse (void);
|
|||||||
@c - Always pure
|
@c - Always pure
|
||||||
@c - initial action
|
@c - initial action
|
||||||
|
|
||||||
The C++ parser @acronym{LALR}(1) skeleton is named @file{lalr1.cc}. To select
|
The C++ parser @acronym{LALR}(1) skeleton is named @file{lalr1.cc}. To
|
||||||
it, you may either pass the option @option{--skeleton=lalr1.cc} to
|
select it, you may either pass the option @option{--skeleton=lalr1.cc}
|
||||||
Bison, or include the directive @samp{%skeleton "lalr1.cc"} in the
|
to Bison, or include the directive @samp{%skeleton "lalr1.cc"} in the
|
||||||
grammar preamble. When run, @command{bison} will create several
|
grammar preamble. When run, @command{bison} will create several
|
||||||
files:
|
entities in the @samp{yy} namespace. Use the @samp{%name-prefix}
|
||||||
|
directive to change the namespace name, see @ref{Decl Summary}. The
|
||||||
|
various classes are generated in the following files:
|
||||||
|
|
||||||
@table @file
|
@table @file
|
||||||
@item position.hh
|
@item position.hh
|
||||||
@itemx location.hh
|
@itemx location.hh
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ static int global_count = 0;
|
|||||||
static int power (int base, int exponent);
|
static int power (int base, int exponent);
|
||||||
]AT_SKEL_CC_IF(
|
]AT_SKEL_CC_IF(
|
||||||
[#ifndef YYLTYPE
|
[#ifndef YYLTYPE
|
||||||
# define YYLTYPE yy::location
|
[#] define YYLTYPE AT_NAME_PREFIX::location
|
||||||
#endif
|
#endif
|
||||||
#define first_line begin.line
|
#define first_line begin.line
|
||||||
#define first_column begin.column
|
#define first_column begin.column
|
||||||
@@ -152,7 +152,7 @@ static FILE *input;
|
|||||||
]AT_SKEL_CC_IF(
|
]AT_SKEL_CC_IF(
|
||||||
[/* A C++ error reporting function. */
|
[/* A C++ error reporting function. */
|
||||||
void
|
void
|
||||||
yy::parser::error (const location& l, const std::string& m)
|
AT_NAME_PREFIX::parser::error (const location& l, const std::string& m)
|
||||||
{
|
{
|
||||||
(void) l;
|
(void) l;
|
||||||
std::cerr << AT_LOCATION_IF([l << ": " << ])m << std::endl;
|
std::cerr << AT_LOCATION_IF([l << ": " << ])m << std::endl;
|
||||||
@@ -161,7 +161,7 @@ yy::parser::error (const location& l, const std::string& m)
|
|||||||
int
|
int
|
||||||
yyparse (AT_PARAM_IF([semantic_value *result, int *count]))
|
yyparse (AT_PARAM_IF([semantic_value *result, int *count]))
|
||||||
{
|
{
|
||||||
yy::parser parser[]AT_PARAM_IF([ (result, count)]);
|
AT_NAME_PREFIX::parser parser[]AT_PARAM_IF([ (result, count)]);
|
||||||
parser.set_debug_level (!!YYDEBUG);
|
parser.set_debug_level (!!YYDEBUG);
|
||||||
return parser.parse ();
|
return parser.parse ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ m4_pushdef([AT_PURE_AND_LOC_IF],
|
|||||||
[$1], [$2])])
|
[$1], [$2])])
|
||||||
m4_pushdef([AT_GLR_OR_PARAM_IF],
|
m4_pushdef([AT_GLR_OR_PARAM_IF],
|
||||||
[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
|
[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
|
||||||
|
m4_pushdef([AT_NAME_PREFIX],
|
||||||
|
[m4_bregexp([$3], [name-prefix="\([^"]*\)"], [\1])])
|
||||||
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
|
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
|
||||||
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
||||||
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
|
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
|
||||||
@@ -80,7 +81,7 @@ m4_pushdef([AT_YYERROR_SEES_LOC_IF],
|
|||||||
# are using the C++ parsers.
|
# are using the C++ parsers.
|
||||||
m4_pushdef([AT_PURE_LEX_IF],
|
m4_pushdef([AT_PURE_LEX_IF],
|
||||||
[AT_PURE_IF([$1],
|
[AT_PURE_IF([$1],
|
||||||
[AT_LALR1_CC_IF([$1], [$2])])])
|
[AT_SKEL_CC_IF([$1], [$2])])])
|
||||||
|
|
||||||
AT_PURE_LEX_IF(
|
AT_PURE_LEX_IF(
|
||||||
[m4_pushdef([AT_LOC], [(*llocp)])
|
[m4_pushdef([AT_LOC], [(*llocp)])
|
||||||
@@ -120,6 +121,7 @@ m4_popdef([AT_LOC])
|
|||||||
m4_popdef([AT_PURE_LEX_IF])
|
m4_popdef([AT_PURE_LEX_IF])
|
||||||
m4_popdef([AT_YYERROR_SEES_LOC_IF])
|
m4_popdef([AT_YYERROR_SEES_LOC_IF])
|
||||||
m4_popdef([AT_YYERROR_ARG_LOC_IF])
|
m4_popdef([AT_YYERROR_ARG_LOC_IF])
|
||||||
|
m4_popdef([AT_NAME_PREFIX])
|
||||||
m4_popdef([AT_GLR_OR_PARAM_IF])
|
m4_popdef([AT_GLR_OR_PARAM_IF])
|
||||||
m4_popdef([AT_PURE_AND_LOC_IF])
|
m4_popdef([AT_PURE_AND_LOC_IF])
|
||||||
m4_popdef([AT_LOCATION_IF])
|
m4_popdef([AT_LOCATION_IF])
|
||||||
|
|||||||
Reference in New Issue
Block a user