X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/28427f57ceb6f70c3a84696a9275c60ed72d1f52..710c4a65711d48674ce330ac140d00f6338fa863:/data/lalr1.cc diff --git a/data/lalr1.cc b/data/lalr1.cc index 3d6bdca9..b3e46e95 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -120,10 +120,6 @@ m4_pushdef([b4_copyright_years], m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])]) -# The header is mandatory. -b4_defines_if([], - [b4_fatal([b4_skeleton[: using %%defines is mandatory]])]) - b4_locations_if([b4_percent_define_ifdef([[location_type]], [], [# Backward compatibility. m4_define([b4_location_constructors]) @@ -138,21 +134,26 @@ b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])]) m4_define([b4_shared_declarations], [b4_percent_code_get([[requires]])[ ]b4_parse_assert_if([# include ])[ -# include -# include +# include # include +# include +# include ]b4_defines_if([[ # include "stack.hh" ]b4_locations_if([b4_percent_define_ifdef([[location_type]], [], - [[# include "location.hh"]])])[ - -]b4_variant_if([b4_namespace_open -b4_variant_define -b4_namespace_close])[ + [[# include "location.hh"]])])])[ ]b4_YYDEBUG_define[ ]b4_namespace_open[ +]b4_defines_if([], +[b4_stack_define +b4_locations_if([b4_percent_define_ifdef([[location_type]], [], + [b4_position_define +b4_location_define])])])[ + +]b4_variant_if([b4_variant_define])[ + /// A Bison parser. class ]b4_parser_class_name[ { @@ -268,7 +269,7 @@ b4_namespace_close])[ inline stack_symbol_type (); /// Constructor. - inline stack_symbol_type (]b4_args([state_type s], + inline stack_symbol_type (]b4_join([state_type s], [const semantic_type& v], b4_locations_if([const location_type& l]))[); @@ -336,7 +337,8 @@ b4_public_types_define])[ # We do want M4 expansion after # for CPP macros. m4_changecom() -m4_divert_push(0)dnl +b4_defines_if( +[m4_divert_push(0)dnl @output(b4_spec_defines_file@)@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++]) [ @@ -350,6 +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 +]) + + +m4_divert_push(0)dnl @output(b4_parser_file_name@)@ b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++]) b4_percent_code_get([[top]])[]dnl @@ -363,7 +370,8 @@ m4_if(b4_prefix, [yy], [], ]b4_null_define[ -#include "@basename(]b4_spec_defines_file[@)" +]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], + [b4_shared_declarations])[ /* User implementation prologue. */ ]b4_user_post_prologue[ @@ -501,7 +509,7 @@ m4_if(b4_prefix, [yy], [], { } - ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (]b4_args( + ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (]b4_join( [state_type s], [const semantic_type& v], b4_locations_if([const location_type& l]))[) @@ -567,13 +575,13 @@ m4_if(b4_prefix, [yy], [], if (m) YY_SYMBOL_PRINT (m, sym); ]b4_variant_if( -[[ yystack_.push (stack_symbol_type (]b4_args( +[[ yystack_.push (stack_symbol_type (]b4_join( [s], [semantic_type()], b4_locations_if([sym.location]))[)); ]b4_symbol_variant([[yystos_[s]]], [[yystack_[0].value]], [build], [sym.value])], -[[ yystack_.push (stack_symbol_type (]b4_args( +[[ yystack_.push (stack_symbol_type (]b4_join( [s], [sym.value], b4_locations_if([sym.location]))[));]])[ @@ -585,7 +593,7 @@ m4_if(b4_prefix, [yy], [], if (m) YY_SYMBOL_PRINT (m, s); ]b4_variant_if( -[[ yystack_.push (stack_symbol_type (]b4_args( +[[ yystack_.push (stack_symbol_type (]b4_join( [s.state], [semantic_type()], b4_locations_if([s.location]))[)); @@ -844,7 +852,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[ if (!yyerrstatus_) { ++yynerrs_; - error (]b4_args(b4_locations_if([yyla.location]), + error (]b4_join(b4_locations_if([yyla.location]), [[yysyntax_error_ (yystack_[0].state, yyempty ? yyempty_ : yyla.type)]])[); } @@ -959,7 +967,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[ void ]b4_parser_class_name[::error (const syntax_error& yyexc) { - error (]b4_args(b4_locations_if([yyexc.location]), + error (]b4_join(b4_locations_if([yyexc.location]), [[yyexc.what()]])[); }