]>
Commit | Line | Data |
---|---|---|
fb8135fa AD |
1 | m4_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 | # -------------------------- | |
28 | m4_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 | ||
59 | # b4_sint_type(MAX) | |
60 | # ----------------- | |
61 | # Return the smallest signed int type able to handle the number MAX. | |
62 | m4_define([b4_sint_type], | |
63 | [m4_if(m4_eval([$1 <= 127]), [1], [signed char], | |
64 | m4_eval([$1 <= 32767]), [1], [signed short], | |
65 | [signed int])]) | |
66 | ||
67 | ||
68 | # b4_uint_type(MAX) | |
69 | # ----------------- | |
70 | # Return the smallest unsigned int type able to handle the number MAX. | |
71 | m4_define([b4_uint_type], | |
72 | [m4_if(m4_eval([$1 <= 255]), [1], [unsigned char], | |
73 | m4_eval([$1 <= 65535]), [1], [unsigned short], | |
74 | [unsigned int])]) | |
75 | ||
76 | ||
77 | ||
78 | ## ------------------------- ## | |
79 | ## Assigning token numbers. ## | |
80 | ## ------------------------- ## | |
81 | ||
82 | # b4_token_define(TOKEN-NAME, TOKEN-NUMBER) | |
83 | # ----------------------------------------- | |
84 | # Output the definition of this token as #define. | |
85 | m4_define([b4_token_define], | |
86 | [#define $1 $2 | |
87 | ]) | |
88 | ||
89 | ||
90 | # b4_token_enum(TOKEN-NAME, TOKEN-NUMBER) | |
91 | # --------------------------------------- | |
92 | # Output the definition of this token as an enum. | |
93 | m4_define([b4_token_enum], | |
94 | [$1 = $2]) | |
95 | ||
96 | ||
97 | # b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) | |
98 | # ------------------------------------------------------- | |
99 | # Output the definition of the tokens (if there are) as enums and #define. | |
100 | m4_define([b4_token_defines], | |
101 | [m4_if([$@], [[]], [], | |
102 | [/* Tokens. */ | |
103 | #ifndef YYTOKENTYPE | |
104 | # if defined (__STDC__) || defined (__cplusplus) | |
105 | /* Put the tokens into the symbol table, so that GDB and other debuggers | |
106 | know about them. */ | |
107 | enum yytokentype { | |
108 | m4_map_sep([ b4_token_enum], [, | |
109 | ], | |
110 | [$@]) | |
111 | }; | |
112 | # endif | |
113 | /* POSIX requires `int' for tokens in interfaces. */ | |
114 | # define YYTOKENTYPE int | |
115 | #endif /* !YYTOKENTYPE */ | |
116 | m4_map([b4_token_define], [$@]) | |
117 | ]) | |
118 | ]) |