]> git.saurik.com Git - bison.git/blame - data/c.m4
(strerror_r): Remove decl; not needed.
[bison.git] / data / c.m4
CommitLineData
fb8135fa
AD
1m4_divert(-1) -*- C -*-
2
3# C M4 Macros for Bison.
4# Copyright (C) 2002 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., 59 Temple Place, Suite 330, Boston, MA
19# 02111-1307 USA
20
21
22## ----------- ##
23## Copuright. ##
24## ----------- ##
25
26# b4_copyright(TITLE, YEARS)
27# --------------------------
28m4_define([b4_copyright],
29[/* A Bison parser, made from b4_filename, by GNU bison b4_version. */
30
31/* $1,
c76e14da 32 Copyright (C) $2 Free Software Foundation, Inc.
fb8135fa
AD
33
34 This program is free software; you can redistribute it and/or modify
35 it under the terms of the GNU General Public License as published by
36 the Free Software Foundation; either version 2, or (at your option)
37 any later version.
38
39 This program is distributed in the hope that it will be useful,
40 but WITHOUT ANY WARRANTY; without even the implied warranty of
41 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 GNU General Public License for more details.
43
44 You should have received a copy of the GNU General Public License
45 along with this program; if not, write to the Free Software
46 Foundation, Inc., 59 Temple Place - Suite 330,
47 Boston, MA 02111-1307, USA. */
48
49/* As a special exception, when this file is copied by Bison into a
50 Bison output file, you may use that output file without restriction.
51 This special exception was added by the Free Software Foundation
52 in version 1.24 of Bison. */])
53
54
55## ------------ ##
56## Data Types. ##
57## ------------ ##
58
fb8135fa 59
a762e609
AD
60# b4_ints_in(INT1, INT2, LOW, HIGH)
61# ---------------------------------
62# Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise.
63m4_define([b4_ints_in],
64[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
65
66
67# b4_int_type(MIN, MAX)
68# ---------------------
69# Return the smallest int type able to handle numbers ranging from
70# MIN to MAX (included).
71m4_define([b4_int_type],
72[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],
73 b4_ints_in($@, [-128], [128]), [1], [signed char],
74
75 b4_ints_in($@, [0], [65535]), [1], [unsigned short],
76 b4_ints_in($@, [-32768], [32767]), [1], [short],
77
78 m4_eval([0 <= $1]), [1], [unsigned int],
79
80 [int])])
81
82# b4_int_type_for(NAME)
83# ---------------------
84# Return the smallest int type able to handle numbers ranging from
85# `NAME_min' to `NAME_max' (included).
86m4_define([b4_int_type_for],
87[b4_int_type($1_min, $1_max)])
fb8135fa
AD
88
89
90## ------------------------- ##
91## Assigning token numbers. ##
92## ------------------------- ##
93
94# b4_token_define(TOKEN-NAME, TOKEN-NUMBER)
95# -----------------------------------------
96# Output the definition of this token as #define.
97m4_define([b4_token_define],
98[#define $1 $2
99])
100
101
102# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
103# ---------------------------------------
104# Output the definition of this token as an enum.
105m4_define([b4_token_enum],
106[$1 = $2])
107
108
109# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
110# -------------------------------------------------------
111# Output the definition of the tokens (if there are) as enums and #define.
112m4_define([b4_token_defines],
113[m4_if([$@], [[]], [],
114[/* Tokens. */
115#ifndef YYTOKENTYPE
116# if defined (__STDC__) || defined (__cplusplus)
117 /* Put the tokens into the symbol table, so that GDB and other debuggers
118 know about them. */
119 enum yytokentype {
120m4_map_sep([ b4_token_enum], [,
121],
122 [$@])
123 };
124# endif
125 /* POSIX requires `int' for tokens in interfaces. */
126# define YYTOKENTYPE int
127#endif /* !YYTOKENTYPE */
128m4_map([b4_token_define], [$@])
129])
130])
4a2a22f4
AD
131
132
133## ---------------------------------------------- ##
134## Declaring C functions in both K&R and ANSI-C. ##
135## ---------------------------------------------- ##
136
137
138# b4_c_function(NAME, RETURN-VALUE, [TYPE1, NAME1], ...)
139# ------------------------------------------------
140# Declare the function NAME.
141m4_define([b4_c_function],
142[$2
143#if defined (__STDC__) || defined (__cplusplus)
144$1 (b4_c_ansi_args(m4_shiftn(2, $@)))
145#else
146$1 (b4_c_knr_arg_names(m4_shiftn(2, $@)))
147b4_c_knr_arg_decls(m4_shiftn(2, $@))
148#endif[]dnl
149])
150
151
152# b4_c_ansi_args([TYPE1, NAME1], ...)
153# -----------------------------------
154# Output the arguments ANSI-C definition.
155m4_define([b4_c_ansi_args],
156[m4_map_sep([b4_c_ansi_arg], [, ], [$@])])
157
158m4_define([b4_c_ansi_arg],
159[$1 $2])
160
161
162# b4_c_knr_args([TYPE1, NAME1], ...)
163# ----------------------------------
164# Output the argument names.
165m4_define([b4_c_knr_arg_names],
166[m4_map_sep([b4_c_knr_arg_name], [, ], [$@])])
167
168m4_define([b4_c_knr_arg_name],
169[$2])
170
171
172# b4_c_knr_args([TYPE1, NAME1], ...)
173# ----------------------------------
174# Output the K&R argument declarations.
175m4_define([b4_c_knr_arg_decls],
176[m4_map_sep([b4_c_knr_arg_decl],
177 [
178],
179 [$@])])
180
181m4_define([b4_c_knr_arg_decl],
182[ $1 $2;])