]> git.saurik.com Git - bison.git/blob - data/bison.m4
Add maintainer-push-check to run maintainer-check using push parsing in
[bison.git] / data / bison.m4
1 m4_divert(-1) -*- Autoconf -*-
2
3 # Language-independent M4 Macros for Bison.
4 # Copyright (C) 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301 USA
20
21
22 ## ---------------- ##
23 ## Identification. ##
24 ## ---------------- ##
25
26 # b4_copyright(TITLE, YEARS)
27 # --------------------------
28 m4_define([b4_copyright],
29 [b4_comment([A Bison parser, made by GNU Bison b4_version.])
30
31 b4_comment([$1
32
33 m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ])
34
35 This program is free software; you can redistribute it and/or modify
36 it under the terms of the GNU General Public License as published by
37 the Free Software Foundation; either version 2, or (at your option)
38 any later version.
39
40 This program is distributed in the hope that it will be useful,
41 but WITHOUT ANY WARRANTY; without even the implied warranty of
42 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 GNU General Public License for more details.
44
45 You should have received a copy of the GNU General Public License
46 along with this program; if not, write to the Free Software
47 Foundation, Inc., 51 Franklin Street, Fifth Floor,
48 Boston, MA 02110-1301, USA.])
49
50 b4_comment([As a special exception, you may create a larger work that contains
51 part or all of the Bison parser skeleton and distribute that work
52 under terms of your choice, so long as that work isn't itself a
53 parser generator using the skeleton or a modified version thereof
54 as a parser skeleton. Alternatively, if you modify or redistribute
55 the parser skeleton itself, you may (at your option) remove this
56 special exception, which will cause the skeleton and the resulting
57 Bison output files to be licensed under the GNU General Public
58 License without this special exception.
59
60 This special exception was added by the Free Software Foundation in
61 version 2.2 of Bison.])])
62
63
64 ## ---------------- ##
65 ## Default values. ##
66 ## ---------------- ##
67
68 # m4_define_default([b4_lex_param], []) dnl breaks other skeletons
69 m4_define_default([b4_epilogue], [])
70 m4_define_default([b4_parse_param], [])
71
72 # The initial column and line.
73 m4_define_default([b4_location_initial_column], [1])
74 m4_define_default([b4_location_initial_line], [1])
75
76
77 ## ------------ ##
78 ## Data Types. ##
79 ## ------------ ##
80
81 # b4_ints_in(INT1, INT2, LOW, HIGH)
82 # ---------------------------------
83 # Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise.
84 m4_define([b4_ints_in],
85 [m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
86
87
88
89 ## ------------------ ##
90 ## Decoding options. ##
91 ## ------------------ ##
92
93 # b4_flag_if(FLAG, IF-TRUE, IF-FALSE)
94 # -----------------------------------
95 # Run IF-TRUE if b4_FLAG_flag is 1, IF-FALSE if FLAG is 0, otherwise fail.
96 m4_define([b4_flag_if],
97 [m4_case(b4_$1_flag,
98 [0], [$3],
99 [1], [$2],
100 [m4_fatal([invalid $1 value: ]$1)])])
101
102
103 # b4_define_flag_if(FLAG)
104 # -----------------------
105 # Define "b4_FLAG_if(IF-TRUE, IF-FALSE)" that depends on the
106 # value of the Boolean FLAG.
107 m4_define([b4_define_flag_if],
108 [_b4_define_flag_if($[1], $[2], [$1])])
109
110 # _b4_define_flag_if($1, $2, FLAG)
111 # --------------------------------
112 # This macro works around the impossibility to define macros
113 # inside macros, because issuing `[$1]' is not possible in M4 :(.
114 # This sucks hard, GNU M4 should really provide M5 like $$1.
115 m4_define([_b4_define_flag_if],
116 [m4_if([$1$2], $[1]$[2], [],
117 [m4_fatal([$0: Invalid arguments: $@])])dnl
118 m4_define([b4_$3_if],
119 [b4_flag_if([$3], [$1], [$2])])])
120
121
122 # b4_FLAG_if(IF-TRUE, IF-FALSE)
123 # -----------------------------
124 # Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
125 b4_define_flag_if([defines]) # Whether headers are requested.
126 b4_define_flag_if([error_verbose]) # Whether error are verbose.
127 b4_define_flag_if([glr]) # Whether a GLR parser is requested.
128 b4_define_flag_if([locations]) # Whether locations are tracked.
129 b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
130 b4_define_flag_if([pull]) # Whether pull parsing is requested.
131 b4_define_flag_if([pure]) # Whether the interface is pure.
132 b4_define_flag_if([push]) # Whether push parsing is requested.
133 b4_define_flag_if([use_push_for_pull]) # Whether push parsing should be used
134 # in place of pull parsing (where
135 # available) for the sake of the test
136 # suite.
137 b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
138
139
140 ## ------------------------- ##
141 ## Assigning token numbers. ##
142 ## ------------------------- ##
143
144
145 ## ----------- ##
146 ## Synclines. ##
147 ## ----------- ##
148
149 # b4_basename(NAME)
150 # -----------------
151 # Similar to POSIX basename; the differences don't matter here.
152 # Beware that NAME is not evaluated.
153 m4_define([b4_basename],
154 [m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])
155
156
157 # b4_syncline(LINE, FILE)
158 # -----------------------
159 m4_define([b4_syncline],
160 [b4_flag_if([synclines], [
161 b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
162 b4_sync_start([$1], [$2])])])
163
164 m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
165 m4_define([b4_sync_start], [b4_comment([Line $1 of $2])])
166
167 # b4_user_code(USER-CODE)
168 # -----------------------
169 # Emit code from the user, ending it with synclines.
170 m4_define([b4_user_code],
171 [$1
172 b4_syncline([@oline@], [@ofile@])])
173
174
175 # b4_define_user_code(MACRO)
176 # --------------------------
177 # From b4_MACRO, build b4_user_MACRO that includes the synclines.
178 m4_define([b4_define_user_code],
179 [m4_define([b4_user_$1],
180 [b4_user_code([b4_$1])])])
181
182
183 # b4_user_actions
184 # b4_user_initial_action
185 # b4_user_post_prologue
186 # b4_user_pre_prologue
187 # b4_user_provides
188 # b4_user_requires
189 # b4_user_stype
190 # ----------------------
191 # Macros that issue user code, ending with synclines.
192 b4_define_user_code([actions])
193 b4_define_user_code([initial_action])
194 b4_define_user_code([post_prologue])
195 b4_define_user_code([pre_prologue])
196 b4_define_user_code([provides])
197 b4_define_user_code([requires])
198 b4_define_user_code([stype])
199
200