]> git.saurik.com Git - bison.git/blame - src/flex-scanner.h
maint: fix spaces.
[bison.git] / src / flex-scanner.h
CommitLineData
f9bfc42a 1/* Common parts between scan-code.l, scan-gram.l, and scan-skel.l.
9f936c5e 2
c932d613 3 Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
9f936c5e
AD
4
5 This file is part of Bison, the GNU Compiler Compiler.
6
f16b0819 7 This program is free software: you can redistribute it and/or modify
9f936c5e 8 it under the terms of the GNU General Public License as published by
f16b0819 9 the Free Software Foundation, either version 3 of the License, or
9f936c5e
AD
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
f16b0819 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
9f936c5e
AD
19
20#ifndef FLEX_PREFIX
21# error "FLEX_PREFIX not defined"
22#endif
23
86b08b49
AD
24/* Whether this version of Flex is (strictly) greater than
25 Major.Minor.Subminor. */
26#define FLEX_VERSION_GT(Major, Minor, Subminor) \
27 (defined YY_FLEX_MAJOR_VERSION \
28 && (Major < YY_FLEX_MAJOR_VERSION \
29 || (Major == YY_FLEX_MAJOR_VERSION \
30 && (defined YY_FLEX_MINOR_VERSION \
31 && (Minor < YY_FLEX_MINOR_VERSION \
32 || (Minor == YY_FLEX_MINOR_VERSION \
33 && defined YY_FLEX_SUBMINOR_VERSION \
34 && Subminor < YY_FLEX_SUBMINOR_VERSION))))))
35
9f936c5e 36/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */
86b08b49 37# if ! FLEX_VERSION_GT (2, 5, 31)
9f936c5e
AD
38int FLEX_PREFIX (get_lineno) (void);
39FILE *FLEX_PREFIX (get_in) (void);
40FILE *FLEX_PREFIX (get_out) (void);
41int FLEX_PREFIX (get_leng) (void);
42char *FLEX_PREFIX (get_text) (void);
43void FLEX_PREFIX (set_lineno) (int);
44void FLEX_PREFIX (set_in) (FILE *);
45void FLEX_PREFIX (set_out) (FILE *);
46int FLEX_PREFIX (get_debug) (void);
47void FLEX_PREFIX (set_debug) (int);
48int FLEX_PREFIX (lex_destroy) (void);
86b08b49 49#endif
9f936c5e
AD
50
51#define last_string FLEX_PREFIX (last_string)
52
53/* It seems to be a nice "feature" of Flex that one cannot use yytext,
54 yyleng etc. when a prefix is given, since there is no longer a
55 #define, but rather the token is actually changed in the output.
9e668899
JD
56 However, this is not true for Flex 2.5.4. */
57#ifndef yyleng
58# define yyleng FLEX_PREFIX (leng)
59#endif
60#ifndef yytext
3c40d0b5 61# define yytext FLEX_PREFIX (text)
9e668899 62#endif
9f936c5e 63
580b8926
JD
64/* Non-reentrant scanners generated by Flex 2.5.9 and later (and some earlier
65 versions according to the Flex manual) leak memory if yylex_destroy is not
66 invoked. However, yylex_destroy is not defined before Flex 2.5.9, so give
67 an implementation here that at least appears to work with Flex 2.5.4. */
86b08b49 68#if ! FLEX_VERSION_GT (2, 5, 9)
580b8926
JD
69# define yylex_destroy() yy_delete_buffer (YY_CURRENT_BUFFER)
70#endif
71
9f936c5e
AD
72/* OBSTACK_FOR_STRING -- Used to store all the characters that we need to
73 keep (to construct ID, STRINGS etc.). Use the following macros to
74 use it.
75
76 Use STRING_GROW to append what has just been matched, and
77 STRING_FINISH to end the string (it puts the ending 0).
78 STRING_FINISH also stores this string in LAST_STRING, which can be
79 used, and which is used by STRING_FREE to free the last string. */
80
f9bfc42a
JD
81#ifndef FLEX_NO_OBSTACK
82
9f936c5e
AD
83static struct obstack obstack_for_string;
84
08f6341c 85# define STRING_GROW \
9f936c5e
AD
86 obstack_grow (&obstack_for_string, yytext, yyleng)
87
08f6341c 88# define STRING_FINISH \
9f936c5e
AD
89 do { \
90 obstack_1grow (&obstack_for_string, '\0'); \
91 last_string = obstack_finish (&obstack_for_string); \
92 } while (0)
93
08f6341c 94# define STRING_FREE \
f2e690d8 95 obstack_free (&obstack_for_string, last_string)
f9bfc42a
JD
96
97#endif