1 /* Common parts between scan-code.l and scan-gram.l.
3 Copyright (C) 2006 Free Software Foundation, Inc.
5 This file is part of Bison, the GNU Compiler Compiler.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 # error "FLEX_PREFIX not defined"
29 /* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */
30 int FLEX_PREFIX (get_lineno
) (void);
31 FILE *FLEX_PREFIX (get_in
) (void);
32 FILE *FLEX_PREFIX (get_out
) (void);
33 int FLEX_PREFIX (get_leng
) (void);
34 char *FLEX_PREFIX (get_text
) (void);
35 void FLEX_PREFIX (set_lineno
) (int);
36 void FLEX_PREFIX (set_in
) (FILE *);
37 void FLEX_PREFIX (set_out
) (FILE *);
38 int FLEX_PREFIX (get_debug
) (void);
39 void FLEX_PREFIX (set_debug
) (int);
40 int FLEX_PREFIX (lex_destroy
) (void);
42 #define last_string FLEX_PREFIX (last_string)
44 /* It seems to be a nice "feature" of Flex that one cannot use yytext,
45 yyleng etc. when a prefix is given, since there is no longer a
46 #define, but rather the token is actually changed in the output.
48 #define yyleng FLEX_PREFIX (leng)
49 #define yytext FLEX_PREFIX (text)
51 /* OBSTACK_FOR_STRING -- Used to store all the characters that we need to
52 keep (to construct ID, STRINGS etc.). Use the following macros to
55 Use STRING_GROW to append what has just been matched, and
56 STRING_FINISH to end the string (it puts the ending 0).
57 STRING_FINISH also stores this string in LAST_STRING, which can be
58 used, and which is used by STRING_FREE to free the last string. */
60 static struct obstack obstack_for_string
;
63 obstack_grow (&obstack_for_string, yytext, yyleng)
65 #define STRING_FINISH \
67 obstack_1grow (&obstack_for_string, '\0'); \
68 last_string = obstack_finish (&obstack_for_string); \
72 obstack_free (&obstack_for_string, FLEX_PREFIX (last_string))