Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Side by Side Diff: src/preparser.h

Issue 9352013: Extend scanner with new Harmony module keywords (under flag). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Michael's comments. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/parser.cc ('k') | src/scanner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 enum PreParseResult { 108 enum PreParseResult {
109 kPreParseStackOverflow, 109 kPreParseStackOverflow,
110 kPreParseSuccess 110 kPreParseSuccess
111 }; 111 };
112 112
113 113
114 PreParser(i::Scanner* scanner, 114 PreParser(i::Scanner* scanner,
115 i::ParserRecorder* log, 115 i::ParserRecorder* log,
116 uintptr_t stack_limit, 116 uintptr_t stack_limit,
117 bool allow_lazy, 117 bool allow_lazy,
118 bool allow_natives_syntax) 118 bool allow_natives_syntax,
119 bool allow_modules)
119 : scanner_(scanner), 120 : scanner_(scanner),
120 log_(log), 121 log_(log),
121 scope_(NULL), 122 scope_(NULL),
122 stack_limit_(stack_limit), 123 stack_limit_(stack_limit),
123 strict_mode_violation_location_(i::Scanner::Location::invalid()), 124 strict_mode_violation_location_(i::Scanner::Location::invalid()),
124 strict_mode_violation_type_(NULL), 125 strict_mode_violation_type_(NULL),
125 stack_overflow_(false), 126 stack_overflow_(false),
126 allow_lazy_(allow_lazy), 127 allow_lazy_(allow_lazy),
128 allow_modules_(allow_modules),
127 allow_natives_syntax_(allow_natives_syntax), 129 allow_natives_syntax_(allow_natives_syntax),
128 parenthesized_function_(false), 130 parenthesized_function_(false),
129 harmony_scoping_(scanner->HarmonyScoping()) { } 131 harmony_scoping_(scanner->HarmonyScoping()) { }
130 132
131 ~PreParser() {} 133 ~PreParser() {}
132 134
133 // Pre-parse the program from the character stream; returns true on 135 // Pre-parse the program from the character stream; returns true on
134 // success (even if parsing failed, the pre-parse data successfully 136 // success (even if parsing failed, the pre-parse data successfully
135 // captured the syntax error), and false if a stack-overflow happened 137 // captured the syntax error), and false if a stack-overflow happened
136 // during parsing. 138 // during parsing.
137 static PreParseResult PreParseProgram(i::Scanner* scanner, 139 static PreParseResult PreParseProgram(i::Scanner* scanner,
138 i::ParserRecorder* log, 140 i::ParserRecorder* log,
139 int flags, 141 int flags,
140 uintptr_t stack_limit) { 142 uintptr_t stack_limit) {
141 bool allow_lazy = (flags & i::kAllowLazy) != 0; 143 bool allow_lazy = (flags & i::kAllowLazy) != 0;
142 bool allow_natives_syntax = (flags & i::kAllowNativesSyntax) != 0; 144 bool allow_natives_syntax = (flags & i::kAllowNativesSyntax) != 0;
143 return PreParser(scanner, log, stack_limit, 145 bool allow_modules = (flags & i::kAllowModules) != 0;
144 allow_lazy, allow_natives_syntax).PreParse(); 146 return PreParser(scanner, log, stack_limit, allow_lazy,
147 allow_natives_syntax, allow_modules).PreParse();
145 } 148 }
146 149
147 // Parses a single function literal, from the opening parentheses before 150 // Parses a single function literal, from the opening parentheses before
148 // parameters to the closing brace after the body. 151 // parameters to the closing brace after the body.
149 // Returns a FunctionEntry describing the body of the funciton in enough 152 // Returns a FunctionEntry describing the body of the funciton in enough
150 // detail that it can be lazily compiled. 153 // detail that it can be lazily compiled.
151 // The scanner is expected to have matched the "function" keyword and 154 // The scanner is expected to have matched the "function" keyword and
152 // parameters, and have consumed the initial '{'. 155 // parameters, and have consumed the initial '{'.
153 // At return, unless an error occured, the scanner is positioned before the 156 // At return, unless an error occured, the scanner is positioned before the
154 // the final '}'. 157 // the final '}'.
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 bool* ok); 643 bool* ok);
641 644
642 i::Scanner* scanner_; 645 i::Scanner* scanner_;
643 i::ParserRecorder* log_; 646 i::ParserRecorder* log_;
644 Scope* scope_; 647 Scope* scope_;
645 uintptr_t stack_limit_; 648 uintptr_t stack_limit_;
646 i::Scanner::Location strict_mode_violation_location_; 649 i::Scanner::Location strict_mode_violation_location_;
647 const char* strict_mode_violation_type_; 650 const char* strict_mode_violation_type_;
648 bool stack_overflow_; 651 bool stack_overflow_;
649 bool allow_lazy_; 652 bool allow_lazy_;
653 bool allow_modules_;
650 bool allow_natives_syntax_; 654 bool allow_natives_syntax_;
651 bool parenthesized_function_; 655 bool parenthesized_function_;
652 bool harmony_scoping_; 656 bool harmony_scoping_;
653 }; 657 };
654 } } // v8::preparser 658 } } // v8::preparser
655 659
656 #endif // V8_PREPARSER_H 660 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698