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

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

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. 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 5b56213df816980f78298107590c8f0cd0bdaf88..56b8cb36d7d8580c784b7c67b848e4603aa3e610 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -88,6 +88,7 @@ class ParserBase : public Traits {
typedef typename Traits::Type::FunctionLiteral FunctionLiteralT;
typedef typename Traits::Type::Literal LiteralT;
typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT;
+ typedef typename Traits::Type::Statement StatementT;
typedef typename Traits::Type::StatementList StatementListT;
typedef typename Traits::Type::ExpressionClassifier ExpressionClassifier;
typedef typename Traits::Type::TypeSystem TypeSystem;
@@ -852,6 +853,7 @@ class ParserBase : public Traits {
typename TypeSystem::TypeList ParseTypeArguments(bool* ok);
IdentifierListT ParsePropertyNameList(bool* ok);
typename TypeSystem::TypeMember ParseTypeMember(bool* ok);
+ StatementT ParseTypeAliasDeclaration(int pos, bool* ok);
typename TypeSystem::Type ValidateType(typename TypeSystem::Type type,
Scanner::Location location, bool* ok) {
@@ -3598,6 +3600,35 @@ ParserBase<Traits>::ParseTypeMember(bool* ok) {
}
+template <typename Traits>
+typename ParserBase<Traits>::StatementT
+ParserBase<Traits>::ParseTypeAliasDeclaration(int pos, bool* ok) {
+ // TypeAliasDeclaration ::
+ // 'type' BindingIdentifier [ TypeParameters ] '=' Type ';'
+ typename ParserBase<Traits>::StatementT empty =
+ factory()->NewEmptyStatement(pos);
+ IdentifierT name = ParseIdentifierName(ok);
+ if (!*ok) return empty;
+ // Parse optional type parameters.
+ typename TypeSystem::TypeParameters type_parameters =
+ this->NullTypeParameters();
+ if (peek() == Token::LT) {
+ type_parameters = ParseTypeParameters(ok);
+ if (!*ok) return empty;
+ }
+ Expect(Token::ASSIGN, ok);
+ if (!*ok) return empty;
+ typename TypeSystem::Type type = ParseValidType(ok);
+ if (!*ok) return empty;
+ ExpectSemicolon(ok);
+ if (!*ok) return empty;
+ USE(name); // TODO(nikolaos): really use them!
+ USE(type_parameters);
+ USE(type);
+ return empty;
+}
+
+
#undef CHECK_OK
#undef CHECK_OK_CUSTOM
#undef CHECK_OK_TYPE
« 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