X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/8e0a5e9e735620ef5196a155eed1f8cf4d3aab5f..6ce2d93a9b49afbc196e764923d539bc0caa1120:/data/lalr1.cc diff --git a/data/lalr1.cc b/data/lalr1.cc index 8dcce38a..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 @@ -20,11 +19,15 @@ m4_divert(-1) # 02110-1301 USA m4_include(b4_pkgdatadir/[c++.m4]) -b4_check_percent_code_qualifiers([[requires]], [[provides]], [[top]]) + +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]) @@ -32,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 b4_spec_defines_file +[@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. @@ -44,9 +47,7 @@ dnl FIXME: This is wrong, we want computed header guards. #ifndef PARSER_HEADER_H # define PARSER_HEADER_H -]m4_ifdef([b4_percent_code_requires], -[[/* Copy the %code "requires" blocks. */ -]b4_user_code([b4_percent_code_requires])])[ +]b4_percent_code_get([[requires]])[ #include #include @@ -108,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;]])])[ @@ -117,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 { @@ -288,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 @@ -296,18 +298,14 @@ b4_error_verbose_if([, int tok])[); # define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type #endif ]) -m4_ifdef([b4_percent_code_provides], -[[/* Copy the %code "provides" blocks. */ -]b4_user_code([b4_percent_code_provides])])[]dnl +b4_percent_code_get([[provides]])[]dnl [#endif /* ! defined PARSER_HEADER_H */] ])dnl -@output b4_parser_file_name +@output(b4_parser_file_name@) b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++], [2002, 2003, 2004, 2005, 2006]) -m4_ifdef([b4_percent_code_top], -[[/* Copy the %code "top" blocks. */ -]b4_user_code([b4_percent_code_top])])[]dnl +b4_percent_code_get([[top]])[]dnl m4_if(b4_prefix, [yy], [], [ // Take the name prefix into account. @@ -321,10 +319,7 @@ b4_defines_if([[ /* User implementation prologue. */ ]b4_user_post_prologue -m4_ifdef([b4_percent_code], -[[/* Copy the unqualified %code blocks. */ -]b4_user_code([b4_percent_code]) -])[]dnl +b4_percent_code_get[]dnl [#ifndef YY_ # if YYENABLE_NLS @@ -1018,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 << " =", @@ -1060,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])[ @@ -1159,4 +1154,4 @@ namespace ]b4_namespace[ } #endif // not BISON_STACK_HH] -m4_divert(-1) +m4_divert_pop(0)