OSDN Git Service

am 3c54ece0: am 5dc34a85: activeDocumentLoader() causes crash in WebCoreFrameBridge.cpp
[android-x86/external-webkit.git] / WebCore / css / maketokenizer
1 print <<END;
2 /*
3  * Copyright (C) 2003 Lars Knoll (knoll\@kde.org)
4  *
5  *
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.
10  *
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.
15  *
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.
20  */
21
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.
25
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.
28
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
31    the important symbol.
32
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
36    yyterminate().
37
38 */
39
40 // --------- begin generated code -------------------
41
42 END
43
44 {
45 print<<END
46
47 #include "CSSGrammar.h"
48
49 #define INITIAL 0
50 #define mediaquery 1
51 #define forkeyword 2
52
53 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
54
55 #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
56 #include <inttypes.h>
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;
63 #else
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;
70 #endif /* ! C99 */
71 END
72 }
73
74 # Skip over the flex output prologue: the above typedefs, forward declarations, etc.
75 # Stop when we get to the declarations of tables.
76 while (<>) {
77     last if /YY_NUM_RULES/;
78 }
79
80 # Dump the generated tables.  /yy_last_accepting/ matches the first declaration after the tables.
81 print;
82 while (<>) {
83     last if /yy_last_accepting/;
84     print;
85 }
86
87 # Skip down the the declaration of yytext; the body of the flex output begins after it.
88 while (<>) {
89   last if /yytext/;
90 }
91 # Dump the definitions of states (INITIAL, media query, tokenizer state support).
92 while (<>) {
93   last if not (/define/ || /line/) ;
94   print;
95 }
96
97 # Skip to main scanner function.
98 while (<>) {
99     last if /^YY_DECL/;
100 }
101
102 # Dump main scanner declarations, substituting in our 16-bit character type.
103 # Declarations end with the declaration matching /yy_act/.
104 print;
105 while (<>) {
106     s/char/UChar/;
107     print;
108     last if /yy_act/;
109 }
110
111 # Skip past initialization code, down to main loop.
112 while (<>) {
113     last if /while \( 1 \)/;
114 }
115
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.
118 print;
119 while (<>) {
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";
131     }
132     print;
133 }
134
135 # Skip over the end-of-buffer handling; dump the rest of the function.
136 while (<>) {
137     last if /default:/;
138 }
139 print;
140 while (<>) {
141     print;
142     last if /end of yylex/;
143 }
144
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.
149 while (<>) {
150 }