]> git.saurik.com Git - bison.git/blob - data/bison.m4
Credit Satya for the graphviz change.
[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 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([pure]) # Whether the interface is pure.
131 b4_define_flag_if([push]) # Whether push parsing is supported.
132 b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
133
134
135 ## ------------------------- ##
136 ## Assigning token numbers. ##
137 ## ------------------------- ##
138
139
140 ## ----------- ##
141 ## Synclines. ##
142 ## ----------- ##
143
144 # b4_basename(NAME)
145 # -----------------
146 # Similar to POSIX basename; the differences don't matter here.
147 # Beware that NAME is not evaluated.
148 m4_define([b4_basename],
149 [m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])
150
151
152 # b4_syncline(LINE, FILE)
153 # -----------------------
154 m4_define([b4_syncline],
155 [b4_flag_if([synclines], [
156 b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
157 b4_sync_start([$1], [$2])])])
158
159 m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
160 m4_define([b4_sync_start], [b4_comment([Line $1 of $2])])
161
162 # b4_user_code(USER-CODE)
163 # -----------------------
164 # Emit code from the user, ending it with synclines.
165 m4_define([b4_user_code],
166 [$1
167 b4_syncline([@oline@], [@ofile@])])
168
169
170 # b4_define_user_code(MACRO)
171 # --------------------------
172 # From b4_MACRO, build b4_user_MACRO that includes the synclines.
173 m4_define([b4_define_user_code],
174 [m4_define([b4_user_$1],
175 [b4_user_code([b4_$1])])])
176
177
178 # b4_user_actions
179 # b4_user_initial_action
180 # b4_user_post_prologue
181 # b4_user_start_header
182 # b4_user_stype
183 # ----------------------
184 # Macros that issue user code, ending with synclines.
185 b4_define_user_code([actions])
186 b4_define_user_code([initial_action])
187 b4_define_user_code([post_prologue])
188 b4_define_user_code([start_header])
189 b4_define_user_code([stype])
190
191