Skip to content

Commit 9e4e2ad

Browse files
committed
refactor(new_ts): fix more syntax error issues
1 parent a181540 commit 9e4e2ad

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

chapi-ast-typescript/src/main/antlr/TypeScriptParser.g4

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ decoratorMemberExpression
308308
;
309309

310310
decoratorCallExpression
311-
: decoratorMemberExpression arguments;
312-
313-
311+
: decoratorMemberExpression arguments
312+
| objectLiteral
313+
;
314314

315315
// Interface
316316

@@ -341,7 +341,13 @@ interfaceMember
341341
| getAccessor
342342
| setAccessor
343343
| methodSignature
344+
| enumSignature
344345
| propertySignature
346+
| '[' typeRef In (Keyof | Typeof)* typeRef ']' '?'? typeAnnotation
347+
;
348+
349+
enumSignature
350+
: identifierOrKeyWord '?'? ':' '|'? typeRef ('|' typeRef)*
345351
;
346352

347353
constructSignature
@@ -480,7 +486,7 @@ initializer
480486

481487

482488
parameterBlock
483-
: '(' formalParameterList? ')'
489+
: '(' (This typeAnnotation? ',')? ( formalParameterList ','?)? ')'
484490
;
485491

486492

@@ -492,14 +498,14 @@ formalParameterArg
492498
: decoratorList? accessibilityModifier? ReadOnly? identifierOrKeyWord '?'? typeAnnotation? ('=' singleExpression)? // ECMAScript 6: Initialization
493499
| lastFormalParameterArg
494500
// ([key, value]: [string, string[]])
495-
| arrayLiteral (':' formalParameterList)? // ECMAScript 6: Parameter Context Matching
496-
| objectLiteral (':' formalParameterList)? // ECMAScript 6: Parameter Context Matching
501+
// | arrayLiteral (':' formalParameterList)? // ECMAScript 6: Parameter Context Matching
502+
// | objectLiteral (':' formalParameterList)? // ECMAScript 6: Parameter Context Matching
497503
// `addThing({ payload }, { call }){}`
498-
| objectLiteral (',' objectLiteral)* // ECMAScript 6: Parameter Context Matching
504+
// | objectLiteral (',' objectLiteral)* // ECMAScript 6: Parameter Context Matching
499505
;
500506

501507
lastFormalParameterArg // ECMAScript 6: Rest Parameter
502-
: Ellipsis Identifier
508+
: Ellipsis identifierOrPattern typeAnnotation?
503509
;
504510

505511
parameterList
@@ -561,6 +567,7 @@ accessibilityModifier
561567
: Public
562568
| Private
563569
| Protected
570+
| ReadOnly
564571
;
565572

566573
identifierOrPattern
@@ -610,6 +617,7 @@ propertyAssignment
610617
: propertyName (':' identifierOrKeyWord | bindingPattern)? ('=' singleExpression)? # PropertyExpressionAssignment
611618
| propertyName '?'? (':' |'=') singleExpression # PropertyExpressionAssignment
612619
| '[' singleExpression ']' '?'? ':' singleExpression # ComputedPropertyExpressionAssignment
620+
| propertyName '?'? (':' |'=') '[' singleExpression ']' # PropertyExpressionAssignment
613621
| getAccessor # PropertyGetter
614622
| setAccessor # PropertySetter
615623
| generatorMethod # MethodProperty

0 commit comments

Comments
 (0)