| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 // General collection of (multi-)bit-flags that can be passed to scanners and | 45 // General collection of (multi-)bit-flags that can be passed to scanners and |
| 46 // parsers to signify their (initial) mode of operation. | 46 // parsers to signify their (initial) mode of operation. |
| 47 enum ParsingFlags { | 47 enum ParsingFlags { |
| 48 kNoParsingFlags = 0, | 48 kNoParsingFlags = 0, |
| 49 // Embed LanguageMode values in parsing flags, i.e., equivalent to: | 49 // Embed LanguageMode values in parsing flags, i.e., equivalent to: |
| 50 // CLASSIC_MODE = 0, | 50 // CLASSIC_MODE = 0, |
| 51 // STRICT_MODE, | 51 // STRICT_MODE, |
| 52 // EXTENDED_MODE, | 52 // EXTENDED_MODE, |
| 53 kLanguageModeMask = 0x03, | 53 kLanguageModeMask = 0x03, |
| 54 kAllowLazy = 4, | 54 kAllowLazy = 0x04, |
| 55 kAllowNativesSyntax = 8 | 55 kAllowNativesSyntax = 0x08, |
| 56 kAllowModules = 0x10 |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 STATIC_ASSERT((kLanguageModeMask & CLASSIC_MODE) == CLASSIC_MODE); | 59 STATIC_ASSERT((kLanguageModeMask & CLASSIC_MODE) == CLASSIC_MODE); |
| 59 STATIC_ASSERT((kLanguageModeMask & STRICT_MODE) == STRICT_MODE); | 60 STATIC_ASSERT((kLanguageModeMask & STRICT_MODE) == STRICT_MODE); |
| 60 STATIC_ASSERT((kLanguageModeMask & EXTENDED_MODE) == EXTENDED_MODE); | 61 STATIC_ASSERT((kLanguageModeMask & EXTENDED_MODE) == EXTENDED_MODE); |
| 61 | 62 |
| 62 | 63 |
| 63 // Returns the value (0 .. 15) of a hexadecimal character c. | 64 // Returns the value (0 .. 15) of a hexadecimal character c. |
| 64 // If c is not a legal hexadecimal character, returns a value < 0. | 65 // If c is not a legal hexadecimal character, returns a value < 0. |
| 65 inline int HexValue(uc32 c) { | 66 inline int HexValue(uc32 c) { |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 397 |
| 397 // Seek forward to the given position. This operation does not | 398 // Seek forward to the given position. This operation does not |
| 398 // work in general, for instance when there are pushed back | 399 // work in general, for instance when there are pushed back |
| 399 // characters, but works for seeking forward until simple delimiter | 400 // characters, but works for seeking forward until simple delimiter |
| 400 // tokens, which is what it is used for. | 401 // tokens, which is what it is used for. |
| 401 void SeekForward(int pos); | 402 void SeekForward(int pos); |
| 402 | 403 |
| 403 bool HarmonyScoping() const { | 404 bool HarmonyScoping() const { |
| 404 return harmony_scoping_; | 405 return harmony_scoping_; |
| 405 } | 406 } |
| 406 void SetHarmonyScoping(bool block_scoping) { | 407 void SetHarmonyScoping(bool scoping) { |
| 407 harmony_scoping_ = block_scoping; | 408 harmony_scoping_ = scoping; |
| 409 } |
| 410 bool HarmonyModules() const { |
| 411 return harmony_modules_; |
| 412 } |
| 413 void SetHarmonyModules(bool modules) { |
| 414 harmony_modules_ = modules; |
| 408 } | 415 } |
| 409 | 416 |
| 410 | 417 |
| 411 // Returns true if there was a line terminator before the peek'ed token, | 418 // Returns true if there was a line terminator before the peek'ed token, |
| 412 // possibly inside a multi-line comment. | 419 // possibly inside a multi-line comment. |
| 413 bool HasAnyLineTerminatorBeforeNext() const { | 420 bool HasAnyLineTerminatorBeforeNext() const { |
| 414 return has_line_terminator_before_next_ || | 421 return has_line_terminator_before_next_ || |
| 415 has_multiline_comment_before_next_; | 422 has_multiline_comment_before_next_; |
| 416 } | 423 } |
| 417 | 424 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 // One Unicode character look-ahead; c0_ < 0 at the end of the input. | 552 // One Unicode character look-ahead; c0_ < 0 at the end of the input. |
| 546 uc32 c0_; | 553 uc32 c0_; |
| 547 | 554 |
| 548 // Whether there is a line terminator whitespace character after | 555 // Whether there is a line terminator whitespace character after |
| 549 // the current token, and before the next. Does not count newlines | 556 // the current token, and before the next. Does not count newlines |
| 550 // inside multiline comments. | 557 // inside multiline comments. |
| 551 bool has_line_terminator_before_next_; | 558 bool has_line_terminator_before_next_; |
| 552 // Whether there is a multi-line comment that contains a | 559 // Whether there is a multi-line comment that contains a |
| 553 // line-terminator after the current token, and before the next. | 560 // line-terminator after the current token, and before the next. |
| 554 bool has_multiline_comment_before_next_; | 561 bool has_multiline_comment_before_next_; |
| 555 // Whether we scan 'let' as a keyword for harmony block scoped | 562 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. |
| 556 // let bindings. | |
| 557 bool harmony_scoping_; | 563 bool harmony_scoping_; |
| 564 // Whether we scan 'module', 'import', 'export' as keywords. |
| 565 bool harmony_modules_; |
| 558 }; | 566 }; |
| 559 | 567 |
| 560 } } // namespace v8::internal | 568 } } // namespace v8::internal |
| 561 | 569 |
| 562 #endif // V8_SCANNER_H_ | 570 #endif // V8_SCANNER_H_ |
| OLD | NEW |