]> git.saurik.com Git - bison.git/blame - data/bison.m4
Add maintainer-push-check to run maintainer-check using push parsing in
[bison.git] / data / bison.m4
CommitLineData
90b9908d
PB
1m4_divert(-1) -*- Autoconf -*-
2
3# Language-independent M4 Macros for Bison.
945e396c 4# Copyright (C) 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
90b9908d
PB
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# --------------------------
28m4_define([b4_copyright],
29[b4_comment([A Bison parser, made by GNU Bison b4_version.])
30
31b4_comment([$1
32
33m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ])
34
35This program is free software; you can redistribute it and/or modify
36it under the terms of the GNU General Public License as published by
37the Free Software Foundation; either version 2, or (at your option)
38any later version.
39
40This program is distributed in the hope that it will be useful,
41but WITHOUT ANY WARRANTY; without even the implied warranty of
42MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43GNU General Public License for more details.
44
45You should have received a copy of the GNU General Public License
46along with this program; if not, write to the Free Software
47Foundation, Inc., 51 Franklin Street, Fifth Floor,
48Boston, MA 02110-1301, USA.])
49
50b4_comment([As a special exception, you may create a larger work that contains
51part or all of the Bison parser skeleton and distribute that work
52under terms of your choice, so long as that work isn't itself a
53parser generator using the skeleton or a modified version thereof
54as a parser skeleton. Alternatively, if you modify or redistribute
55the parser skeleton itself, you may (at your option) remove this
56special exception, which will cause the skeleton and the resulting
57Bison output files to be licensed under the GNU General Public
58License without this special exception.
59
60This special exception was added by the Free Software Foundation in
61version 2.2 of Bison.])])
62
63
64## ---------------- ##
65## Default values. ##
66## ---------------- ##
67
68# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
69m4_define_default([b4_epilogue], [])
70m4_define_default([b4_parse_param], [])
71
72# The initial column and line.
73m4_define_default([b4_location_initial_column], [1])
74m4_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.
84m4_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.
96m4_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.
107m4_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.
115m4_define([_b4_define_flag_if],
116[m4_if([$1$2], $[1]$[2], [],
117 [m4_fatal([$0: Invalid arguments: $@])])dnl
118m4_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.
125b4_define_flag_if([defines]) # Whether headers are requested.
126b4_define_flag_if([error_verbose]) # Whether error are verbose.
127b4_define_flag_if([glr]) # Whether a GLR parser is requested.
128b4_define_flag_if([locations]) # Whether locations are tracked.
129b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
7172e23e 130b4_define_flag_if([pull]) # Whether pull parsing is requested.
90b9908d 131b4_define_flag_if([pure]) # Whether the interface is pure.
7172e23e 132b4_define_flag_if([push]) # Whether push parsing is requested.
945e396c
JD
133b4_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.
90b9908d
PB
137b4_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.
153m4_define([b4_basename],
154[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])
155
156
157# b4_syncline(LINE, FILE)
158# -----------------------
159m4_define([b4_syncline],
160[b4_flag_if([synclines], [
161b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
162b4_sync_start([$1], [$2])])])
163
164m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
165m4_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.
170m4_define([b4_user_code],
171[$1
172b4_syncline([@oline@], [@ofile@])])
173
174
175# b4_define_user_code(MACRO)
176# --------------------------
177# From b4_MACRO, build b4_user_MACRO that includes the synclines.
178m4_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
136a0f76
PB
186# b4_user_pre_prologue
187# b4_user_provides
188# b4_user_requires
90b9908d
PB
189# b4_user_stype
190# ----------------------
191# Macros that issue user code, ending with synclines.
192b4_define_user_code([actions])
193b4_define_user_code([initial_action])
194b4_define_user_code([post_prologue])
136a0f76
PB
195b4_define_user_code([pre_prologue])
196b4_define_user_code([provides])
197b4_define_user_code([requires])
90b9908d
PB
198b4_define_user_code([stype])
199
200