]> git.saurik.com Git - bison.git/blame - data/c++.m4
Transform XML into XHTML.
[bison.git] / data / c++.m4
CommitLineData
08af01c2 1 -*- Autoconf -*-
cf147260
AD
2
3# C++ skeleton for Bison
4
279cabb6
JD
5# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,
6# Inc.
cf147260 7
f16b0819 8# This program is free software: you can redistribute it and/or modify
cf147260 9# it under the terms of the GNU General Public License as published by
f16b0819 10# the Free Software Foundation, either version 3 of the License, or
cf147260 11# (at your option) any later version.
f16b0819 12#
cf147260
AD
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
f16b0819 17#
cf147260 18# You should have received a copy of the GNU General Public License
f16b0819 19# along with this program. If not, see <http://www.gnu.org/licenses/>.
cf147260 20
3953ed88
AD
21m4_include(b4_pkgdatadir/[c.m4])
22
cf147260
AD
23## ---------------- ##
24## Default values. ##
25## ---------------- ##
26
27# Default parser class name.
a4e25e1d
JD
28b4_percent_define_default([[parser_class_name]], [[parser]])
29b4_percent_define_default([[location_type]], [[location]])
30b4_percent_define_default([[filename_type]], [[std::string]])
31b4_percent_define_default([[namespace]], m4_defn([b4_prefix]))
c1d19e10 32b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
a4e25e1d
JD
33b4_percent_define_default([[define_location_comparison]],
34 [m4_if(b4_percent_define_get([[filename_type]]),
c1d19e10 35 [std::string], [[true]], [[false]])])
cf147260
AD
36
37
38# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
39# -----------------------------------------------------
c095d689 40# Output the definition of the tokens as enums.
cf147260 41m4_define([b4_token_enums],
cf147260
AD
42[/* Tokens. */
43 enum yytokentype {
44m4_map_sep([ b4_token_enum], [,
45],
46 [$@])
47 };
c095d689 48])
cf147260
AD
49
50
51## ----------------- ##
52## Semantic Values. ##
53## ----------------- ##
54
55
56# b4_lhs_value([TYPE])
57# --------------------
58# Expansion of $<TYPE>$.
59m4_define([b4_lhs_value],
60[(yyval[]m4_ifval([$1], [.$1]))])
61
62
63# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
64# --------------------------------------
65# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
66# symbols on RHS.
67m4_define([b4_rhs_value],
d1ff7a7c 68[(yysemantic_stack_@{($1) - ($2)@}m4_ifval([$3], [.$3]))])
cf147260
AD
69
70# b4_lhs_location()
71# -----------------
72# Expansion of @$.
73m4_define([b4_lhs_location],
74[(yyloc)])
75
76
77# b4_rhs_location(RULE-LENGTH, NUM)
78# ---------------------------------
79# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
80# on RHS.
81m4_define([b4_rhs_location],
d1ff7a7c 82[(yylocation_stack_@{($1) - ($2)@})])
cf147260
AD
83
84
85# b4_parse_param_decl
86# -------------------
87# Extra formal arguments of the constructor.
88# Change the parameter names from "foo" into "foo_yyarg", so that
89# there is no collision bw the user chosen attribute name, and the
90# argument name in the constructor.
91m4_define([b4_parse_param_decl],
92[m4_ifset([b4_parse_param],
93 [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
94
95m4_define([b4_parse_param_decl_1],
96[$1_yyarg])
97
98
99
100# b4_parse_param_cons
101# -------------------
102# Extra initialisations of the constructor.
103m4_define([b4_parse_param_cons],
104 [m4_ifset([b4_parse_param],
fa7b79c0 105 [
cf147260
AD
106 b4_cc_constructor_calls(b4_parse_param)])])
107m4_define([b4_cc_constructor_calls],
108 [m4_map_sep([b4_cc_constructor_call], [,
109 ], [$@])])
110m4_define([b4_cc_constructor_call],
111 [$2 ($2_yyarg)])
112
113# b4_parse_param_vars
114# -------------------
115# Extra instance variables.
116m4_define([b4_parse_param_vars],
117 [m4_ifset([b4_parse_param],
118 [
119 /* User arguments. */
120b4_cc_var_decls(b4_parse_param)])])
121m4_define([b4_cc_var_decls],
122 [m4_map_sep([b4_cc_var_decl], [
123], [$@])])
124m4_define([b4_cc_var_decl],
125 [ $1;])