From 4640f34874ec34cd3fe322e60201c51301cabb77 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Thu, 17 Nov 2022 08:20:54 +0800 Subject: [PATCH] fix(ts): fix function error issues --- .../src/main/antlr/TypeScriptParser.g4 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 index 1a4ab879..327abf86 100644 --- a/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 +++ b/chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4 @@ -905,7 +905,6 @@ singleExpression | singleExpression ('.' | '?''.') identifierName # PropertyAccessExpression | New (Dot Target| singleExpression ) # NewExpression // find arguments first, then found the call expression -// | singleExpression typeArguments? arguments # ArgumentsExpression | '(' expressionSequence ')' # ParenthesizedExpression // TODO: @@ -914,17 +913,22 @@ singleExpression | This # ThisExpression | Super # SuperExpression - | identifierName # IdentifierExpression + | typeArguments? identifierName # IdentifierExpression | literal # LiteralExpression | arrayLiteral # ArrayLiteralExpression | objectLiteral # ObjectLiteralExpression | templateStringLiteral # TemplateStringExpression + | singleExpression As asExpression # CastAsExpression + // TODO: careful use those + | singleExpression typeArguments? arguments # ArgumentsExpression | htmlElements # HtmlElementExpression ; - +asExpression + : singleExpression + ; functionExpression : Function '*'? Identifier? '(' formalParameterList? ')' typeAnnotation? '{' functionBody '}'