3 * Copyright (C) 2003 Lars Knoll (knoll\@kde.org)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 /* This file is mostly data generated by flex. Unfortunately flex
23 can't handle 16bit strings directly, so we just copy the part of
24 the code we need and modify it to our needs.
26 Most of the defines below are to make sure we can easily use the
27 flex generated code, using as little editing as possible.
29 The flex syntax to generate the lexer are more or less directly
30 copied from the CSS2.1 specs, with some fixes for comments and
33 To regenerate, run flex on tokenizer.flex. After this, copy the
34 data tables and the YY_DECL method over to this file. Remove the
35 init code from YY_DECL and change the YY_END_OF_BUFFER to only call
40 // --------- begin generated code -------------------
47 #include "CSSGrammar.h"
53 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
55 #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
57 typedef int8_t flex_int8_t;
58 typedef uint8_t flex_uint8_t;
59 typedef int16_t flex_int16_t;
60 typedef uint16_t flex_uint16_t;
61 typedef int32_t flex_int32_t;
62 typedef uint32_t flex_uint32_t;
64 typedef signed char flex_int8_t;
65 typedef short int flex_int16_t;
66 typedef int flex_int32_t;
67 typedef unsigned char flex_uint8_t;
68 typedef unsigned short int flex_uint16_t;
69 typedef unsigned int flex_uint32_t;
74 # Skip over the flex output prologue: the above typedefs, forward declarations, etc.
75 # Stop when we get to the declarations of tables.
77 last if /YY_NUM_RULES/;
80 # Dump the generated tables. /yy_last_accepting/ matches the first declaration after the tables.
83 last if /yy_last_accepting/;
87 # Skip down the the declaration of yytext; the body of the flex output begins after it.
91 # Dump the definitions of states (INITIAL, media query, tokenizer state support).
93 last if not (/define/ || /line/) ;
97 # Skip to main scanner function.
102 # Dump main scanner declarations, substituting in our 16-bit character type.
103 # Declarations end with the declaration matching /yy_act/.
111 # Skip past initialization code, down to main loop.
113 last if /while \( 1 \)/;
116 # Dump the main loop, skipping over labels we don't use.
117 # Stop before dumping the end-of-buffer handling, because we output our own custom end-of-buffer handling.
120 next if /^yy_match:/;
121 next if /^do_action:/;
122 last if /YY_END_OF_BUFFER/;
123 if (/^case YY_STATE_EOF\(INITIAL\):/) {
124 print "case YY_END_OF_BUFFER:\n";
125 # flex outputs a ton of logic related to end-of-buffer handling; we just want to fall through to
126 # the yyterminate() found in other EOF states. But we need to be careful to back up to behind
127 # the terminating double-NUL so that subsequent calls to flex will have the pointers in order,
128 # so this logic is a reduction of the normal flex-generated YY_END_OF_BUFFER code.
129 print "\tyy_c_buf_p = yy_cp - 1;\n";
130 print "\tyy_cp = yy_c_buf_p;\n";
135 # Skip over the end-of-buffer handling; dump the rest of the function.
142 last if /end of yylex/;
145 # We don't want the remainder of flex's output.
146 # However, flex may choke with "flex: error writing output file <stdout>"
147 # if its stdout is unexpectedly closed on it.
148 # Consume the remaining output.