| OLD | NEW |
| 1 // Portions of this code based on re2c: | 1 // Portions of this code based on re2c: |
| 2 // (re2c/examples/push.re) | 2 // (re2c/examples/push.re) |
| 3 // Copyright 2013 the V8 project authors. All rights reserved. | 3 // Copyright 2013 the V8 project authors. All rights reserved. |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 re2c:define:YYCONDTYPE = Condition; | 188 re2c:define:YYCONDTYPE = Condition; |
| 189 re2c:define:YYCURSOR = cursor_; | 189 re2c:define:YYCURSOR = cursor_; |
| 190 re2c:define:YYCTYPE = uint8_t; | 190 re2c:define:YYCTYPE = uint8_t; |
| 191 re2c:define:YYLIMIT = limit_; | 191 re2c:define:YYLIMIT = limit_; |
| 192 re2c:define:YYMARKER = marker_; | 192 re2c:define:YYMARKER = marker_; |
| 193 | 193 |
| 194 eof = "\000"; | 194 eof = "\000"; |
| 195 any = [\000-\377]; | 195 any = [\000-\377]; |
| 196 whitespace_char = [ \t\v\f\r]; | 196 whitespace_char = [ \t\v\f\r]; |
| 197 whitespace = whitespace_char+; | 197 whitespace = whitespace_char+; |
| 198 identifier_start_ = [$_\\a-zA-Z]; | 198 identifier_start_ = [$_a-zA-Z]; |
| 199 identifier_char = [$_\\a-zA-Z0-9]; | 199 identifier_char = [$_a-zA-Z0-9]; |
| 200 not_identifier_char = any\identifier_char; | 200 not_identifier_char = any\identifier_char; |
| 201 illegal_after_identifier = [\\]; |
| 201 line_terminator = [\n\r]+; | 202 line_terminator = [\n\r]+; |
| 202 digit = [0-9]; | 203 digit = [0-9]; |
| 203 hex_digit = [0-9a-fA-F]; | 204 hex_digit = [0-9a-fA-F]; |
| 204 maybe_exponent = ('e' [-+]? digit+)?; | 205 maybe_exponent = ('e' [-+]? digit+)?; |
| 205 | 206 |
| 206 <Normal> "break" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::BREA
K); } | 207 <Normal> "break" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::BREA
K); } |
| 207 <Normal> "case" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CASE
); } | 208 <Normal> "case" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CASE
); } |
| 208 <Normal> "catch" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CATC
H); } | 209 <Normal> "catch" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CATC
H); } |
| 209 <Normal> "class" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::FUTU
RE_RESERVED_WORD); } | 210 <Normal> "class" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::FUTU
RE_RESERVED_WORD); } |
| 210 <Normal> "const" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CONS
T); } | 211 <Normal> "const" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CONS
T); } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 313 |
| 313 <Normal> line_terminator { PUSH_LINE_TERMINATOR(); } | 314 <Normal> line_terminator { PUSH_LINE_TERMINATOR(); } |
| 314 <Normal> whitespace { SKIP(); } | 315 <Normal> whitespace { SKIP(); } |
| 315 | 316 |
| 316 <Normal> ["] :=> DoubleQuoteString | 317 <Normal> ["] :=> DoubleQuoteString |
| 317 <Normal> ['] :=> SingleQuoteString | 318 <Normal> ['] :=> SingleQuoteString |
| 318 | 319 |
| 319 <Normal> identifier_start_ :=> Identifier | 320 <Normal> identifier_start_ :=> Identifier |
| 320 | 321 |
| 321 <Normal> eof { PUSH_EOF_AND_RETURN();} | 322 <Normal> eof { PUSH_EOF_AND_RETURN();} |
| 322 <Normal> any { TERMINATE_ILLEGAL(); } | 323 <Normal> any { PUSH_TOKEN(Token::ILLEGAL); } |
| 323 | 324 |
| 324 <DoubleQuoteString> "\\\"" { goto yy0; } | 325 <DoubleQuoteString> "\\\"" { goto yy0; } |
| 325 <DoubleQuoteString> '"' { PUSH_TOKEN(Token::STRING);} | 326 <DoubleQuoteString> '"' { PUSH_TOKEN(Token::STRING);} |
| 326 <DoubleQuoteString> "\\" "\n" "\r"? { goto yy0; } | 327 <DoubleQuoteString> "\\" "\n" "\r"? { goto yy0; } |
| 327 <DoubleQuoteString> "\\" "\r" "\n"? { goto yy0; } | 328 <DoubleQuoteString> "\\" "\r" "\n"? { goto yy0; } |
| 328 <DoubleQuoteString> line_terminator { TERMINATE_ILLEGAL(); } | 329 <DoubleQuoteString> line_terminator { TERMINATE_ILLEGAL(); } |
| 329 <DoubleQuoteString> eof { TERMINATE_ILLEGAL(); } | 330 <DoubleQuoteString> eof { TERMINATE_ILLEGAL(); } |
| 330 <DoubleQuoteString> any { goto yy0; } | 331 <DoubleQuoteString> any { goto yy0; } |
| 331 | 332 |
| 332 <SingleQuoteString> "\\'" { goto yy0; } | 333 <SingleQuoteString> "\\'" { goto yy0; } |
| 333 <SingleQuoteString> "'" { PUSH_TOKEN(Token::STRING);} | 334 <SingleQuoteString> "'" { PUSH_TOKEN(Token::STRING);} |
| 334 <SingleQuoteString> "\\" "\n" "\r"? { goto yy0; } | 335 <SingleQuoteString> "\\" "\n" "\r"? { goto yy0; } |
| 335 <SingleQuoteString> "\\" "\r" "\n"? { goto yy0; } | 336 <SingleQuoteString> "\\" "\r" "\n"? { goto yy0; } |
| 336 <SingleQuoteString> line_terminator { TERMINATE_ILLEGAL(); } | 337 <SingleQuoteString> line_terminator { TERMINATE_ILLEGAL(); } |
| 337 <SingleQuoteString> eof { TERMINATE_ILLEGAL(); } | 338 <SingleQuoteString> eof { TERMINATE_ILLEGAL(); } |
| 338 <SingleQuoteString> any { goto yy0; } | 339 <SingleQuoteString> any { goto yy0; } |
| 339 | 340 |
| 340 <Identifier> identifier_char+ { goto yy0; } | 341 <Identifier> identifier_char+ { goto yy0; } |
| 342 <Identifier> illegal_after_identifier { PUSH_TOKEN(Token::ILLEGAL); } |
| 341 <Identifier> any { PUSH_TOKEN_LOOKAHEAD(Token::IDENTIFIER); } | 343 <Identifier> any { PUSH_TOKEN_LOOKAHEAD(Token::IDENTIFIER); } |
| 342 | 344 |
| 343 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();} | 345 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();} |
| 344 <SingleLineComment> eof { PUSH_LINE_TERMINATOR();} | 346 <SingleLineComment> eof { PUSH_LINE_TERMINATOR();} |
| 345 <SingleLineComment> any { goto yy0; } | 347 <SingleLineComment> any { goto yy0; } |
| 346 | 348 |
| 347 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();} | 349 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();} |
| 348 <MultiLineComment> eof { TERMINATE_ILLEGAL(); } | 350 <MultiLineComment> eof { TERMINATE_ILLEGAL(); } |
| 349 <MultiLineComment> any { goto yy0; } | 351 <MultiLineComment> any { goto yy0; } |
| 350 | 352 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 379 size_t start_offset = start_ - buffer_; | 381 size_t start_offset = start_ - buffer_; |
| 380 memmove(buffer_, start_, limit_ - start_); | 382 memmove(buffer_, start_, limit_ - start_); |
| 381 marker_ -= start_offset; | 383 marker_ -= start_offset; |
| 382 cursor_ -= start_offset; | 384 cursor_ -= start_offset; |
| 383 limit_ -= start_offset; | 385 limit_ -= start_offset; |
| 384 start_ -= start_offset; | 386 start_ -= start_offset; |
| 385 real_start_ += start_offset; | 387 real_start_ += start_offset; |
| 386 } | 388 } |
| 387 return 0; | 389 return 0; |
| 388 } | 390 } |
| OLD | NEW |