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