| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 any = [\000-\377]; | 259 any = [\000-\377]; |
| 260 whitespace_char = [ \t\v\f\r]; | 260 whitespace_char = [ \t\v\f\r]; |
| 261 whitespace = whitespace_char+; | 261 whitespace = whitespace_char+; |
| 262 identifier_start = [$_a-zA-Z]; | 262 identifier_start = [$_a-zA-Z]; |
| 263 identifier_char = [$_a-zA-Z0-9]; | 263 identifier_char = [$_a-zA-Z0-9]; |
| 264 not_identifier_char = any\identifier_char\[\\]; | 264 not_identifier_char = any\identifier_char\[\\]; |
| 265 line_terminator = [\n\r]+; | 265 line_terminator = [\n\r]+; |
| 266 digit = [0-9]; | 266 digit = [0-9]; |
| 267 hex_digit = [0-9a-fA-F]; | 267 hex_digit = [0-9a-fA-F]; |
| 268 maybe_exponent = ('e' [-+]? digit+)?; | 268 maybe_exponent = ('e' [-+]? digit+)?; |
| 269 number = ('0x' hex_digit+) | ("." digit+ maybe_exponent) | (digit+ ("." digi
t+)? maybe_exponent); |
| 269 | 270 |
| 270 <Normal> "break" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::BREA
K); } | 271 <Normal> "break" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::BREA
K); } |
| 271 <Normal> "case" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CASE
); } | 272 <Normal> "case" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CASE
); } |
| 272 <Normal> "catch" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CATC
H); } | 273 <Normal> "catch" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CATC
H); } |
| 273 <Normal> "class" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::FUTU
RE_RESERVED_WORD); } | 274 <Normal> "class" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::FUTU
RE_RESERVED_WORD); } |
| 274 <Normal> "const" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CONS
T); } | 275 <Normal> "const" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CONS
T); } |
| 275 <Normal> "continue" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CONT
INUE); } | 276 <Normal> "continue" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CONT
INUE); } |
| 276 <Normal> "debugger" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DEBU
GGER); } | 277 <Normal> "debugger" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DEBU
GGER); } |
| 277 <Normal> "default" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DEFA
ULT); } | 278 <Normal> "default" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DEFA
ULT); } |
| 278 <Normal> "delete" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DELE
TE); } | 279 <Normal> "delete" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DELE
TE); } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 <Normal> ">>>" { PUSH_TOKEN(Token::SHR); } | 338 <Normal> ">>>" { PUSH_TOKEN(Token::SHR); } |
| 338 <Normal> "<<=" { PUSH_TOKEN(Token::ASSIGN_SHL); } | 339 <Normal> "<<=" { PUSH_TOKEN(Token::ASSIGN_SHL); } |
| 339 <Normal> ">>=" { PUSH_TOKEN(Token::ASSIGN_SAR); } | 340 <Normal> ">>=" { PUSH_TOKEN(Token::ASSIGN_SAR); } |
| 340 <Normal> "<=" { PUSH_TOKEN(Token::LTE); } | 341 <Normal> "<=" { PUSH_TOKEN(Token::LTE); } |
| 341 <Normal> ">=" { PUSH_TOKEN(Token::GTE); } | 342 <Normal> ">=" { PUSH_TOKEN(Token::GTE); } |
| 342 <Normal> "<<" { PUSH_TOKEN(Token::SHL); } | 343 <Normal> "<<" { PUSH_TOKEN(Token::SHL); } |
| 343 <Normal> ">>" { PUSH_TOKEN(Token::SAR); } | 344 <Normal> ">>" { PUSH_TOKEN(Token::SAR); } |
| 344 <Normal> "<" { PUSH_TOKEN(Token::LT); } | 345 <Normal> "<" { PUSH_TOKEN(Token::LT); } |
| 345 <Normal> ">" { PUSH_TOKEN(Token::GT); } | 346 <Normal> ">" { PUSH_TOKEN(Token::GT); } |
| 346 | 347 |
| 347 <Normal> '0x' hex_digit+ not_identifier_char { PUSH_TOKE
N_LOOKAHEAD(Token::NUMBER); } | 348 <Normal> number not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::NUMBER); } |
| 348 <Normal> "." digit+ maybe_exponent not_identifier_char { PUSH_TOKE
N_LOOKAHEAD(Token::NUMBER); } | 349 <Normal> number "\\u" [0-9a-fA-F]{4} { cursor_ -= 6; send(Token::ILLEGAL); s
tart_ = cursor_; cursor_ += 6; if (ValidIdentifierStart()) { YYSETCONDITION(kCon
ditionIdentifier); goto yy0; } else { PUSH_TOKEN(Token::ILLEGAL); } } |
| 349 <Normal> digit+ ("." digit+)? maybe_exponent not_identifier_char { PUSH_TOKE
N_LOOKAHEAD(Token::NUMBER); } | 350 <Normal> number any { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL); } |
| 350 | |
| 351 <Normal> '0x' hex_digit+ "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart())
{ YYSETCONDITION(kConditionIdentifier); } else { YYSETCONDITION(kConditionIdenti
fierIllegal); } cursor_ -= 6; send(Token::ILLEGAL); start_ = cursor_; cursor_ +=
6; goto yy0; } | |
| 352 <Normal> "." digit+ maybe_exponent "\\u" [0-9a-fA-F]{4} { if (ValidIdentifie
rStart()) { YYSETCONDITION(kConditionIdentifier); } else { YYSETCONDITION(kCondi
tionIdentifierIllegal); } cursor_ -= 6; send(Token::ILLEGAL); start_ = cursor_;
cursor_ += 6; goto yy0; } | |
| 353 <Normal> digit+ ("." digit+)? maybe_exponent "\\u" [0-9a-fA-F]{4} { if (Vali
dIdentifierStart()) { YYSETCONDITION(kConditionIdentifier); } else { YYSETCONDIT
ION(kConditionIdentifierIllegal); } cursor_ -= 6; send(Token::ILLEGAL); start_ =
cursor_; cursor_ += 6; goto yy0; } | |
| 354 | 351 |
| 355 <Normal> "(" { PUSH_TOKEN(Token::LPAREN); } | 352 <Normal> "(" { PUSH_TOKEN(Token::LPAREN); } |
| 356 <Normal> ")" { PUSH_TOKEN(Token::RPAREN); } | 353 <Normal> ")" { PUSH_TOKEN(Token::RPAREN); } |
| 357 <Normal> "[" { PUSH_TOKEN(Token::LBRACK); } | 354 <Normal> "[" { PUSH_TOKEN(Token::LBRACK); } |
| 358 <Normal> "]" { PUSH_TOKEN(Token::RBRACK); } | 355 <Normal> "]" { PUSH_TOKEN(Token::RBRACK); } |
| 359 <Normal> "{" { PUSH_TOKEN(Token::LBRACE); } | 356 <Normal> "{" { PUSH_TOKEN(Token::LBRACE); } |
| 360 <Normal> "}" { PUSH_TOKEN(Token::RBRACE); } | 357 <Normal> "}" { PUSH_TOKEN(Token::RBRACE); } |
| 361 <Normal> ":" { PUSH_TOKEN(Token::COLON); } | 358 <Normal> ":" { PUSH_TOKEN(Token::COLON); } |
| 362 <Normal> ";" { PUSH_TOKEN(Token::SEMICOLON); } | 359 <Normal> ";" { PUSH_TOKEN(Token::SEMICOLON); } |
| 363 <Normal> "." { PUSH_TOKEN(Token::PERIOD); } | 360 <Normal> "." { PUSH_TOKEN(Token::PERIOD); } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 383 <Normal> whitespace { SKIP(); } | 380 <Normal> whitespace { SKIP(); } |
| 384 | 381 |
| 385 <Normal> ["] :=> DoubleQuoteString | 382 <Normal> ["] :=> DoubleQuoteString |
| 386 <Normal> ['] :=> SingleQuoteString | 383 <Normal> ['] :=> SingleQuoteString |
| 387 | 384 |
| 388 <Normal> identifier_start :=> Identifier | 385 <Normal> identifier_start :=> Identifier |
| 389 <Normal> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart()) { YYSETCONDITION
(kConditionIdentifier); goto yy0; } send(Token::ILLEGAL); start_ = cursor_; goto
yy0; } | 386 <Normal> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart()) { YYSETCONDITION
(kConditionIdentifier); goto yy0; } send(Token::ILLEGAL); start_ = cursor_; goto
yy0; } |
| 390 <Normal> "\\" { PUSH_TOKEN(Token::ILLEGAL); } | 387 <Normal> "\\" { PUSH_TOKEN(Token::ILLEGAL); } |
| 391 | 388 |
| 392 <Normal> eof { PUSH_EOF_AND_RETURN();} | 389 <Normal> eof { PUSH_EOF_AND_RETURN();} |
| 393 <Normal> any :=> IdentifierIllegal | 390 <Normal> any { marker_ = cursor_; YYSETCONDITION(kConditionIdentif
ierIllegal); goto yy0; } |
| 394 | 391 |
| 395 <DoubleQuoteString> "\\\\" { goto yy0; } | 392 <DoubleQuoteString> "\\\\" { goto yy0; } |
| 396 <DoubleQuoteString> "\\\"" { goto yy0; } | 393 <DoubleQuoteString> "\\\"" { goto yy0; } |
| 397 <DoubleQuoteString> '"' { PUSH_TOKEN(Token::STRING);} | 394 <DoubleQuoteString> '"' { PUSH_TOKEN(Token::STRING);} |
| 398 <DoubleQuoteString> "\\" "\n" "\r"? { goto yy0; } | 395 <DoubleQuoteString> "\\" "\n" "\r"? { goto yy0; } |
| 399 <DoubleQuoteString> "\\" "\r" "\n"? { goto yy0; } | 396 <DoubleQuoteString> "\\" "\r" "\n"? { goto yy0; } |
| 400 <DoubleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 397 <DoubleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 401 <DoubleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 398 <DoubleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 402 <DoubleQuoteString> eof { TERMINATE_ILLEGAL(); } | 399 <DoubleQuoteString> eof { TERMINATE_ILLEGAL(); } |
| 403 <DoubleQuoteString> any { goto yy0; } | 400 <DoubleQuoteString> any { goto yy0; } |
| 404 | 401 |
| 405 <SingleQuoteString> "\\\\" { goto yy0; } | 402 <SingleQuoteString> "\\\\" { goto yy0; } |
| 406 <SingleQuoteString> "\\'" { goto yy0; } | 403 <SingleQuoteString> "\\'" { goto yy0; } |
| 407 <SingleQuoteString> "'" { PUSH_TOKEN(Token::STRING);} | 404 <SingleQuoteString> "'" { PUSH_TOKEN(Token::STRING);} |
| 408 <SingleQuoteString> "\\" "\n" "\r"? { goto yy0; } | 405 <SingleQuoteString> "\\" "\n" "\r"? { goto yy0; } |
| 409 <SingleQuoteString> "\\" "\r" "\n"? { goto yy0; } | 406 <SingleQuoteString> "\\" "\r" "\n"? { goto yy0; } |
| 410 <SingleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 407 <SingleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 411 <SingleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 408 <SingleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 412 <SingleQuoteString> eof { TERMINATE_ILLEGAL(); } | 409 <SingleQuoteString> eof { TERMINATE_ILLEGAL(); } |
| 413 <SingleQuoteString> any { goto yy0; } | 410 <SingleQuoteString> any { goto yy0; } |
| 414 | 411 |
| 415 <Identifier> identifier_char+ { goto yy0; } | 412 <Identifier> identifier_char+ { goto yy0; } |
| 416 <Identifier> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierPart()) { YYSETCONDIT
ION(kConditionIdentifier); goto yy0; } YYSETCONDITION(kConditionNormal); send(To
ken::ILLEGAL); start_ = cursor_; goto yy0; } | 413 <Identifier> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierPart()) { YYSETCONDIT
ION(kConditionIdentifier); goto yy0; } YYSETCONDITION(kConditionNormal); send(To
ken::ILLEGAL); start_ = cursor_; goto yy0; } |
| 417 <Identifier> "\\" { PUSH_TOKEN(Token::ILLEGAL); } | 414 <Identifier> "\\" { PUSH_TOKEN(Token::ILLEGAL); } |
| 418 <Identifier> any { PUSH_TOKEN_LOOKAHEAD(Token::IDENTIFIER); } | 415 <Identifier> any { PUSH_TOKEN_LOOKAHEAD(Token::IDENTIFIER); } |
| 419 | 416 |
| 420 <IdentifierIllegal> identifier_start { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 417 <IdentifierIllegal> identifier_start { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 421 <IdentifierIllegal> identifier_char\identifier_start { goto yy0; } | 418 <IdentifierIllegal> identifier_char\identifier_start { marker_ = cursor_; g
oto yy0; } |
| 422 <IdentifierIllegal> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart()) { cur
sor_ -= 6; PUSH_TOKEN(Token::ILLEGAL); } goto yy0; } | 419 <IdentifierIllegal> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart()) { cur
sor_ -= 6; PUSH_TOKEN(Token::ILLEGAL); } marker_ = cursor_; PUSH_TOKEN(Token::IL
LEGAL); } |
| 423 <IdentifierIllegal> "\\"+ { goto yy0; } | 420 <IdentifierIllegal> "\\"+ { marker_ = cursor_; goto yy0; } |
| 421 <IdentifierIllegal> number not_identifier_char { YYCTYPE* temp = cursor_; cu
rsor_ = marker_; send(Token::ILLEGAL); cursor_ = temp; YYSETCONDITION(kCondition
Normal); PUSH_TOKEN_LOOKAHEAD(Token::NUMBER); } |
| 422 <IdentifierIllegal> number "\\u" [0-9a-fA-F]{4} { YYCTYPE* temp = cursor_; c
ursor_ = marker_; send(Token::ILLEGAL); cursor_ = temp; send(Token::ILLEGAL); st
art_ = cursor_; goto yy0; } |
| 424 <IdentifierIllegal> any { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 423 <IdentifierIllegal> any { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 425 | 424 |
| 426 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();} | 425 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();} |
| 427 <SingleLineComment> eof { PUSH_TOKEN(Token::EOS); } | 426 <SingleLineComment> eof { PUSH_TOKEN(Token::EOS); } |
| 428 <SingleLineComment> any { goto yy0; } | 427 <SingleLineComment> any { goto yy0; } |
| 429 | 428 |
| 430 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();} | 429 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();} |
| 431 <MultiLineComment> eof { TERMINATE_ILLEGAL(); } | 430 <MultiLineComment> eof { TERMINATE_ILLEGAL(); } |
| 432 <MultiLineComment> any { goto yy0; } | 431 <MultiLineComment> any { goto yy0; } |
| 433 | 432 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 462 size_t start_offset = start_ - buffer_; | 461 size_t start_offset = start_ - buffer_; |
| 463 memmove(buffer_, start_, limit_ - start_); | 462 memmove(buffer_, start_, limit_ - start_); |
| 464 marker_ -= start_offset; | 463 marker_ -= start_offset; |
| 465 cursor_ -= start_offset; | 464 cursor_ -= start_offset; |
| 466 limit_ -= start_offset; | 465 limit_ -= start_offset; |
| 467 start_ -= start_offset; | 466 start_ -= start_offset; |
| 468 real_start_ += start_offset; | 467 real_start_ += start_offset; |
| 469 } | 468 } |
| 470 return 0; | 469 return 0; |
| 471 } | 470 } |
| OLD | NEW |