Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: src/lexer/lexer_py.re

Issue 66533002: Experimental parser: better generation (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/lexer_generator/generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 the V8 project authors. All rights reserved. 1 # Copyright 2013 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 "-" { PUSH_TOKEN(SUB); } 94 "-" { PUSH_TOKEN(SUB); }
95 "*" { PUSH_TOKEN(MUL); } 95 "*" { PUSH_TOKEN(MUL); }
96 "/" { PUSH_TOKEN(DIV); } 96 "/" { PUSH_TOKEN(DIV); }
97 "%" { PUSH_TOKEN(MOD); } 97 "%" { PUSH_TOKEN(MOD); }
98 "~" { PUSH_TOKEN(BIT_NOT); } 98 "~" { PUSH_TOKEN(BIT_NOT); }
99 "," { PUSH_TOKEN(COMMA); } 99 "," { PUSH_TOKEN(COMMA); }
100 100
101 line_terminator+ { PUSH_LINE_TERMINATOR(); } 101 line_terminator+ { PUSH_LINE_TERMINATOR(); }
102 whitespace <<continue>> 102 whitespace <<continue>>
103 103
104 "\"" <<DoubleQuoteString>> # TODO mark these transitions as ignoring t his character 104 "\"" <<DoubleQuoteString>>
105 "'" <<SingleQuoteString>> 105 "'" <<SingleQuoteString>>
106 106
107 identifier_start <<Identifier>> # TODO merge identifier dfa... 107 # all keywords
108 "break" { PUSH_TOKEN(BREAK); } <<break>>
109 "case" { PUSH_TOKEN(CASE); } <<break>>
110 "catch" { PUSH_TOKEN(CATCH); } <<break>>
111 "class" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
112 "const" { PUSH_TOKEN(CONST); } <<break>>
113 "continue" { PUSH_TOKEN(CONTINUE); } <<break>>
114 "debugger" { PUSH_TOKEN(DEBUGGER); } <<break>>
115 "default" { PUSH_TOKEN(DEFAULT); } <<break>>
116 "delete" { PUSH_TOKEN(DELETE); } <<break>>
117 "do" { PUSH_TOKEN(DO); } <<break>>
118 "else" { PUSH_TOKEN(ELSE); } <<break>>
119 "enum" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
120 "export" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
121 "extends" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
122 "false" { PUSH_TOKEN(FALSE_LITERAL); } <<break>>
123 "finally" { PUSH_TOKEN(FINALLY); } <<break>>
124 "for" { PUSH_TOKEN(FOR); } <<break>>
125 "function" { PUSH_TOKEN(FUNCTION); } <<break>>
126 "if" { PUSH_TOKEN(IF); } <<break>>
127 "implements" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
128 "import" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
129 "in" { PUSH_TOKEN(IN); } <<break>>
130 "instanceof" { PUSH_TOKEN(INSTANCEOF); } <<break>>
131 "interface" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
132 "let" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
133 "new" { PUSH_TOKEN(NEW); } <<break>>
134 "null" { PUSH_TOKEN(NULL_LITERAL); } <<break>>
135 "package" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
136 "private" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
137 "protected" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
138 "public" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
139 "return" { PUSH_TOKEN(RETURN); } <<break>>
140 "static" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
141 "super" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
142 "switch" { PUSH_TOKEN(SWITCH); } <<break>>
143 "this" { PUSH_TOKEN(THIS); } <<break>>
144 "throw" { PUSH_TOKEN(THROW); } <<break>>
145 "true" { PUSH_TOKEN(TRUE_LITERAL); } <<break>>
146 "try" { PUSH_TOKEN(TRY); } <<break>>
147 "typeof" { PUSH_TOKEN(TYPEOF); } <<break>>
148 "var" { PUSH_TOKEN(VAR); } <<break>>
149 "void" { PUSH_TOKEN(VOID); } <<break>>
150 "while" { PUSH_TOKEN(WHILE); } <<break>>
151 "with" { PUSH_TOKEN(WITH); } <<break>>
152 "yield" { PUSH_TOKEN(YIELD); } <<break>>
153
154 identifier_start <<Identifier>>
108 /\\u[0-9a-fA-F]{4}/ { 155 /\\u[0-9a-fA-F]{4}/ {
109 if (V8_LIKELY(ValidIdentifierStart())) { 156 if (V8_LIKELY(ValidIdentifierStart())) {
110 JUMP(Identifier); 157 JUMP(Identifier);
111 } 158 }
112 PUSH_TOKEN(ILLEGAL); 159 PUSH_TOKEN(ILLEGAL);
113 } 160 } <<Identifier>>
114 161
115 eof <<terminate>> 162 eof <<terminate>>
116 default { PUSH_TOKEN(ILLEGAL); } 163 default { PUSH_TOKEN(ILLEGAL); }
117 164
118 <DoubleQuoteString> 165 <DoubleQuoteString>
119 "\\" <<continue>> 166 "\\" <<continue>>
120 "\\\"" <<continue>> 167 "\\\"" <<continue>>
121 "\"" { PUSH_TOKEN(STRING); } <<break>> 168 "\"" { PUSH_TOKEN(STRING); } <<break>>
122 /\\\n\r?/ <<continue>> 169 /\\\n\r?/ <<continue>>
123 /\\\r\n?/ <<continue>> 170 /\\\r\n?/ <<continue>>
124 /\n\r/ { PUSH_TOKEN(ILLEGAL); } <<break>> 171 /\n|\r/ { PUSH_TOKEN(ILLEGAL); } <<break>>
125 eof <<terminate_illegal>> 172 eof <<terminate_illegal>>
126 default <<continue>> 173 default <<continue>>
127 174
128 <SingleQuoteString> 175 <SingleQuoteString>
129 "\\" <<continue>> 176 "\\" <<continue>>
130 "\\'" <<continue>> 177 "\\'" <<continue>>
131 "'" { PUSH_TOKEN(STRING); } <<break>> 178 "'" { PUSH_TOKEN(STRING); } <<break>>
132 /\\\n\r?/ <<continue>> 179 /\\\n\r?/ <<continue>>
133 /\\\r\n?/ <<continue>> 180 /\\\r\n?/ <<continue>>
134 /\n\r/ { PUSH_TOKEN(ILLEGAL); } <<break>> 181 /\n|\r/ { PUSH_TOKEN(ILLEGAL); } <<break>>
135 eof <<terminate_illegal>> 182 eof <<terminate_illegal>>
136 default <<continue>> 183 default <<continue>>
137 184
138 <Identifier> 185 <Identifier>
139 identifier_char+ <<continue>> 186 identifier_char+ <<continue>>
140 /\\u[0-9a-fA-F]{4}/ { 187 /\\u[0-9a-fA-F]{4}/ {
141 if (V8_UNLIKELY(!ValidIdentifierStart())) { 188 if (V8_UNLIKELY(!ValidIdentifierStart())) {
142 PUSH_TOKEN(ILLEGAL); 189 PUSH_TOKEN(ILLEGAL);
143 JUMP(Normal); 190 JUMP(Normal);
144 } 191 }
145 } 192 }
146 default { PUSH_TOKEN(IDENTIFIER); } <<break>> 193 default { PUSH_TOKEN(IDENTIFIER); } <<break>>
147 194
148 <SingleLineComment> 195 <SingleLineComment>
149 line_terminator { PUSH_LINE_TERMINATOR(); } <<break>> 196 line_terminator { PUSH_LINE_TERMINATOR(); } <<break>>
150 eof <<terminate>> 197 eof <<terminate>>
151 default <<continue>> 198 default <<continue>>
152 199
153 <MultiLineComment> 200 <MultiLineComment>
154 "*/" <<break>> 201 "*/" <<break>>
155 line_terminator+ { PUSH_LINE_TERMINATOR(); } 202 line_terminator+ { PUSH_LINE_TERMINATOR(); }
156 eof <<terminate>> 203 eof <<terminate>>
157 default <<continue>> 204 default <<continue>>
158 205
159 <HtmlComment> 206 <HtmlComment>
160 "-->" <<break>> 207 "-->" <<break>>
161 line_terminator+ { PUSH_LINE_TERMINATOR(); } 208 line_terminator+ { PUSH_LINE_TERMINATOR(); }
162 eof <<terminate>> 209 eof <<terminate>>
163 default <<continue>> 210 default <<continue>>
164
165 <default>
166 # all keywords
167 "break" { PUSH_TOKEN(BREAK); } <<break>>
168 "case" { PUSH_TOKEN(CASE); } <<break>>
169 "catch" { PUSH_TOKEN(CATCH); } <<break>>
170 "class" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
171 "const" { PUSH_TOKEN(CONST); } <<break>>
172 "continue" { PUSH_TOKEN(CONTINUE); } <<break>>
173 "debugger" { PUSH_TOKEN(DEBUGGER); } <<break>>
174 "default" { PUSH_TOKEN(DEFAULT); } <<break>>
175 "delete" { PUSH_TOKEN(DELETE); } <<break>>
176 "do" { PUSH_TOKEN(DO); } <<break>>
177 "else" { PUSH_TOKEN(ELSE); } <<break>>
178 "enum" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
179 "export" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
180 "extends" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
181 "false" { PUSH_TOKEN(FALSE_LITERAL); } <<break>>
182 "finally" { PUSH_TOKEN(FINALLY); } <<break>>
183 "for" { PUSH_TOKEN(FOR); } <<break>>
184 "function" { PUSH_TOKEN(FUNCTION); } <<break>>
185 "if" { PUSH_TOKEN(IF); } <<break>>
186 "implements" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
187 "import" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
188 "in" { PUSH_TOKEN(IN); } <<break>>
189 "instanceof" { PUSH_TOKEN(INSTANCEOF); } <<break>>
190 "interface" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
191 "let" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
192 "new" { PUSH_TOKEN(NEW); } <<break>>
193 "null" { PUSH_TOKEN(NULL_LITERAL); } <<break>>
194 "package" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
195 "private" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
196 "protected" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
197 "public" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
198 "return" { PUSH_TOKEN(RETURN); } <<break>>
199 "static" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>>
200 "super" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>>
201 "switch" { PUSH_TOKEN(SWITCH); } <<break>>
202 "this" { PUSH_TOKEN(THIS); } <<break>>
203 "throw" { PUSH_TOKEN(THROW); } <<break>>
204 "true" { PUSH_TOKEN(TRUE_LITERAL); } <<break>>
205 "try" { PUSH_TOKEN(TRY); } <<break>>
206 "typeof" { PUSH_TOKEN(TYPEOF); } <<break>>
207 "var" { PUSH_TOKEN(VAR); } <<break>>
208 "void" { PUSH_TOKEN(VOID); } <<break>>
209 "while" { PUSH_TOKEN(WHILE); } <<break>>
210 "with" { PUSH_TOKEN(WITH); } <<break>>
211 "yield" { PUSH_TOKEN(YIELD); } <<break>>
OLDNEW
« no previous file with comments | « no previous file | tools/lexer_generator/generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698