]> git.saurik.com Git - bison.git/blame - data/c++.m4
* bootstrap: Remove occurrences of .#bootmp from lib/Makefile.
[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
AD
7
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12
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.
17
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21# 02110-1301 USA
22
3953ed88
AD
23m4_include(b4_pkgdatadir/[c.m4])
24
cf147260
AD
25## ---------------- ##
26## Default values. ##
27## ---------------- ##
28
29# Default parser class name.
a4e25e1d
JD
30b4_percent_define_default([[parser_class_name]], [[parser]])
31b4_percent_define_default([[location_type]], [[location]])
32b4_percent_define_default([[filename_type]], [[std::string]])
33b4_percent_define_default([[namespace]], m4_defn([b4_prefix]))
c1d19e10 34b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
a4e25e1d
JD
35b4_percent_define_default([[define_location_comparison]],
36 [m4_if(b4_percent_define_get([[filename_type]]),
c1d19e10 37 [std::string], [[true]], [[false]])])
cf147260
AD
38
39
40# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
41# -----------------------------------------------------
c095d689 42# Output the definition of the tokens as enums.
cf147260 43m4_define([b4_token_enums],
cf147260
AD
44[/* Tokens. */
45 enum yytokentype {
46m4_map_sep([ b4_token_enum], [,
47],
48 [$@])
49 };
c095d689 50])
cf147260
AD
51
52
53## ----------------- ##
54## Semantic Values. ##
55## ----------------- ##
56
57
58# b4_lhs_value([TYPE])
59# --------------------
60# Expansion of $<TYPE>$.
61m4_define([b4_lhs_value],
62[(yyval[]m4_ifval([$1], [.$1]))])
63
64
65# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
66# --------------------------------------
67# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
68# symbols on RHS.
69m4_define([b4_rhs_value],
d1ff7a7c 70[(yysemantic_stack_@{($1) - ($2)@}m4_ifval([$3], [.$3]))])
cf147260
AD
71
72# b4_lhs_location()
73# -----------------
74# Expansion of @$.
75m4_define([b4_lhs_location],
76[(yyloc)])
77
78
79# b4_rhs_location(RULE-LENGTH, NUM)
80# ---------------------------------
81# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
82# on RHS.
83m4_define([b4_rhs_location],
d1ff7a7c 84[(yylocation_stack_@{($1) - ($2)@})])
cf147260
AD
85
86
87# b4_parse_param_decl
88# -------------------
89# Extra formal arguments of the constructor.
90# Change the parameter names from "foo" into "foo_yyarg", so that
91# there is no collision bw the user chosen attribute name, and the
92# argument name in the constructor.
93m4_define([b4_parse_param_decl],
94[m4_ifset([b4_parse_param],
95 [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
96
97m4_define([b4_parse_param_decl_1],
98[$1_yyarg])
99
100
101
102# b4_parse_param_cons
103# -------------------
104# Extra initialisations of the constructor.
105m4_define([b4_parse_param_cons],
106 [m4_ifset([b4_parse_param],
fa7b79c0 107 [
cf147260
AD
108 b4_cc_constructor_calls(b4_parse_param)])])
109m4_define([b4_cc_constructor_calls],
110 [m4_map_sep([b4_cc_constructor_call], [,
111 ], [$@])])
112m4_define([b4_cc_constructor_call],
113 [$2 ($2_yyarg)])
114
115# b4_parse_param_vars
116# -------------------
117# Extra instance variables.
118m4_define([b4_parse_param_vars],
119 [m4_ifset([b4_parse_param],
120 [
121 /* User arguments. */
122b4_cc_var_decls(b4_parse_param)])])
123m4_define([b4_cc_var_decls],
124 [m4_map_sep([b4_cc_var_decl], [
125], [$@])])
126m4_define([b4_cc_var_decl],
127 [ $1;])