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

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

Issue 68343004: Experimental parser: better actions (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/automaton.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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 "/=" { PUSH_TOKEN(ASSIGN_DIV); } 45 "/=" { PUSH_TOKEN(ASSIGN_DIV); }
46 "%=" { PUSH_TOKEN(ASSIGN_MOD); } 46 "%=" { PUSH_TOKEN(ASSIGN_MOD); }
47 47
48 "===" { PUSH_TOKEN(EQ_STRICT); } 48 "===" { PUSH_TOKEN(EQ_STRICT); }
49 "==" { PUSH_TOKEN(EQ); } 49 "==" { PUSH_TOKEN(EQ); }
50 "=" { PUSH_TOKEN(ASSIGN); } 50 "=" { PUSH_TOKEN(ASSIGN); }
51 "!==" { PUSH_TOKEN(NE_STRICT); } 51 "!==" { PUSH_TOKEN(NE_STRICT); }
52 "!=" { PUSH_TOKEN(NE); } 52 "!=" { PUSH_TOKEN(NE); }
53 "!" { PUSH_TOKEN(NOT); } 53 "!" { PUSH_TOKEN(NOT); }
54 54
55 "//" <<SingleLineComment>> # TODO save offset? 55 "//" <<SingleLineComment>>
56 "/*" <<MultiLineComment>> 56 "/*" <<MultiLineComment>>
57 "<!--" <<HtmlComment>> 57 "<!--" <<HtmlComment>>
58
58 #whitespace* "-->" { if (just_seen_line_terminator_) { YYSETCONDITION(kCondition SingleLineComment); goto yyc_SingleLineComment; } else { --cursor_; send(Token:: DEC); start_ = cursor_; goto yyc_Normal; } } 59 #whitespace* "-->" { if (just_seen_line_terminator_) { YYSETCONDITION(kCondition SingleLineComment); goto yyc_SingleLineComment; } else { --cursor_; send(Token:: DEC); start_ = cursor_; goto yyc_Normal; } }
59 60
60 ">>>=" { PUSH_TOKEN(ASSIGN_SHR); } 61 ">>>=" { PUSH_TOKEN(ASSIGN_SHR); }
61 ">>>" { PUSH_TOKEN(SHR); } 62 ">>>" { PUSH_TOKEN(SHR); }
62 "<<=" { PUSH_TOKEN(ASSIGN_SHL); } 63 "<<=" { PUSH_TOKEN(ASSIGN_SHL); }
63 ">>=" { PUSH_TOKEN(ASSIGN_SAR); } 64 ">>=" { PUSH_TOKEN(ASSIGN_SAR); }
64 "<=" { PUSH_TOKEN(LTE); } 65 "<=" { PUSH_TOKEN(LTE); }
65 ">=" { PUSH_TOKEN(GTE); } 66 ">=" { PUSH_TOKEN(GTE); }
66 "<<" { PUSH_TOKEN(SHL); } 67 "<<" { PUSH_TOKEN(SHL); }
67 ">>" { PUSH_TOKEN(SAR); } 68 ">>" { PUSH_TOKEN(SAR); }
(...skipping 24 matching lines...) Expand all
92 "&" { PUSH_TOKEN(BIT_AND); } 93 "&" { PUSH_TOKEN(BIT_AND); }
93 "+" { PUSH_TOKEN(ADD); } 94 "+" { PUSH_TOKEN(ADD); }
94 "-" { PUSH_TOKEN(SUB); } 95 "-" { PUSH_TOKEN(SUB); }
95 "*" { PUSH_TOKEN(MUL); } 96 "*" { PUSH_TOKEN(MUL); }
96 "/" { PUSH_TOKEN(DIV); } 97 "/" { PUSH_TOKEN(DIV); }
97 "%" { PUSH_TOKEN(MOD); } 98 "%" { PUSH_TOKEN(MOD); }
98 "~" { PUSH_TOKEN(BIT_NOT); } 99 "~" { PUSH_TOKEN(BIT_NOT); }
99 "," { PUSH_TOKEN(COMMA); } 100 "," { PUSH_TOKEN(COMMA); }
100 101
101 line_terminator+ { PUSH_LINE_TERMINATOR(); } 102 line_terminator+ { PUSH_LINE_TERMINATOR(); }
102 whitespace <<continue>> 103 whitespace { SKIP } # TODO implement skip
103 104
104 "\"" <<DoubleQuoteString>> 105 "\"" <<DoubleQuoteString>>
105 "'" <<SingleQuoteString>> 106 "'" <<SingleQuoteString>>
106 107
107 # all keywords 108 # all keywords
108 "break" { PUSH_TOKEN(BREAK); } <<break>> 109 "break" { PUSH_TOKEN(BREAK); }
109 "case" { PUSH_TOKEN(CASE); } <<break>> 110 "case" { PUSH_TOKEN(CASE); }
110 "catch" { PUSH_TOKEN(CATCH); } <<break>> 111 "catch" { PUSH_TOKEN(CATCH); }
111 "class" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>> 112 "class" { PUSH_TOKEN(FUTURE_RESERVED_WORD); }
112 "const" { PUSH_TOKEN(CONST); } <<break>> 113 "const" { PUSH_TOKEN(CONST); }
113 "continue" { PUSH_TOKEN(CONTINUE); } <<break>> 114 "continue" { PUSH_TOKEN(CONTINUE); }
114 "debugger" { PUSH_TOKEN(DEBUGGER); } <<break>> 115 "debugger" { PUSH_TOKEN(DEBUGGER); }
115 "default" { PUSH_TOKEN(DEFAULT); } <<break>> 116 "default" { PUSH_TOKEN(DEFAULT); }
116 "delete" { PUSH_TOKEN(DELETE); } <<break>> 117 "delete" { PUSH_TOKEN(DELETE); }
117 "do" { PUSH_TOKEN(DO); } <<break>> 118 "do" { PUSH_TOKEN(DO); }
118 "else" { PUSH_TOKEN(ELSE); } <<break>> 119 "else" { PUSH_TOKEN(ELSE); }
119 "enum" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>> 120 "enum" { PUSH_TOKEN(FUTURE_RESERVED_WORD); }
120 "export" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>> 121 "export" { PUSH_TOKEN(FUTURE_RESERVED_WORD); }
121 "extends" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>> 122 "extends" { PUSH_TOKEN(FUTURE_RESERVED_WORD); }
122 "false" { PUSH_TOKEN(FALSE_LITERAL); } <<break>> 123 "false" { PUSH_TOKEN(FALSE_LITERAL); }
123 "finally" { PUSH_TOKEN(FINALLY); } <<break>> 124 "finally" { PUSH_TOKEN(FINALLY); }
124 "for" { PUSH_TOKEN(FOR); } <<break>> 125 "for" { PUSH_TOKEN(FOR); }
125 "function" { PUSH_TOKEN(FUNCTION); } <<break>> 126 "function" { PUSH_TOKEN(FUNCTION); }
126 "if" { PUSH_TOKEN(IF); } <<break>> 127 "if" { PUSH_TOKEN(IF); }
127 "implements" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>> 128 "implements" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); }
128 "import" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>> 129 "import" { PUSH_TOKEN(FUTURE_RESERVED_WORD); }
129 "in" { PUSH_TOKEN(IN); } <<break>> 130 "in" { PUSH_TOKEN(IN); }
130 "instanceof" { PUSH_TOKEN(INSTANCEOF); } <<break>> 131 "instanceof" { PUSH_TOKEN(INSTANCEOF); }
131 "interface" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>> 132 "interface" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); }
132 "let" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>> 133 "let" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); }
133 "new" { PUSH_TOKEN(NEW); } <<break>> 134 "new" { PUSH_TOKEN(NEW); }
134 "null" { PUSH_TOKEN(NULL_LITERAL); } <<break>> 135 "null" { PUSH_TOKEN(NULL_LITERAL); }
135 "package" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>> 136 "package" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); }
136 "private" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>> 137 "private" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); }
137 "protected" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>> 138 "protected" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); }
138 "public" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>> 139 "public" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); }
139 "return" { PUSH_TOKEN(RETURN); } <<break>> 140 "return" { PUSH_TOKEN(RETURN); }
140 "static" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); } <<break>> 141 "static" { PUSH_TOKEN(FUTURE_STRICT_RESERVED_WORD); }
141 "super" { PUSH_TOKEN(FUTURE_RESERVED_WORD); } <<break>> 142 "super" { PUSH_TOKEN(FUTURE_RESERVED_WORD); }
142 "switch" { PUSH_TOKEN(SWITCH); } <<break>> 143 "switch" { PUSH_TOKEN(SWITCH); }
143 "this" { PUSH_TOKEN(THIS); } <<break>> 144 "this" { PUSH_TOKEN(THIS); }
144 "throw" { PUSH_TOKEN(THROW); } <<break>> 145 "throw" { PUSH_TOKEN(THROW); }
145 "true" { PUSH_TOKEN(TRUE_LITERAL); } <<break>> 146 "true" { PUSH_TOKEN(TRUE_LITERAL); }
146 "try" { PUSH_TOKEN(TRY); } <<break>> 147 "try" { PUSH_TOKEN(TRY); }
147 "typeof" { PUSH_TOKEN(TYPEOF); } <<break>> 148 "typeof" { PUSH_TOKEN(TYPEOF); }
148 "var" { PUSH_TOKEN(VAR); } <<break>> 149 "var" { PUSH_TOKEN(VAR); }
149 "void" { PUSH_TOKEN(VOID); } <<break>> 150 "void" { PUSH_TOKEN(VOID); }
150 "while" { PUSH_TOKEN(WHILE); } <<break>> 151 "while" { PUSH_TOKEN(WHILE); }
151 "with" { PUSH_TOKEN(WITH); } <<break>> 152 "with" { PUSH_TOKEN(WITH); }
152 "yield" { PUSH_TOKEN(YIELD); } <<break>> 153 "yield" { PUSH_TOKEN(YIELD); }
153 154
154 identifier_start <<Identifier>> 155 identifier_start { PUSH_TOKEN(IDENTIFIER); } <<Identifier>>
155 /\\u[0-9a-fA-F]{4}/ { 156 /\\u[0-9a-fA-F]{4}/ {
156 if (V8_LIKELY(ValidIdentifierStart())) { 157 if (V8_UNLIKELY(!ValidIdentifierStart())) {
157 JUMP(Identifier); 158 PUSH_TOKEN(ILLEGAL);
158 } 159 }
159 PUSH_TOKEN(ILLEGAL);
160 } <<Identifier>> 160 } <<Identifier>>
161 161
162 eof <<terminate>> 162 eof <<terminate>>
163 default { PUSH_TOKEN(ILLEGAL); } 163 default_action { PUSH_TOKEN(ILLEGAL); }
164 164
165 <DoubleQuoteString> 165 <DoubleQuoteString>
166 "\\" <<continue>> 166 "\\" <<continue>>
167 "\\\"" <<continue>> 167 "\\\"" <<continue>>
168 "\"" { PUSH_TOKEN(STRING); } <<break>> 168 "\"" { PUSH_TOKEN(STRING); }
169 /\\\n\r?/ <<continue>> 169 /\\\n\r?/ <<continue>>
170 /\\\r\n?/ <<continue>> 170 /\\\r\n?/ <<continue>>
171 /\n|\r/ { PUSH_TOKEN(ILLEGAL); } <<break>> 171 /\n|\r/ { PUSH_TOKEN(ILLEGAL); }
172 eof <<terminate_illegal>> 172 eof <<terminate_illegal>>
173 default <<continue>> 173 /./ <<continue>>
174 174
175 <SingleQuoteString> 175 <SingleQuoteString>
176 "\\" <<continue>> 176 "\\" <<continue>>
177 "\\'" <<continue>> 177 "\\'" <<continue>>
178 "'" { PUSH_TOKEN(STRING); } <<break>> 178 "'" { PUSH_TOKEN(STRING); }
179 /\\\n\r?/ <<continue>> 179 /\\\n\r?/ <<continue>>
180 /\\\r\n?/ <<continue>> 180 /\\\r\n?/ <<continue>>
181 /\n|\r/ { PUSH_TOKEN(ILLEGAL); } <<break>> 181 /\n|\r/ { PUSH_TOKEN(ILLEGAL); }
182 eof <<terminate_illegal>> 182 eof <<terminate_illegal>>
183 default <<continue>> 183 /./ <<continue>>
184 184
185 <Identifier> 185 <Identifier>
186 identifier_char+ <<continue>> 186 identifier_char <<continue>>
187 /\\u[0-9a-fA-F]{4}/ { 187 /\\u[0-9a-fA-F]{4}/ {
188 if (V8_UNLIKELY(!ValidIdentifierStart())) { 188 if (V8_UNLIKELY(!ValidIdentifierStart())) {
189 PUSH_TOKEN(ILLEGAL); 189 PUSH_TOKEN(ILLEGAL);
190 JUMP(Normal);
191 } 190 }
192 } 191 } <<continue>>
193 default { PUSH_TOKEN(IDENTIFIER); } <<break>> 192 default_action { PUSH_TOKEN(IDENTIFIER); }
194 193
195 <SingleLineComment> 194 <SingleLineComment>
196 line_terminator { PUSH_LINE_TERMINATOR(); } <<break>> 195 line_terminator { PUSH_LINE_TERMINATOR(); }
197 eof <<terminate>> 196 eof <<terminate>>
198 default <<continue>> 197 /./ <<continue>>
199 198
200 <MultiLineComment> 199 <MultiLineComment>
201 "*/" <<break>> 200 "*/" { SKIP }
202 line_terminator+ { PUSH_LINE_TERMINATOR(); } 201 # need to force action
202 line_terminator+ { PUSH_LINE_TERMINATOR(); } <<continue>>
203 eof <<terminate>> 203 eof <<terminate>>
204 default <<continue>> 204 /./ <<continue>>
205 205
206 <HtmlComment> 206 <HtmlComment>
207 "-->" <<break>> 207 "-->" { SKIP }
208 line_terminator+ { PUSH_LINE_TERMINATOR(); } 208 # need to force action
209 line_terminator+ { PUSH_LINE_TERMINATOR(); } <<continue>>
209 eof <<terminate>> 210 eof <<terminate>>
210 default <<continue>> 211 /./ <<continue>>
OLDNEW
« no previous file with comments | « no previous file | tools/lexer_generator/automaton.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698