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