]> git.saurik.com Git - bison.git/blame - data/c++.m4
* data/c.m4 (b4_token_enum): Always define the enum of tokens,
[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])
32
33
34
35# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
36# -----------------------------------------------------
c095d689 37# Output the definition of the tokens as enums.
cf147260 38m4_define([b4_token_enums],
cf147260
AD
39[/* Tokens. */
40 enum yytokentype {
41m4_map_sep([ b4_token_enum], [,
42],
43 [$@])
44 };
c095d689 45])
cf147260
AD
46
47
48## ----------------- ##
49## Semantic Values. ##
50## ----------------- ##
51
52
53# b4_lhs_value([TYPE])
54# --------------------
55# Expansion of $<TYPE>$.
56m4_define([b4_lhs_value],
57[(yyval[]m4_ifval([$1], [.$1]))])
58
59
60# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
61# --------------------------------------
62# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
63# symbols on RHS.
64m4_define([b4_rhs_value],
d1ff7a7c 65[(yysemantic_stack_@{($1) - ($2)@}m4_ifval([$3], [.$3]))])
cf147260
AD
66
67# b4_lhs_location()
68# -----------------
69# Expansion of @$.
70m4_define([b4_lhs_location],
71[(yyloc)])
72
73
74# b4_rhs_location(RULE-LENGTH, NUM)
75# ---------------------------------
76# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
77# on RHS.
78m4_define([b4_rhs_location],
d1ff7a7c 79[(yylocation_stack_@{($1) - ($2)@})])
cf147260
AD
80
81
82# b4_parse_param_decl
83# -------------------
84# Extra formal arguments of the constructor.
85# Change the parameter names from "foo" into "foo_yyarg", so that
86# there is no collision bw the user chosen attribute name, and the
87# argument name in the constructor.
88m4_define([b4_parse_param_decl],
89[m4_ifset([b4_parse_param],
90 [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
91
92m4_define([b4_parse_param_decl_1],
93[$1_yyarg])
94
95
96
97# b4_parse_param_cons
98# -------------------
99# Extra initialisations of the constructor.
100m4_define([b4_parse_param_cons],
101 [m4_ifset([b4_parse_param],
102 [,
103 b4_cc_constructor_calls(b4_parse_param)])])
104m4_define([b4_cc_constructor_calls],
105 [m4_map_sep([b4_cc_constructor_call], [,
106 ], [$@])])
107m4_define([b4_cc_constructor_call],
108 [$2 ($2_yyarg)])
109
110# b4_parse_param_vars
111# -------------------
112# Extra instance variables.
113m4_define([b4_parse_param_vars],
114 [m4_ifset([b4_parse_param],
115 [
116 /* User arguments. */
117b4_cc_var_decls(b4_parse_param)])])
118m4_define([b4_cc_var_decls],
119 [m4_map_sep([b4_cc_var_decl], [
120], [$@])])
121m4_define([b4_cc_var_decl],
122 [ $1;])