1 m4_divert(-1) -*- Autoconf -*-
3 # C++ skeleton for Bison
5 # Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 m4_include(b4_pkgdatadir/[c.m4])
24 ## ---------------- ##
26 ## ---------------- ##
28 # Default parser class name.
29 m4_define_default([b4_parser_class_name], [parser])
30 m4_define_default([b4_location_type], [location])
31 m4_define_default([b4_filename_type], [std::string])
35 # b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
36 # -----------------------------------------------------
37 # Output the definition of the tokens (if there are) as enums.
38 m4_define([b4_token_enums],
39 [m4_if([$@], [[]], [],
42 m4_map_sep([ b4_token_enum], [,
49 ## ----------------- ##
50 ## Semantic Values. ##
51 ## ----------------- ##
54 # b4_lhs_value([TYPE])
55 # --------------------
56 # Expansion of $<TYPE>$.
57 m4_define([b4_lhs_value],
58 [(yyval[]m4_ifval([$1], [.$1]))])
61 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
62 # --------------------------------------
63 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
65 m4_define([b4_rhs_value],
66 [(yysemantic_stack_@{($1) - ($2)@}m4_ifval([$3], [.$3]))])
71 m4_define([b4_lhs_location],
75 # b4_rhs_location(RULE-LENGTH, NUM)
76 # ---------------------------------
77 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
79 m4_define([b4_rhs_location],
80 [(yylocation_stack_@{($1) - ($2)@})])
85 # Extra formal arguments of the constructor.
86 # Change the parameter names from "foo" into "foo_yyarg", so that
87 # there is no collision bw the user chosen attribute name, and the
88 # argument name in the constructor.
89 m4_define([b4_parse_param_decl],
90 [m4_ifset([b4_parse_param],
91 [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
93 m4_define([b4_parse_param_decl_1],
100 # Extra initialisations of the constructor.
101 m4_define([b4_parse_param_cons],
102 [m4_ifset([b4_parse_param],
104 b4_cc_constructor_calls(b4_parse_param)])])
105 m4_define([b4_cc_constructor_calls],
106 [m4_map_sep([b4_cc_constructor_call], [,
108 m4_define([b4_cc_constructor_call],
111 # b4_parse_param_vars
112 # -------------------
113 # Extra instance variables.
114 m4_define([b4_parse_param_vars],
115 [m4_ifset([b4_parse_param],
117 /* User arguments. */
118 b4_cc_var_decls(b4_parse_param)])])
119 m4_define([b4_cc_var_decls],
120 [m4_map_sep([b4_cc_var_decl], [
122 m4_define([b4_cc_var_decl],