| OLD | NEW |
| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 "&" push_token(BIT_AND) | 93 "&" push_token(BIT_AND) |
| 94 "+" push_token(ADD) | 94 "+" push_token(ADD) |
| 95 "-" push_token(SUB) | 95 "-" push_token(SUB) |
| 96 "*" push_token(MUL) | 96 "*" push_token(MUL) |
| 97 "/" push_token(DIV) | 97 "/" push_token(DIV) |
| 98 "%" push_token(MOD) | 98 "%" push_token(MOD) |
| 99 "~" push_token(BIT_NOT) | 99 "~" push_token(BIT_NOT) |
| 100 "," push_token(COMMA) | 100 "," push_token(COMMA) |
| 101 | 101 |
| 102 line_terminator+ { PUSH_LINE_TERMINATOR(); } | 102 line_terminator+ { PUSH_LINE_TERMINATOR(); } |
| 103 whitespace { SKIP(); } # TODO implement skip | 103 whitespace <<skip>> |
| 104 | 104 |
| 105 "\"" <<DoubleQuoteString>> | 105 "\"" <<DoubleQuoteString>> |
| 106 "'" <<SingleQuoteString>> | 106 "'" <<SingleQuoteString>> |
| 107 | 107 |
| 108 # all keywords | 108 # all keywords |
| 109 "break" push_token(BREAK) | 109 "break" push_token(BREAK) |
| 110 "case" push_token(CASE) | 110 "case" push_token(CASE) |
| 111 "catch" push_token(CATCH) | 111 "catch" push_token(CATCH) |
| 112 "class" push_token(FUTURE_RESERVED_WORD) | 112 "class" push_token(FUTURE_RESERVED_WORD) |
| 113 "const" push_token(CONST) | 113 "const" push_token(CONST) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 "with" push_token(WITH) | 152 "with" push_token(WITH) |
| 153 "yield" push_token(YIELD) | 153 "yield" push_token(YIELD) |
| 154 | 154 |
| 155 identifier_start push_token(IDENTIFIER) <<Identifier>> | 155 identifier_start push_token(IDENTIFIER) <<Identifier>> |
| 156 /\\u[0-9a-fA-F]{4}/ { | 156 /\\u[0-9a-fA-F]{4}/ { |
| 157 if (V8_UNLIKELY(!ValidIdentifierStart())) { | 157 if (V8_UNLIKELY(!ValidIdentifierStart())) { |
| 158 PUSH_TOKEN(Token::ILLEGAL); | 158 PUSH_TOKEN(Token::ILLEGAL); |
| 159 } | 159 } |
| 160 } <<Identifier>> | 160 } <<Identifier>> |
| 161 | 161 |
| 162 eof { PUSH_TOKEN(Token::EOS); return 0; } | 162 eof <<terminate>> |
| 163 default_action push_token(ILLEGAL) | 163 default_action push_token(ILLEGAL) |
| 164 | 164 |
| 165 <DoubleQuoteString> | 165 <DoubleQuoteString> |
| 166 /\\\n\r?/ <<continue>> | 166 /\\\n\r?/ <<continue>> |
| 167 /\\\r\n?/ <<continue>> | 167 /\\\r\n?/ <<continue>> |
| 168 /\\./ <<continue>> | 168 /\\./ <<continue>> |
| 169 /\n|\r/ push_token(ILLEGAL) | 169 /\n|\r/ push_token(ILLEGAL) |
| 170 "\"" push_token(STRING) | 170 "\"" push_token(STRING) |
| 171 eof <<terminate_illegal>> | 171 eof <<terminate_illegal>> |
| 172 catch_all <<continue>> | 172 catch_all <<continue>> |
| 173 | 173 |
| 174 <SingleQuoteString> | 174 <SingleQuoteString> |
| 175 /\\\n\r?/ <<continue>> | 175 /\\\n\r?/ <<continue>> |
| 176 /\\\r\n?/ <<continue>> | 176 /\\\r\n?/ <<continue>> |
| 177 /\\./ <<continue>> | 177 /\\./ <<continue>> |
| 178 /\n|\r/ push_token(ILLEGAL) | 178 /\n|\r/ push_token(ILLEGAL) |
| 179 "'" push_token(STRING) | 179 "'" push_token(STRING) |
| 180 eof <<terminate_illegal>> | 180 eof <<terminate_illegal>> |
| 181 catch_all <<continue>> | 181 catch_all <<continue>> |
| 182 | 182 |
| 183 <Identifier> | 183 <Identifier> |
| 184 identifier_char <<continue>> | 184 identifier_char push_token(IDENTIFIER) <<continue>> |
| 185 /\\u[0-9a-fA-F]{4}/ { | 185 /\\u[0-9a-fA-F]{4}/ { |
| 186 if (V8_UNLIKELY(!ValidIdentifierStart())) { | 186 if (V8_UNLIKELY(!ValidIdentifierStart())) { |
| 187 PUSH_TOKEN(Token::ILLEGAL); | 187 PUSH_TOKEN(Token::ILLEGAL); |
| 188 } | 188 } |
| 189 } <<continue>> | 189 } <<continue>> |
| 190 default_action push_token(IDENTIFIER) | |
| 191 | 190 |
| 192 <SingleLineComment> | 191 <SingleLineComment> |
| 193 line_terminator { PUSH_LINE_TERMINATOR(); } | 192 line_terminator { PUSH_LINE_TERMINATOR(); } |
| 194 eof <<terminate>> | |
| 195 catch_all <<continue>> | 193 catch_all <<continue>> |
| 196 | 194 |
| 197 <MultiLineComment> | 195 <MultiLineComment> |
| 198 "*/" { SKIP(); goto code_start;} | 196 "*/" <<skip>> |
| 199 /\*[^\057]/ <<continue>> | 197 /\*[^\057]/ <<continue>> |
| 200 # need to force action | 198 line_terminator { PUSH_LINE_TERMINATOR(); } <<continue>> |
| 201 line_terminator+ { PUSH_LINE_TERMINATOR(); } <<continue>> | |
| 202 eof <<terminate>> | |
| 203 catch_all <<continue>> | 199 catch_all <<continue>> |
| 204 | 200 |
| 205 <HtmlComment> | 201 <HtmlComment> |
| 206 "-->" { SKIP(); } | 202 "-->" <<skip>> |
| 207 /--./ <<continue>> | 203 /--./ <<continue>> |
| 208 /-./ <<continue>> | 204 /-./ <<continue>> |
| 209 # need to force action | 205 line_terminator { PUSH_LINE_TERMINATOR(); } <<continue>> |
| 210 line_terminator+ { PUSH_LINE_TERMINATOR(); } <<continue>> | |
| 211 eof <<terminate>> | |
| 212 catch_all <<continue>> | 206 catch_all <<continue>> |
| OLD | NEW |