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

Unified Diff: src/parsing/parser-base.h

Issue 2312263002: [parser] Refactor of Parse*Statement*, part 2 (Closed)
Patch Set: The real patch Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index bdb2cad9c31162df670ea7c0cc0d7f2f8c7d99da..6dfa4a7d17f488f748c8535aeef0d98fbf387fe8 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -1219,6 +1219,7 @@ class ParserBase {
bool* ok);
StatementT ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels,
bool* ok);
+ BlockT ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok);
bool IsNextLetKeyword();
bool IsTrivialExpression();
@@ -4201,6 +4202,36 @@ ParserBase<Impl>::ParseStatementAsUnlabelled(
}
}
+template <typename Impl>
+typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseBlock(
+ ZoneList<const AstRawString*>* labels, bool* ok) {
+ // Block ::
+ // '{' StatementList '}'
+
+ // Construct block expecting 16 statements.
+ BlockT body = factory()->NewBlock(labels, 16, false, kNoSourcePosition);
+
+ // Parse the statements and collect escaping labels.
+ Expect(Token::LBRACE, CHECK_OK_CUSTOM(NullBlock));
+ {
+ BlockState block_state(&scope_state_);
+ block_state.set_start_position(scanner()->location().beg_pos);
+ typename Types::Target target(this, body);
+
+ while (peek() != Token::RBRACE) {
+ StatementT stat = ParseStatementListItem(CHECK_OK_CUSTOM(NullBlock));
+ if (!impl()->IsNullOrEmptyStatement(stat)) {
+ body->statements()->Add(stat, zone());
+ }
+ }
+
+ Expect(Token::RBRACE, CHECK_OK_CUSTOM(NullBlock));
+ block_state.set_end_position(scanner()->location().end_pos);
+ body->set_scope(block_state.FinalizedBlockScope());
+ }
+ return body;
+}
+
#undef CHECK_OK
#undef CHECK_OK_CUSTOM
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698