@@ -502,8 +502,9 @@ subroutineName : identifier;
502
502
// 5.2.3.3 User Defined Type Declarations
503
503
publicTypeDeclaration : ((GLOBAL | PUBLIC ) whiteSpace)? udtDeclaration;
504
504
privateTypeDeclaration : PRIVATE whiteSpace udtDeclaration;
505
- udtDeclaration : TYPE whiteSpace untypedIdentifier endOfStatement udtMemberList endOfStatement END_TYPE ;
506
- udtMemberList : udtMember (endOfStatement udtMember)*;
505
+ // member list includes trailing endOfStatement
506
+ udtDeclaration : TYPE whiteSpace untypedIdentifier endOfStatement udtMemberList END_TYPE ;
507
+ udtMemberList : (udtMember endOfStatement)+;
507
508
udtMember : reservedNameMemberDeclaration | untypedNameMemberDeclaration;
508
509
untypedNameMemberDeclaration : untypedIdentifier whiteSpace? optionalArrayClause;
509
510
reservedNameMemberDeclaration : unrestrictedIdentifier whiteSpace asTypeClause;
@@ -864,21 +865,24 @@ endOfLine :
864
865
| whiteSpace? commentOrAnnotation
865
866
;
866
867
868
+ // we expect endOfStatement to consume all trailing whitespace
867
869
endOfStatement :
868
- (endOfLine | (whiteSpace? COLON whiteSpace?))+
870
+ (endOfLine whiteSpace? | (whiteSpace? COLON whiteSpace?))+
869
871
| whiteSpace? EOF
870
872
;
871
873
872
874
// Annotations must come before comments because of precedence. ANTLR4 matches as much as possible then chooses the one that comes first.
873
875
commentOrAnnotation :
874
- annotationList
876
+ ( annotationList
875
877
| remComment
876
- | comment
878
+ | comment)
879
+ // all comments must end with a logical line. See VBA Language Spec 3.3.1
880
+ (NEWLINE | EOF )
877
881
;
878
882
remComment : REM whiteSpace? commentBody;
879
883
comment : SINGLEQUOTE commentBody;
880
- commentBody : (LINE_CONTINUATION | ~NEWLINE )*;
881
- annotationList : SINGLEQUOTE (AT annotation whiteSpace?)+ (whiteSpace? COLON commentBody)?;
884
+ commentBody : (~NEWLINE )*;
885
+ annotationList : SINGLEQUOTE (AT annotation whiteSpace?)+ (COLON commentBody)?;
882
886
annotation : annotationName annotationArgList?;
883
887
annotationName : unrestrictedIdentifier;
884
888
annotationArgList :
0 commit comments