Chromium Code Reviews

Side by Side Diff: src/parsing/preparser.cc

Issue 1839393002: Add parsing for type aliases (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@types-1841093002-fun-decl
Patch Set: More tests and allow type as an indentifier Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « src/parsing/preparser.h ('k') | test/cctest/test-parsing.cc » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 175 matching lines...)
186 case Token::CONST: 186 case Token::CONST:
187 if (allow_const()) { 187 if (allow_const()) {
188 return ParseVariableStatement(kStatementListItem, ok); 188 return ParseVariableStatement(kStatementListItem, ok);
189 } 189 }
190 break; 190 break;
191 case Token::LET: 191 case Token::LET:
192 if (IsNextLetKeyword()) { 192 if (IsNextLetKeyword()) {
193 return ParseVariableStatement(kStatementListItem, ok); 193 return ParseVariableStatement(kStatementListItem, ok);
194 } 194 }
195 break; 195 break;
196 case Token::IDENTIFIER: {
197 if (!scope_->typed()) break;
198 int pos = peek_position();
199 if (PeekContextualKeyword(CStrVector("type")) &&
200 PeekAhead() == Token::IDENTIFIER) {
201 Consume(Token::IDENTIFIER);
202 return ParseTypeAliasDeclaration(pos, ok);
203 }
204 break;
205 }
206 // TODO(nikolaos): interface
207 // TODO(nikolaos): ambient
196 default: 208 default:
197 break; 209 break;
198 } 210 }
199 return ParseStatement(ok); 211 return ParseStatement(ok);
200 } 212 }
201 213
202 214
203 void PreParser::ParseStatementList(int end_token, bool* ok, 215 void PreParser::ParseStatementList(int end_token, bool* ok,
204 Scanner::BookmarkScope* bookmark) { 216 Scanner::BookmarkScope* bookmark) {
205 // SourceElements :: 217 // SourceElements ::
(...skipping 988 matching lines...)
1194 Expect(Token::RBRACE, CHECK_OK); 1206 Expect(Token::RBRACE, CHECK_OK);
1195 return PreParserExpression::Default(); 1207 return PreParserExpression::Default();
1196 } 1208 }
1197 } 1209 }
1198 1210
1199 #undef CHECK_OK 1211 #undef CHECK_OK
1200 1212
1201 1213
1202 } // namespace internal 1214 } // namespace internal
1203 } // namespace v8 1215 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine