X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/a36b333cc208e43106b3c556b6bb9205b0a831a2..75ad86eebd3f49dff81976eb83036eb7b7793e68:/data/lalr1.cc?ds=inline diff --git a/data/lalr1.cc b/data/lalr1.cc index e76077d6..63712265 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -1,8 +1,7 @@ -m4_divert(-1) - # C++ skeleton for Bison -# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, +# Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,9 +20,14 @@ m4_divert(-1) m4_include(b4_pkgdatadir/[c++.m4]) +m4_define([b4_parser_class_name], + [b4_percent_define_get([[parser_class_name]])]) +m4_define([b4_namespace], + [b4_percent_define_get([[namespace]])]) + # The header is mandatory. b4_defines_if([], - [m4_fatal(b4_skeleton[: using %defines is mandatory])]) + [b4_fatal([b4_skeleton[: using %%defines is mandatory]])]) # Backward compatibility. m4_define([b4_location_constructors]) @@ -31,9 +35,9 @@ m4_include(b4_pkgdatadir/[location.cc]) # We do want M4 expansion after # for CPP macros. m4_changecom() -m4_divert(0)dnl +m4_divert_push(0)dnl b4_defines_if( -[@output @output_header_name@ +[@output(b4_spec_defines_file@) b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++], [2002, 2003, 2004, 2005, 2006]) dnl FIXME: This is wrong, we want computed header guards. @@ -43,9 +47,7 @@ dnl FIXME: This is wrong, we want computed header guards. #ifndef PARSER_HEADER_H # define PARSER_HEADER_H -]m4_ifdef([b4_start_header], -[[/* Copy the %start-header blocks. */ -]b4_user_start_header])[ +]b4_percent_code_get([[requires]])[ #include #include @@ -107,8 +109,9 @@ namespace ]b4_namespace[ #ifndef YYSTYPE ]m4_ifdef([b4_stype], [ union semantic_type + { b4_user_stype - ;], + };], [m4_if(b4_tag_seen_flag, 0, [[ typedef int semantic_type;]], [[ typedef YYSTYPE semantic_type;]])])[ @@ -116,7 +119,7 @@ b4_user_stype typedef YYSTYPE semantic_type; #endif /// Symbol locations. - typedef ]b4_location_type[ location_type; + typedef ]b4_percent_define_get([[location_type]])[ location_type; /// Tokens. struct token { @@ -287,7 +290,7 @@ b4_error_verbose_if([, int tok])[); }; } -]m4_ifset([b4_global_tokens_and_yystype], +]b4_percent_define_flag_if([[global_tokens_and_yystype]], [b4_token_defines(b4_tokens) #ifndef YYSTYPE @@ -295,30 +298,30 @@ b4_error_verbose_if([, int tok])[); # define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type #endif ]) -m4_ifdef([b4_end_header], -[[/* Copy the %end-header blocks. */ -]b4_end_header])[]dnl +b4_percent_code_get([[provides]])[]dnl [#endif /* ! defined PARSER_HEADER_H */] ])dnl -@output @output_parser_name@ +@output(b4_parser_file_name@) b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++], [2002, 2003, 2004, 2005, 2006]) +b4_percent_code_get([[top]])[]dnl m4_if(b4_prefix, [yy], [], [ // Take the name prefix into account. #define yylex b4_prefix[]lex])[ /* First part of user declarations. */ -]b4_pre_prologue +]b4_user_pre_prologue -b4_defines_if([ -#include @output_header_name@])[ +b4_defines_if([[ +#include "@basename(]b4_spec_defines_file[@)"]])[ /* User implementation prologue. */ -]b4_user_post_prologue[ +]b4_user_post_prologue +b4_percent_code_get[]dnl -#ifndef YY_ +[#ifndef YY_ # if YYENABLE_NLS # if ENABLE_NLS # include /* FIXME: INFRINGES ON USER NAME SPACE */ @@ -1010,7 +1013,7 @@ b4_error_verbose_if([, int tok])[) int yynrhs = yyr2_[yyrule]; /* Print the symbols being reduced, and their result. */ *yycdebug_ << "Reducing stack by rule " << yyrule - 1 - << " (line " << yylno << "), "; + << " (line " << yylno << "):" << std::endl; /* The symbols being reduced. */ for (int yyi = 0; yyi < yynrhs; yyi++) YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", @@ -1052,7 +1055,7 @@ b4_error_verbose_if([, int tok])[) ]b4_epilogue dnl -@output b4_dir_prefix[]stack.hh +@output(b4_dir_prefix[]stack.hh@) b4_copyright([Stack handling for Bison parsers in C++], [2002, 2003, 2004, 2005, 2006])[ @@ -1151,4 +1154,4 @@ namespace ]b4_namespace[ } #endif // not BISON_STACK_HH] -m4_divert(-1) +m4_divert_pop(0)