]> git.saurik.com Git - bison.git/blame - data/c++.m4
Update to latest gnulib and gettext versions.
[bison.git] / data / c++.m4
CommitLineData
d4fb5e3c 1m4_divert(-1) -*- Autoconf -*-
cf147260
AD
2
3# C++ skeleton for Bison
4
3953ed88 5# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
cf147260
AD
6
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.
11
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.
16
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
20# 02110-1301 USA
21
3953ed88
AD
22m4_include(b4_pkgdatadir/[c.m4])
23
cf147260
AD
24## ---------------- ##
25## Default values. ##
26## ---------------- ##
27
28# Default parser class name.
29m4_define_default([b4_parser_class_name], [parser])
30m4_define_default([b4_location_type], [location])
31m4_define_default([b4_filename_type], [std::string])
aa08666d 32m4_define_default([b4_namespace], m4_defn([b4_prefix]))
31b2b07e
JD
33m4_define_default([b4_define_location_comparison],
34 m4_if(b4_filename_type, [std::string], [1], [0]))
cf147260
AD
35
36
37# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
38# -----------------------------------------------------
c095d689 39# Output the definition of the tokens as enums.
cf147260 40m4_define([b4_token_enums],
cf147260
AD
41[/* Tokens. */
42 enum yytokentype {
43m4_map_sep([ b4_token_enum], [,
44],
45 [$@])
46 };
c095d689 47])
cf147260
AD
48
49
50## ----------------- ##
51## Semantic Values. ##
52## ----------------- ##
53
54
55# b4_lhs_value([TYPE])
56# --------------------
57# Expansion of $<TYPE>$.
58m4_define([b4_lhs_value],
59[(yyval[]m4_ifval([$1], [.$1]))])
60
61
62# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
63# --------------------------------------
64# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
65# symbols on RHS.
66m4_define([b4_rhs_value],
d1ff7a7c 67[(yysemantic_stack_@{($1) - ($2)@}m4_ifval([$3], [.$3]))])
cf147260
AD
68
69# b4_lhs_location()
70# -----------------
71# Expansion of @$.
72m4_define([b4_lhs_location],
73[(yyloc)])
74
75
76# b4_rhs_location(RULE-LENGTH, NUM)
77# ---------------------------------
78# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
79# on RHS.
80m4_define([b4_rhs_location],
d1ff7a7c 81[(yylocation_stack_@{($1) - ($2)@})])
cf147260
AD
82
83
84# b4_parse_param_decl
85# -------------------
86# Extra formal arguments of the constructor.
87# Change the parameter names from "foo" into "foo_yyarg", so that
88# there is no collision bw the user chosen attribute name, and the
89# argument name in the constructor.
90m4_define([b4_parse_param_decl],
91[m4_ifset([b4_parse_param],
92 [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
93
94m4_define([b4_parse_param_decl_1],
95[$1_yyarg])
96
97
98
99# b4_parse_param_cons
100# -------------------
101# Extra initialisations of the constructor.
102m4_define([b4_parse_param_cons],
103 [m4_ifset([b4_parse_param],
104 [,
105 b4_cc_constructor_calls(b4_parse_param)])])
106m4_define([b4_cc_constructor_calls],
107 [m4_map_sep([b4_cc_constructor_call], [,
108 ], [$@])])
109m4_define([b4_cc_constructor_call],
110 [$2 ($2_yyarg)])
111
112# b4_parse_param_vars
113# -------------------
114# Extra instance variables.
115m4_define([b4_parse_param_vars],
116 [m4_ifset([b4_parse_param],
117 [
118 /* User arguments. */
119b4_cc_var_decls(b4_parse_param)])])
120m4_define([b4_cc_var_decls],
121 [m4_map_sep([b4_cc_var_decl], [
122], [$@])])
123m4_define([b4_cc_var_decl],
124 [ $1;])