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 24 matching lines...) Expand all Loading... |
35 #include "checks.h" | 35 #include "checks.h" |
36 #include "globals.h" | 36 #include "globals.h" |
37 #include "token.h" | 37 #include "token.h" |
38 #include "unicode-inl.h" | 38 #include "unicode-inl.h" |
39 #include "utils.h" | 39 #include "utils.h" |
40 | 40 |
41 namespace v8 { | 41 namespace v8 { |
42 namespace internal { | 42 namespace internal { |
43 | 43 |
44 | 44 |
45 // General collection of (multi-)bit-flags that can be passed to scanners and | |
46 // parsers to signify their (initial) mode of operation. | |
47 enum ParsingFlags { | |
48 kNoParsingFlags = 0, | |
49 // Embed LanguageMode values in parsing flags, i.e., equivalent to: | |
50 // CLASSIC_MODE = 0, | |
51 // STRICT_MODE, | |
52 // EXTENDED_MODE, | |
53 kLanguageModeMask = 0x03, | |
54 kAllowLazy = 0x04, | |
55 kAllowNativesSyntax = 0x08, | |
56 kAllowModules = 0x10, | |
57 kAllowGenerators = 0x20 | |
58 }; | |
59 | |
60 STATIC_ASSERT((kLanguageModeMask & CLASSIC_MODE) == CLASSIC_MODE); | |
61 STATIC_ASSERT((kLanguageModeMask & STRICT_MODE) == STRICT_MODE); | |
62 STATIC_ASSERT((kLanguageModeMask & EXTENDED_MODE) == EXTENDED_MODE); | |
63 | |
64 | |
65 // Returns the value (0 .. 15) of a hexadecimal character c. | 45 // Returns the value (0 .. 15) of a hexadecimal character c. |
66 // If c is not a legal hexadecimal character, returns a value < 0. | 46 // If c is not a legal hexadecimal character, returns a value < 0. |
67 inline int HexValue(uc32 c) { | 47 inline int HexValue(uc32 c) { |
68 c -= '0'; | 48 c -= '0'; |
69 if (static_cast<unsigned>(c) <= 9) return c; | 49 if (static_cast<unsigned>(c) <= 9) return c; |
70 c = (c | 0x20) - ('a' - '0'); // detect 0x11..0x16 and 0x31..0x36. | 50 c = (c | 0x20) - ('a' - '0'); // detect 0x11..0x16 and 0x31..0x36. |
71 if (static_cast<unsigned>(c) <= 5) return c + 10; | 51 if (static_cast<unsigned>(c) <= 5) return c + 10; |
72 return -1; | 52 return -1; |
73 } | 53 } |
74 | 54 |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 bool has_multiline_comment_before_next_; | 542 bool has_multiline_comment_before_next_; |
563 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. | 543 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. |
564 bool harmony_scoping_; | 544 bool harmony_scoping_; |
565 // Whether we scan 'module', 'import', 'export' as keywords. | 545 // Whether we scan 'module', 'import', 'export' as keywords. |
566 bool harmony_modules_; | 546 bool harmony_modules_; |
567 }; | 547 }; |
568 | 548 |
569 } } // namespace v8::internal | 549 } } // namespace v8::internal |
570 | 550 |
571 #endif // V8_SCANNER_H_ | 551 #endif // V8_SCANNER_H_ |
OLD | NEW |