| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 re2c:condenumprefix = kCondition; | 252 re2c:condenumprefix = kCondition; |
| 253 re2c:define:YYCONDTYPE = Condition; | 253 re2c:define:YYCONDTYPE = Condition; |
| 254 re2c:define:YYCURSOR = cursor_; | 254 re2c:define:YYCURSOR = cursor_; |
| 255 re2c:define:YYLIMIT = limit_; | 255 re2c:define:YYLIMIT = limit_; |
| 256 re2c:define:YYMARKER = marker_; | 256 re2c:define:YYMARKER = marker_; |
| 257 | 257 |
| 258 eof = "\000"; | 258 eof = "\000"; |
| 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 | 269 |
| 270 <Normal> "break" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::BREA
K); } | 270 <Normal> "break" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::BREA
K); } |
| 271 <Normal> "case" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CASE
); } | 271 <Normal> "case" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CASE
); } |
| 272 <Normal> "catch" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CATC
H); } | 272 <Normal> "catch" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CATC
H); } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 <Normal> ">=" { PUSH_TOKEN(Token::GTE); } | 341 <Normal> ">=" { PUSH_TOKEN(Token::GTE); } |
| 342 <Normal> "<<" { PUSH_TOKEN(Token::SHL); } | 342 <Normal> "<<" { PUSH_TOKEN(Token::SHL); } |
| 343 <Normal> ">>" { PUSH_TOKEN(Token::SAR); } | 343 <Normal> ">>" { PUSH_TOKEN(Token::SAR); } |
| 344 <Normal> "<" { PUSH_TOKEN(Token::LT); } | 344 <Normal> "<" { PUSH_TOKEN(Token::LT); } |
| 345 <Normal> ">" { PUSH_TOKEN(Token::GT); } | 345 <Normal> ">" { PUSH_TOKEN(Token::GT); } |
| 346 | 346 |
| 347 <Normal> '0x' hex_digit+ not_identifier_char { PUSH_TOKE
N_LOOKAHEAD(Token::NUMBER); } | 347 <Normal> '0x' hex_digit+ not_identifier_char { PUSH_TOKE
N_LOOKAHEAD(Token::NUMBER); } |
| 348 <Normal> "." digit+ maybe_exponent not_identifier_char { PUSH_TOKE
N_LOOKAHEAD(Token::NUMBER); } | 348 <Normal> "." digit+ maybe_exponent not_identifier_char { PUSH_TOKE
N_LOOKAHEAD(Token::NUMBER); } |
| 349 <Normal> digit+ ("." digit+)? maybe_exponent not_identifier_char { PUSH_TOKE
N_LOOKAHEAD(Token::NUMBER); } | 349 <Normal> digit+ ("." digit+)? maybe_exponent not_identifier_char { PUSH_TOKE
N_LOOKAHEAD(Token::NUMBER); } |
| 350 | 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 <Normal> "(" { PUSH_TOKEN(Token::LPAREN); } | 355 <Normal> "(" { PUSH_TOKEN(Token::LPAREN); } |
| 352 <Normal> ")" { PUSH_TOKEN(Token::RPAREN); } | 356 <Normal> ")" { PUSH_TOKEN(Token::RPAREN); } |
| 353 <Normal> "[" { PUSH_TOKEN(Token::LBRACK); } | 357 <Normal> "[" { PUSH_TOKEN(Token::LBRACK); } |
| 354 <Normal> "]" { PUSH_TOKEN(Token::RBRACK); } | 358 <Normal> "]" { PUSH_TOKEN(Token::RBRACK); } |
| 355 <Normal> "{" { PUSH_TOKEN(Token::LBRACE); } | 359 <Normal> "{" { PUSH_TOKEN(Token::LBRACE); } |
| 356 <Normal> "}" { PUSH_TOKEN(Token::RBRACE); } | 360 <Normal> "}" { PUSH_TOKEN(Token::RBRACE); } |
| 357 <Normal> ":" { PUSH_TOKEN(Token::COLON); } | 361 <Normal> ":" { PUSH_TOKEN(Token::COLON); } |
| 358 <Normal> ";" { PUSH_TOKEN(Token::SEMICOLON); } | 362 <Normal> ";" { PUSH_TOKEN(Token::SEMICOLON); } |
| 359 <Normal> "." { PUSH_TOKEN(Token::PERIOD); } | 363 <Normal> "." { PUSH_TOKEN(Token::PERIOD); } |
| 360 <Normal> "?" { PUSH_TOKEN(Token::CONDITIONAL); } | 364 <Normal> "?" { PUSH_TOKEN(Token::CONDITIONAL); } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 374 <Normal> "%" { PUSH_TOKEN(Token::MOD); } | 378 <Normal> "%" { PUSH_TOKEN(Token::MOD); } |
| 375 <Normal> "~" { PUSH_TOKEN(Token::BIT_NOT); } | 379 <Normal> "~" { PUSH_TOKEN(Token::BIT_NOT); } |
| 376 <Normal> "," { PUSH_TOKEN(Token::COMMA); } | 380 <Normal> "," { PUSH_TOKEN(Token::COMMA); } |
| 377 | 381 |
| 378 <Normal> line_terminator { PUSH_LINE_TERMINATOR(); } | 382 <Normal> line_terminator { PUSH_LINE_TERMINATOR(); } |
| 379 <Normal> whitespace { SKIP(); } | 383 <Normal> whitespace { SKIP(); } |
| 380 | 384 |
| 381 <Normal> ["] :=> DoubleQuoteString | 385 <Normal> ["] :=> DoubleQuoteString |
| 382 <Normal> ['] :=> SingleQuoteString | 386 <Normal> ['] :=> SingleQuoteString |
| 383 | 387 |
| 384 <Normal> identifier_start_ :=> Identifier | 388 <Normal> identifier_start :=> Identifier |
| 385 <Normal> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart()) { YYSETCONDITION
(kConditionIdentifier); goto yy0; } YYSETCONDITION(kConditionIdentifierIllegal);
send(Token::ILLEGAL); start_ = cursor_; goto yy0; } | 389 <Normal> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart()) { YYSETCONDITION
(kConditionIdentifier); goto yy0; } send(Token::ILLEGAL); start_ = cursor_; goto
yy0; } |
| 386 <Normal> "\\" { PUSH_TOKEN(Token::ILLEGAL); } | 390 <Normal> "\\" { PUSH_TOKEN(Token::ILLEGAL); } |
| 387 | 391 |
| 388 <Normal> eof { PUSH_EOF_AND_RETURN();} | 392 <Normal> eof { PUSH_EOF_AND_RETURN();} |
| 389 <Normal> any { PUSH_TOKEN(Token::ILLEGAL); } | 393 <Normal> any :=> IdentifierIllegal |
| 390 | 394 |
| 391 <DoubleQuoteString> "\\\\" { goto yy0; } | 395 <DoubleQuoteString> "\\\\" { goto yy0; } |
| 392 <DoubleQuoteString> "\\\"" { goto yy0; } | 396 <DoubleQuoteString> "\\\"" { goto yy0; } |
| 393 <DoubleQuoteString> '"' { PUSH_TOKEN(Token::STRING);} | 397 <DoubleQuoteString> '"' { PUSH_TOKEN(Token::STRING);} |
| 394 <DoubleQuoteString> "\\" "\n" "\r"? { goto yy0; } | 398 <DoubleQuoteString> "\\" "\n" "\r"? { goto yy0; } |
| 395 <DoubleQuoteString> "\\" "\r" "\n"? { goto yy0; } | 399 <DoubleQuoteString> "\\" "\r" "\n"? { goto yy0; } |
| 396 <DoubleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 400 <DoubleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 397 <DoubleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 401 <DoubleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 398 <DoubleQuoteString> eof { TERMINATE_ILLEGAL(); } | 402 <DoubleQuoteString> eof { TERMINATE_ILLEGAL(); } |
| 399 <DoubleQuoteString> any { goto yy0; } | 403 <DoubleQuoteString> any { goto yy0; } |
| 400 | 404 |
| 401 <SingleQuoteString> "\\\\" { goto yy0; } | 405 <SingleQuoteString> "\\\\" { goto yy0; } |
| 402 <SingleQuoteString> "\\'" { goto yy0; } | 406 <SingleQuoteString> "\\'" { goto yy0; } |
| 403 <SingleQuoteString> "'" { PUSH_TOKEN(Token::STRING);} | 407 <SingleQuoteString> "'" { PUSH_TOKEN(Token::STRING);} |
| 404 <SingleQuoteString> "\\" "\n" "\r"? { goto yy0; } | 408 <SingleQuoteString> "\\" "\n" "\r"? { goto yy0; } |
| 405 <SingleQuoteString> "\\" "\r" "\n"? { goto yy0; } | 409 <SingleQuoteString> "\\" "\r" "\n"? { goto yy0; } |
| 406 <SingleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 410 <SingleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 407 <SingleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 411 <SingleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 408 <SingleQuoteString> eof { TERMINATE_ILLEGAL(); } | 412 <SingleQuoteString> eof { TERMINATE_ILLEGAL(); } |
| 409 <SingleQuoteString> any { goto yy0; } | 413 <SingleQuoteString> any { goto yy0; } |
| 410 | 414 |
| 411 <Identifier> identifier_char+ { goto yy0; } | 415 <Identifier> identifier_char+ { goto yy0; } |
| 412 <Identifier> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierPart()) goto yy0; YYS
ETCONDITION(kConditionIdentifierIllegal); send(Token::ILLEGAL); } | 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> "\\" { PUSH_TOKEN(Token::ILLEGAL); } | 417 <Identifier> "\\" { PUSH_TOKEN(Token::ILLEGAL); } |
| 414 <Identifier> any { PUSH_TOKEN_LOOKAHEAD(Token::IDENTIFIER); } | 418 <Identifier> any { PUSH_TOKEN_LOOKAHEAD(Token::IDENTIFIER); } |
| 415 | 419 |
| 416 <IdentifierIllegal> identifier_char+ { goto yy0; } | 420 <IdentifierIllegal> identifier_start { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 421 <IdentifierIllegal> identifier_char\identifier_start { goto yy0; } |
| 422 <IdentifierIllegal> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart()) { cur
sor_ -= 6; PUSH_TOKEN(Token::ILLEGAL); } goto yy0; } |
| 417 <IdentifierIllegal> "\\"+ { goto yy0; } | 423 <IdentifierIllegal> "\\"+ { goto yy0; } |
| 418 <IdentifierIllegal> any { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 424 <IdentifierIllegal> any { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 419 | 425 |
| 420 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();} | 426 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();} |
| 421 <SingleLineComment> eof { PUSH_TOKEN(Token::EOS); } | 427 <SingleLineComment> eof { PUSH_TOKEN(Token::EOS); } |
| 422 <SingleLineComment> any { goto yy0; } | 428 <SingleLineComment> any { goto yy0; } |
| 423 | 429 |
| 424 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();} | 430 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();} |
| 425 <MultiLineComment> eof { TERMINATE_ILLEGAL(); } | 431 <MultiLineComment> eof { TERMINATE_ILLEGAL(); } |
| 426 <MultiLineComment> any { goto yy0; } | 432 <MultiLineComment> any { goto yy0; } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 456 size_t start_offset = start_ - buffer_; | 462 size_t start_offset = start_ - buffer_; |
| 457 memmove(buffer_, start_, limit_ - start_); | 463 memmove(buffer_, start_, limit_ - start_); |
| 458 marker_ -= start_offset; | 464 marker_ -= start_offset; |
| 459 cursor_ -= start_offset; | 465 cursor_ -= start_offset; |
| 460 limit_ -= start_offset; | 466 limit_ -= start_offset; |
| 461 start_ -= start_offset; | 467 start_ -= start_offset; |
| 462 real_start_ += start_offset; | 468 real_start_ += start_offset; |
| 463 } | 469 } |
| 464 return 0; | 470 return 0; |
| 465 } | 471 } |
| OLD | NEW |