1 | /* Common parts between scan-code.l, scan-gram.l, and scan-skel.l. |
2 | |
3 | Copyright (C) 2006, 2009-2015, 2018-2019 Free Software Foundation, |
4 | Inc. |
5 | |
6 | This file is part of Bison, the GNU Compiler Compiler. |
7 | |
8 | This program is free software: you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation, either version 3 of the License, or |
11 | (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
20 | |
21 | #ifndef FLEX_PREFIX |
22 | # error "FLEX_PREFIX not defined" |
23 | #endif |
24 | |
25 | /* Flex full version as a number. */ |
26 | #define FLEX_VERSION \ |
27 | ((YY_FLEX_MAJOR_VERSION) * 1000000 \ |
28 | + (YY_FLEX_MINOR_VERSION) * 1000 \ |
29 | + (YY_FLEX_SUBMINOR_VERSION)) |
30 | |
31 | // Pacify warnings in yy_init_buffer (observed with Flex 2.6.4 and GCC |
32 | // 6.4.0 and 7.3.0). |
33 | // |
34 | // ./src/scan-skel.c: In function 'skel_restart': |
35 | // ./src/scan-skel.c:2035:20: error: potential null pointer dereference [-Werror=null-dereference] |
36 | // b->yy_fill_buffer = 1; |
37 | // ~~~~~~~~~~~~~~~~~~^~~ |
38 | // ./src/scan-skel.c:2031:19: error: potential null pointer dereference [-Werror=null-dereference] |
39 | // b->yy_input_file = file; |
40 | // ~~~~~~~~~~~~~~~~~^~~~~~ |
41 | #if defined __GNUC__ && ! defined __clang__ && 6 <= __GNUC__ |
42 | # pragma GCC diagnostic ignored "-Wnull-dereference" |
43 | #endif |
44 | |
45 | // Old versions of Flex (2.5.35) generate an incomplete documentation comment. |
46 | // |
47 | // In file included from src/scan-code-c.c:3: |
48 | // src/scan-code.c:2198:21: error: empty paragraph passed to '@param' command |
49 | // [-Werror,-Wdocumentation] |
50 | // * @param line_number |
51 | // ~~~~~~~~~~~~~~~~~^ |
52 | // 1 error generated. |
53 | #if FLEX_VERSION <= 20060000 && defined __clang__ |
54 | # pragma clang diagnostic ignored "-Wdocumentation" |
55 | #endif |
56 | |
57 | /* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */ |
58 | #if FLEX_VERSION <= 2005031 |
59 | int FLEX_PREFIX (get_lineno) (void); |
60 | FILE *FLEX_PREFIX (get_in) (void); |
61 | FILE *FLEX_PREFIX (get_out) (void); |
62 | int FLEX_PREFIX (get_leng) (void); |
63 | char *FLEX_PREFIX (get_text) (void); |
64 | void FLEX_PREFIX (set_lineno) (int); |
65 | void FLEX_PREFIX (set_in) (FILE *); |
66 | void FLEX_PREFIX (set_out) (FILE *); |
67 | int FLEX_PREFIX (get_debug) (void); |
68 | void FLEX_PREFIX (set_debug) (int); |
69 | int FLEX_PREFIX (lex_destroy) (void); |
70 | #endif |
71 | |
72 | #define last_string FLEX_PREFIX (last_string) |
73 | |
74 | /* It seems to be a nice "feature" of Flex that one cannot use yytext, |
75 | yyleng etc. when a prefix is given, since there is no longer a |
76 | #define, but rather the token is actually changed in the output. |
77 | However, this is not true for Flex 2.5.4. */ |
78 | #ifndef yyleng |
79 | # define yyleng FLEX_PREFIX (leng) |
80 | #endif |
81 | #ifndef yytext |
82 | # define yytext FLEX_PREFIX (text) |
83 | #endif |
84 | |
85 | /* Non-reentrant scanners generated by Flex 2.5.9 and later (and some earlier |
86 | versions according to the Flex manual) leak memory if yylex_destroy is not |
87 | invoked. However, yylex_destroy is not defined before Flex 2.5.9, so give |
88 | an implementation here that at least appears to work with Flex 2.5.4. */ |
89 | #if FLEX_VERSION <= 2005009 |
90 | # define yylex_destroy() yy_delete_buffer (YY_CURRENT_BUFFER) |
91 | #endif |
92 | |
93 | /* OBSTACK_FOR_STRING -- Used to store all the characters that we need to |
94 | keep (to construct ID, STRINGS etc.). Use the following macros to |
95 | use it. |
96 | |
97 | Use STRING_GROW to append what has just been matched, and |
98 | STRING_FINISH to end the string (it puts the ending 0). |
99 | STRING_FINISH also stores this string in LAST_STRING, which can be |
100 | used, and which is used by STRING_FREE to free the last string. */ |
101 | |
102 | #ifndef FLEX_NO_OBSTACK |
103 | |
104 | static struct obstack obstack_for_string; |
105 | |
106 | # define STRING_GROW \ |
107 | obstack_grow (&obstack_for_string, yytext, yyleng) |
108 | |
109 | # define STRING_FINISH \ |
110 | (last_string = obstack_finish0 (&obstack_for_string)) |
111 | |
112 | # define STRING_FREE \ |
113 | obstack_free (&obstack_for_string, last_string) |
114 | |
115 | #endif |
116 | |