Skip to content

Commit

Permalink
fix(ts): fix undefined issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 11, 2022
1 parent 691f7d6 commit 3815710
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
2 changes: 2 additions & 0 deletions chapi-ast-typescript/src/main/antlr/TypeScriptLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ Require: 'require';
Module: 'module';
Declare: 'declare';

Undefined: 'undefined';

Abstract: 'abstract';

Is: 'is';
Expand Down
52 changes: 27 additions & 25 deletions chapi-ast-typescript/src/main/antlr/TypeScriptLexer.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,27 @@ Namespace=122
Require=123
Module=124
Declare=125
Abstract=126
Is=127
At=128
Identifier=129
StringLiteral=130
BackTick=131
WhiteSpaces=132
LineTerminator=133
HtmlComment=134
CDataComment=135
UnexpectedCharacter=136
TemplateStringStartExpression=137
TemplateStringAtom=138
TagOpen=139
TagClose=140
TagSlashClose=141
TagSlash=142
TagName=143
AttributeValue=144
Attribute=145
Undefined=126
Abstract=127
Is=128
At=129
Identifier=130
StringLiteral=131
BackTick=132
WhiteSpaces=133
LineTerminator=134
HtmlComment=135
CDataComment=136
UnexpectedCharacter=137
TemplateStringStartExpression=138
TemplateStringAtom=139
TagOpen=140
TagClose=141
TagSlashClose=142
TagSlash=143
TagName=144
AttributeValue=145
Attribute=146
'['=4
']'=5
'('=6
Expand Down Expand Up @@ -258,8 +259,9 @@ Attribute=145
'require'=123
'module'=124
'declare'=125
'abstract'=126
'is'=127
'@'=128
'${'=137
'/>'=141
'undefined'=126
'abstract'=127
'is'=128
'@'=129
'${'=138
'/>'=142
12 changes: 6 additions & 6 deletions chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ primaryType
| typeQuery #QueryPrimType
| This #ThisPrimType
| typeReference Is primaryType #RedefinitionOfType
| 'undefined' #UndefinedType
;

predefinedType
Expand Down Expand Up @@ -523,6 +524,7 @@ htmlTagName
htmlAttribute
: htmlAttributeName '=' htmlAttributeValue
| htmlAttributeName
| objectLiteral
;

htmlAttributeName
Expand Down Expand Up @@ -754,17 +756,15 @@ expressionSequence
functionExpressionDeclaration
: Function_ Identifier? '(' formalParameterList? ')' typeAnnotation? '{' functionBody '}'
;
//
//anoymousFunction
// : functionDeclaration # FunctionDecl
// | Async? Function_ '*'? '(' formalParameterList? ')' '{' functionBody '}' # AnoymousFunctionDecl
// | Async? arrowFunctionParameters '=>' arrowFunctionBody # ArrowFunction
// ;

jsxArrowFunction
: '(' formalParameterList (',' formalParameterList)* ')' '=>' arrowFunctionBody # JsxArrowFunctionDecl
;

singleExpression
: functionExpressionDeclaration # FunctionExpression
| arrowFunctionDeclaration # ArrowFunctionExpression // ECMAScript 6
| jsxArrowFunction # JsxArrowFunctionExpression
| Class Identifier? classTail # ClassExpression
| singleExpression '[' expressionSequence ']' # MemberIndexExpression
| singleExpression '?'? '!'? '.' '#'? identifierName nestedTypeGeneric? # MemberDotExpression
Expand Down

0 comments on commit 3815710

Please # to comment.