| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 <Normal> "=" { PUSH_TOKEN(Token::ASSIGN); } | 264 <Normal> "=" { PUSH_TOKEN(Token::ASSIGN); } |
| 265 <Normal> "!==" { PUSH_TOKEN(Token::NE_STRICT); } | 265 <Normal> "!==" { PUSH_TOKEN(Token::NE_STRICT); } |
| 266 <Normal> "!=" { PUSH_TOKEN(Token::NE); } | 266 <Normal> "!=" { PUSH_TOKEN(Token::NE); } |
| 267 <Normal> "!" { PUSH_TOKEN(Token::NOT); } | 267 <Normal> "!" { PUSH_TOKEN(Token::NOT); } |
| 268 | 268 |
| 269 <Normal> "//" :=> SingleLineComment | 269 <Normal> "//" :=> SingleLineComment |
| 270 <Normal> "/*" :=> MultiLineComment | 270 <Normal> "/*" :=> MultiLineComment |
| 271 <Normal> "<!--" :=> HtmlComment | 271 <Normal> "<!--" :=> HtmlComment |
| 272 | 272 |
| 273 <Normal> ">>>=" { PUSH_TOKEN(Token::ASSIGN_SHR); } | 273 <Normal> ">>>=" { PUSH_TOKEN(Token::ASSIGN_SHR); } |
| 274 <Normal> ">>>" { PUSH_TOKEN(Token::SHR); } |
| 274 <Normal> "<<=" { PUSH_TOKEN(Token::ASSIGN_SHL); } | 275 <Normal> "<<=" { PUSH_TOKEN(Token::ASSIGN_SHL); } |
| 275 <Normal> ">>=" { PUSH_TOKEN(Token::ASSIGN_SAR); } | 276 <Normal> ">>=" { PUSH_TOKEN(Token::ASSIGN_SAR); } |
| 276 <Normal> "<=" { PUSH_TOKEN(Token::LTE); } | 277 <Normal> "<=" { PUSH_TOKEN(Token::LTE); } |
| 277 <Normal> ">=" { PUSH_TOKEN(Token::GTE); } | 278 <Normal> ">=" { PUSH_TOKEN(Token::GTE); } |
| 278 <Normal> "<<" { PUSH_TOKEN(Token::SHL); } | 279 <Normal> "<<" { PUSH_TOKEN(Token::SHL); } |
| 279 <Normal> ">>" { PUSH_TOKEN(Token::SAR); } | 280 <Normal> ">>" { PUSH_TOKEN(Token::SAR); } |
| 280 <Normal> "<" { PUSH_TOKEN(Token::LT); } | 281 <Normal> "<" { PUSH_TOKEN(Token::LT); } |
| 281 <Normal> ">" { PUSH_TOKEN(Token::GT); } | 282 <Normal> ">" { PUSH_TOKEN(Token::GT); } |
| 282 | 283 |
| 283 <Normal> '0x' hex_digit+ not_identifier_char { PUSH_TOKE
N_LOOKAHEAD(Token::NUMBER); } | 284 <Normal> '0x' hex_digit+ not_identifier_char { PUSH_TOKE
N_LOOKAHEAD(Token::NUMBER); } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 <Normal> ['] :=> SingleQuoteString | 319 <Normal> ['] :=> SingleQuoteString |
| 319 | 320 |
| 320 <Normal> identifier_start_ :=> Identifier | 321 <Normal> identifier_start_ :=> Identifier |
| 321 <Normal> "\\u0000" :=> IdentifierIllegal | 322 <Normal> "\\u0000" :=> IdentifierIllegal |
| 322 <Normal> "\\u" [0-9a-fA-F]{4} :=> Identifier | 323 <Normal> "\\u" [0-9a-fA-F]{4} :=> Identifier |
| 323 <Normal> "\\" { PUSH_TOKEN(Token::ILLEGAL); } | 324 <Normal> "\\" { PUSH_TOKEN(Token::ILLEGAL); } |
| 324 | 325 |
| 325 <Normal> eof { PUSH_EOF_AND_RETURN();} | 326 <Normal> eof { PUSH_EOF_AND_RETURN();} |
| 326 <Normal> any { PUSH_TOKEN(Token::ILLEGAL); } | 327 <Normal> any { PUSH_TOKEN(Token::ILLEGAL); } |
| 327 | 328 |
| 329 <DoubleQuoteString> "\\\\" { goto yy0; } |
| 328 <DoubleQuoteString> "\\\"" { goto yy0; } | 330 <DoubleQuoteString> "\\\"" { goto yy0; } |
| 329 <DoubleQuoteString> '"' { PUSH_TOKEN(Token::STRING);} | 331 <DoubleQuoteString> '"' { PUSH_TOKEN(Token::STRING);} |
| 330 <DoubleQuoteString> "\\" "\n" "\r"? { goto yy0; } | 332 <DoubleQuoteString> "\\" "\n" "\r"? { goto yy0; } |
| 331 <DoubleQuoteString> "\\" "\r" "\n"? { goto yy0; } | 333 <DoubleQuoteString> "\\" "\r" "\n"? { goto yy0; } |
| 332 <DoubleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 334 <DoubleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 333 <DoubleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 335 <DoubleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 334 <DoubleQuoteString> eof { TERMINATE_ILLEGAL(); } | 336 <DoubleQuoteString> eof { TERMINATE_ILLEGAL(); } |
| 335 <DoubleQuoteString> any { goto yy0; } | 337 <DoubleQuoteString> any { goto yy0; } |
| 336 | 338 |
| 339 <SingleQuoteString> "\\\\" { goto yy0; } |
| 337 <SingleQuoteString> "\\'" { goto yy0; } | 340 <SingleQuoteString> "\\'" { goto yy0; } |
| 338 <SingleQuoteString> "'" { PUSH_TOKEN(Token::STRING);} | 341 <SingleQuoteString> "'" { PUSH_TOKEN(Token::STRING);} |
| 339 <SingleQuoteString> "\\" "\n" "\r"? { goto yy0; } | 342 <SingleQuoteString> "\\" "\n" "\r"? { goto yy0; } |
| 340 <SingleQuoteString> "\\" "\r" "\n"? { goto yy0; } | 343 <SingleQuoteString> "\\" "\r" "\n"? { goto yy0; } |
| 341 <SingleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 344 <SingleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 342 <SingleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 345 <SingleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 343 <SingleQuoteString> eof { TERMINATE_ILLEGAL(); } | 346 <SingleQuoteString> eof { TERMINATE_ILLEGAL(); } |
| 344 <SingleQuoteString> any { goto yy0; } | 347 <SingleQuoteString> any { goto yy0; } |
| 345 | 348 |
| 346 <Identifier> identifier_char+ { goto yy0; } | 349 <Identifier> identifier_char+ { goto yy0; } |
| 347 <Identifier> "\\u0000" :=> IdentifierIllegal | 350 <Identifier> "\\u0000" :=> IdentifierIllegal |
| 348 <Identifier> "\\u" [0-9a-fA-F]{4} { goto yy0; } | 351 <Identifier> "\\u" [0-9a-fA-F]{4} { goto yy0; } |
| 349 <Identifier> "\\" { PUSH_TOKEN(Token::ILLEGAL); } | 352 <Identifier> "\\" { PUSH_TOKEN(Token::ILLEGAL); } |
| 350 <Identifier> any { PUSH_TOKEN_LOOKAHEAD(Token::IDENTIFIER); } | 353 <Identifier> any { PUSH_TOKEN_LOOKAHEAD(Token::IDENTIFIER); } |
| 351 | 354 |
| 352 <IdentifierIllegal> identifier_char+ { goto yy0; } | 355 <IdentifierIllegal> identifier_char+ { goto yy0; } |
| 353 <IdentifierIllegal> "\\"+ { goto yy0; } | 356 <IdentifierIllegal> "\\"+ { goto yy0; } |
| 354 <IdentifierIllegal> any { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } | 357 <IdentifierIllegal> any { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL)
; } |
| 355 | 358 |
| 356 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();} | 359 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();} |
| 357 <SingleLineComment> eof { PUSH_LINE_TERMINATOR();} | 360 <SingleLineComment> eof { PUSH_TOKEN(Token::EOS); } |
| 358 <SingleLineComment> any { goto yy0; } | 361 <SingleLineComment> any { goto yy0; } |
| 359 | 362 |
| 360 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();} | 363 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();} |
| 361 <MultiLineComment> eof { TERMINATE_ILLEGAL(); } | 364 <MultiLineComment> eof { TERMINATE_ILLEGAL(); } |
| 362 <MultiLineComment> any { goto yy0; } | 365 <MultiLineComment> any { goto yy0; } |
| 363 | 366 |
| 364 <HtmlComment> eof { TERMINATE_ILLEGAL(); } | 367 <HtmlComment> eof { TERMINATE_ILLEGAL(); } |
| 365 <HtmlComment> "-->" { PUSH_LINE_TERMINATOR();} | 368 <HtmlComment> "-->" { PUSH_LINE_TERMINATOR();} |
| 366 <HtmlComment> any { goto yy0; } | 369 <HtmlComment> any { goto yy0; } |
| 367 */ | 370 */ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 392 size_t start_offset = start_ - buffer_; | 395 size_t start_offset = start_ - buffer_; |
| 393 memmove(buffer_, start_, limit_ - start_); | 396 memmove(buffer_, start_, limit_ - start_); |
| 394 marker_ -= start_offset; | 397 marker_ -= start_offset; |
| 395 cursor_ -= start_offset; | 398 cursor_ -= start_offset; |
| 396 limit_ -= start_offset; | 399 limit_ -= start_offset; |
| 397 start_ -= start_offset; | 400 start_ -= start_offset; |
| 398 real_start_ += start_offset; | 401 real_start_ += start_offset; |
| 399 } | 402 } |
| 400 return 0; | 403 return 0; |
| 401 } | 404 } |
| OLD | NEW |