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 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_PREPARSER_H | 28 #ifndef V8_PREPARSER_H |
29 #define V8_PREPARSER_H | 29 #define V8_PREPARSER_H |
30 | 30 |
| 31 #include "token.h" |
| 32 #include "scanner.h" |
| 33 |
31 namespace v8 { | 34 namespace v8 { |
| 35 |
| 36 namespace internal { |
| 37 class UnicodeCache; |
| 38 } |
| 39 |
32 namespace preparser { | 40 namespace preparser { |
33 | 41 |
34 typedef uint8_t byte; | 42 typedef uint8_t byte; |
35 | 43 |
36 // Preparsing checks a JavaScript program and emits preparse-data that helps | 44 // Preparsing checks a JavaScript program and emits preparse-data that helps |
37 // a later parsing to be faster. | 45 // a later parsing to be faster. |
38 // See preparse-data-format.h for the data format. | 46 // See preparse-data-format.h for the data format. |
39 | 47 |
40 // The PreParser checks that the syntax follows the grammar for JavaScript, | 48 // The PreParser checks that the syntax follows the grammar for JavaScript, |
41 // and collects some information about the program along the way. | 49 // and collects some information about the program along the way. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 }; | 107 }; |
100 | 108 |
101 | 109 |
102 class PreParser { | 110 class PreParser { |
103 public: | 111 public: |
104 enum PreParseResult { | 112 enum PreParseResult { |
105 kPreParseStackOverflow, | 113 kPreParseStackOverflow, |
106 kPreParseSuccess | 114 kPreParseSuccess |
107 }; | 115 }; |
108 | 116 |
109 ~PreParser() { } | 117 ~PreParser() {} |
110 | 118 |
111 // Pre-parse the program from the character stream; returns true on | 119 // Pre-parse the program from the character stream; returns true on |
112 // success (even if parsing failed, the pre-parse data successfully | 120 // success (even if parsing failed, the pre-parse data successfully |
113 // captured the syntax error), and false if a stack-overflow happened | 121 // captured the syntax error), and false if a stack-overflow happened |
114 // during parsing. | 122 // during parsing. |
115 static PreParseResult PreParseProgram(i::JavaScriptScanner* scanner, | 123 static PreParseResult PreParseProgram(i::JavaScriptScanner* scanner, |
116 i::ParserRecorder* log, | 124 i::ParserRecorder* log, |
117 bool allow_lazy, | 125 bool allow_lazy, |
118 uintptr_t stack_limit) { | 126 uintptr_t stack_limit) { |
119 return PreParser(scanner, log, stack_limit, allow_lazy).PreParse(); | 127 return PreParser(scanner, log, stack_limit, allow_lazy).PreParse(); |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 i::Scanner::Location strict_mode_violation_location_; | 610 i::Scanner::Location strict_mode_violation_location_; |
603 const char* strict_mode_violation_type_; | 611 const char* strict_mode_violation_type_; |
604 bool stack_overflow_; | 612 bool stack_overflow_; |
605 bool allow_lazy_; | 613 bool allow_lazy_; |
606 bool parenthesized_function_; | 614 bool parenthesized_function_; |
607 bool harmony_block_scoping_; | 615 bool harmony_block_scoping_; |
608 }; | 616 }; |
609 } } // v8::preparser | 617 } } // v8::preparser |
610 | 618 |
611 #endif // V8_PREPARSER_H | 619 #endif // V8_PREPARSER_H |
OLD | NEW |