@@ -518,6 +518,92 @@ typeHint : PERCENT | AMPERSAND | POW | EXCLAMATIONPOINT | HASH | AT | DOLLAR;
518
518
519
519
visibility : PRIVATE | PUBLIC | FRIEND | GLOBAL ;
520
520
521
+ // 5.6 Expressions
522
+ expression :
523
+ // Literal Expression has to come before lExpression, otherwise it'll be classified as simple name expression instead.
524
+ literalExpression # literalExpr
525
+ | lExpression # lExpr
526
+ | builtInType # builtInTypeExpr
527
+ | LPAREN whiteSpace? expression whiteSpace? RPAREN # parenthesizedExpr
528
+ | TYPEOF whiteSpace expression # typeofexpr // To make the grammar SLL, the type-of-is-expression is actually the child of an IS relational op.
529
+ | NEW whiteSpace expression # newExpr
530
+ | expression whiteSpace? POW whiteSpace? expression # powOp
531
+ | MINUS whiteSpace? expression # unaryMinusOp
532
+ | expression whiteSpace? (MULT | DIV ) whiteSpace? expression # multOp
533
+ | expression whiteSpace? INTDIV whiteSpace? expression # intDivOp
534
+ | expression whiteSpace? MOD whiteSpace? expression # modOp
535
+ | expression whiteSpace? (PLUS | MINUS ) whiteSpace? expression # addOp
536
+ | expression whiteSpace? AMPERSAND whiteSpace? expression # concatOp
537
+ | expression whiteSpace? (EQ | NEQ | LT | GT | LEQ | GEQ | LIKE | IS ) whiteSpace? expression # relationalOp
538
+ | NOT whiteSpace? expression # logicalNotOp
539
+ | expression whiteSpace? AND whiteSpace? expression # logicalAndOp
540
+ | expression whiteSpace? OR whiteSpace? expression # logicalOrOp
541
+ | expression whiteSpace? XOR whiteSpace? expression # logicalXorOp
542
+ | expression whiteSpace? EQV whiteSpace? expression # logicalEqvOp
543
+ | expression whiteSpace? IMP whiteSpace? expression # logicalImpOp
544
+ | HASH expression # markedFileNumberExpr // Added to support special forms such as Input(file1, #file1)
545
+ ;
546
+
547
+ // 5.6.5 Literal Expressions
548
+ literalExpression :
549
+ numberLiteral
550
+ | DATELITERAL
551
+ | STRINGLITERAL
552
+ | literalIdentifier typeHint?
553
+ ;
554
+
555
+ literalIdentifier : booleanLiteralIdentifier | objectLiteralIdentifier | variantLiteralIdentifier;
556
+ booleanLiteralIdentifier : TRUE | FALSE ;
557
+ objectLiteralIdentifier : NOTHING ;
558
+ variantLiteralIdentifier : EMPTY | NULL ;
559
+
560
+ lExpression :
561
+ lExpression whiteSpace? LPAREN whiteSpace? argumentList? whiteSpace? RPAREN # indexExpr
562
+ | lExpression DOT unrestrictedIdentifier # memberAccessExpr
563
+ | lExpression LINE_CONTINUATION whiteSpace? DOT unrestrictedIdentifier # memberAccessExpr
564
+ | lExpression EXCLAMATIONPOINT unrestrictedIdentifier # dictionaryAccessExpr
565
+ | lExpression LINE_CONTINUATION EXCLAMATIONPOINT unrestrictedIdentifier # dictionaryAccessExpr
566
+ | lExpression LINE_CONTINUATION EXCLAMATIONPOINT LINE_CONTINUATION unrestrictedIdentifier # dictionaryAccessExpr
567
+ | ME # instanceExpr
568
+ | identifier # simpleNameExpr
569
+ | DOT unrestrictedIdentifier # withMemberAccessExpr
570
+ | EXCLAMATIONPOINT unrestrictedIdentifier # withDictionaryAccessExpr
571
+ ;
572
+
573
+ // 3.3.5.3 Special Identifier Forms
574
+ builtInType :
575
+ baseType
576
+ | L_SQUARE_BRACKET whiteSpace? baseType whiteSpace? R_SQUARE_BRACKET
577
+ | OBJECT
578
+ | L_SQUARE_BRACKET whiteSpace? OBJECT whiteSpace? R_SQUARE_BRACKET
579
+ ;
580
+
581
+ // 5.6.13.1 Argument Lists
582
+ argumentList : positionalOrNamedArgumentList;
583
+ positionalOrNamedArgumentList :
584
+ (positionalArgumentOrMissing whiteSpace?)* requiredPositionalArgument
585
+ | (positionalArgumentOrMissing whiteSpace?)* namedArgumentList
586
+ ;
587
+ positionalArgumentOrMissing :
588
+ positionalArgument whiteSpace? COMMA # specifiedPositionalArgument
589
+ | whiteSpace? COMMA # missingPositionalArgument
590
+ ;
591
+ positionalArgument : argumentExpression;
592
+ requiredPositionalArgument : argumentExpression;
593
+ namedArgumentList : namedArgument (whiteSpace? COMMA whiteSpace? namedArgument)*;
594
+ namedArgument : unrestrictedIdentifier whiteSpace? ASSIGN whiteSpace? argumentExpression;
595
+ argumentExpression :
596
+ (BYVAL whiteSpace)? expression
597
+ | addressOfExpression
598
+ // Special case for redim statements. The resolver doesn't have to deal with this because it is "picked apart" in the redim statement.
599
+ | lowerBoundArgumentExpression whiteSpace TO whiteSpace upperBoundArgumentExpression
600
+ ;
601
+ lowerBoundArgumentExpression : expression;
602
+ upperBoundArgumentExpression : expression;
603
+
604
+ // 5.6.16.8 AddressOf Expressions
605
+ addressOfExpression : ADDRESSOF whiteSpace expression;
606
+
521
607
keyword :
522
608
ABS
523
609
| ADDRESSOF
@@ -542,7 +628,6 @@ keyword :
542
628
| CLNG
543
629
| CLNGLNG
544
630
| CLNGPTR
545
- | COLLECTION
546
631
| CSNG
547
632
| CSTR
548
633
| CURRENCY
@@ -551,7 +636,6 @@ keyword :
551
636
| DATABASE
552
637
| DATE
553
638
| DEBUG
554
- | DELETESETTING
555
639
| DOEVENTS
556
640
| DOUBLE
557
641
| END
@@ -592,9 +676,6 @@ keyword :
592
676
| PSET
593
677
| PTRSAFE
594
678
| REM
595
- | RMDIR
596
- | SENDKEYS
597
- | SETATTR
598
679
| SGN
599
680
| SINGLE
600
681
| SPC
@@ -738,92 +819,4 @@ annotationArgList :
738
819
| whiteSpace? LPAREN annotationArg (whiteSpace? COMMA whiteSpace? annotationArg)+ whiteSpace? RPAREN ;
739
820
annotationArg : expression;
740
821
741
- whiteSpace : (WS | LINE_CONTINUATION )+;
742
-
743
-
744
-
745
-
746
- // 5.6 Expressions
747
- expression :
748
- lExpression # lExpr
749
- | builtInType # builtInTypeExpr
750
- | LPAREN whiteSpace? expression whiteSpace? RPAREN # parenthesizedExpr
751
- | TYPEOF whiteSpace expression # typeofexpr // To make the grammar SLL, the type-of-is-expression is actually the child of an IS relational op.
752
- | NEW whiteSpace expression # newExpr
753
- | expression whiteSpace? POW whiteSpace? expression # powOp
754
- | MINUS whiteSpace? expression # unaryMinusOp
755
- | expression whiteSpace? (MULT | DIV ) whiteSpace? expression # multOp
756
- | expression whiteSpace? INTDIV whiteSpace? expression # intDivOp
757
- | expression whiteSpace? MOD whiteSpace? expression # modOp
758
- | expression whiteSpace? (PLUS | MINUS ) whiteSpace? expression # addOp
759
- | expression whiteSpace? AMPERSAND whiteSpace? expression # concatOp
760
- | expression whiteSpace? (EQ | NEQ | LT | GT | LEQ | GEQ | LIKE | IS ) whiteSpace? expression # relationalOp
761
- | NOT whiteSpace? expression # logicalNotOp
762
- | expression whiteSpace? AND whiteSpace? expression # logicalAndOp
763
- | expression whiteSpace? OR whiteSpace? expression # logicalOrOp
764
- | expression whiteSpace? XOR whiteSpace? expression # logicalXorOp
765
- | expression whiteSpace? EQV whiteSpace? expression # logicalEqvOp
766
- | expression whiteSpace? IMP whiteSpace? expression # logicalImpOp
767
- | literalExpression # literalExpr
768
- | HASH expression # markedFileNumberExpr // Added to support special forms such as Input(file1, #file1)
769
- ;
770
-
771
- // 5.6.5 Literal Expressions
772
- literalExpression :
773
- numberLiteral
774
- | DATELITERAL
775
- | STRINGLITERAL
776
- | literalIdentifier typeHint?
777
- ;
778
-
779
- literalIdentifier : booleanLiteralIdentifier | objectLiteralIdentifier | variantLiteralIdentifier;
780
- booleanLiteralIdentifier : TRUE | FALSE ;
781
- objectLiteralIdentifier : NOTHING ;
782
- variantLiteralIdentifier : EMPTY | NULL ;
783
-
784
- lExpression :
785
- lExpression whiteSpace? LPAREN whiteSpace? argumentList? whiteSpace? RPAREN # indexExpr
786
- | lExpression DOT unrestrictedIdentifier # memberAccessExpr
787
- | lExpression LINE_CONTINUATION whiteSpace? DOT unrestrictedIdentifier # memberAccessExpr
788
- | lExpression EXCLAMATIONPOINT unrestrictedIdentifier # dictionaryAccessExpr
789
- | lExpression LINE_CONTINUATION EXCLAMATIONPOINT unrestrictedIdentifier # dictionaryAccessExpr
790
- | lExpression LINE_CONTINUATION EXCLAMATIONPOINT LINE_CONTINUATION unrestrictedIdentifier # dictionaryAccessExpr
791
- | ME # instanceExpr
792
- | identifier # simpleNameExpr
793
- | DOT unrestrictedIdentifier # withMemberAccessExpr
794
- | EXCLAMATIONPOINT unrestrictedIdentifier # withDictionaryAccessExpr
795
- ;
796
-
797
- // 3.3.5.3 Special Identifier Forms
798
- builtInType :
799
- baseType
800
- | L_SQUARE_BRACKET whiteSpace? baseType whiteSpace? R_SQUARE_BRACKET
801
- | OBJECT
802
- | L_SQUARE_BRACKET whiteSpace? OBJECT whiteSpace? R_SQUARE_BRACKET
803
- ;
804
-
805
- // 5.6.13.1 Argument Lists
806
- argumentList : positionalOrNamedArgumentList;
807
- positionalOrNamedArgumentList :
808
- (positionalArgumentOrMissing whiteSpace?)* requiredPositionalArgument
809
- | (positionalArgumentOrMissing whiteSpace?)* namedArgumentList
810
- ;
811
- positionalArgumentOrMissing :
812
- positionalArgument whiteSpace? COMMA # specifiedPositionalArgument
813
- | whiteSpace? COMMA # missingPositionalArgument
814
- ;
815
- positionalArgument : argumentExpression;
816
- requiredPositionalArgument : argumentExpression;
817
- namedArgumentList : namedArgument (whiteSpace? COMMA whiteSpace? namedArgument)*;
818
- namedArgument : unrestrictedIdentifier whiteSpace? ASSIGN whiteSpace? argumentExpression;
819
- argumentExpression :
820
- (BYVAL whiteSpace)? expression
821
- | addressOfExpression
822
- // Special case for redim statements. The resolver doesn't have to deal with this because it is "picked apart" in the redim statement.
823
- | lowerBoundArgumentExpression whiteSpace TO whiteSpace upperBoundArgumentExpression
824
- ;
825
- lowerBoundArgumentExpression : expression;
826
- upperBoundArgumentExpression : expression;
827
-
828
- // 5.6.16.8 AddressOf Expressions
829
- addressOfExpression : ADDRESSOF whiteSpace expression;
822
+ whiteSpace : (WS | LINE_CONTINUATION )+;
0 commit comments