@@ -286,19 +286,19 @@ defType :
286
286
DEFSTR | DEFOBJ | DEFVAR
287
287
;
288
288
// universalLetterRange must appear before letterRange because they both match the same amount in the case of A-Z but we prefer the universalLetterRange.
289
- letterSpec : singleLetter | universalLetterRange | letterRange;
290
- singleLetter : unrestrictedIdentifier;
289
+ // singleLetter must appear at the end to prevent premature bailout
290
+ letterSpec : universalLetterRange | letterRange | singleLetter;
291
+
292
+ // we're purpusefully not actually making sure this is an ASCII letter
293
+ // that'd be too much of a hassle with the lexer to get working
294
+ singleLetter : {_input.Lt(1 ).Text.Length == 1 } ? IDENTIFIER ;
291
295
// We make a separate universalLetterRange rule because it is treated specially in VBA. This makes it easy for users of the parser
292
296
// to identify this case. Quoting MS VBAL:
293
297
// "A <universal-letter-range> defines a single implicit declared type for every <IDENTIFIER> within
294
298
// a module, even those with a first character that would otherwise fall outside this range if it was
295
299
// interpreted as a <letter-range> from A-Z.""
296
- universalLetterRange : upperCaseA whiteSpace? MINUS whiteSpace? upperCaseZ;
297
- upperCaseA : {_input.Lt(1 ).Text.Equals(" A" )} ? unrestrictedIdentifier;
298
- upperCaseZ : {_input.Lt(1 ).Text.Equals(" Z" )} ? unrestrictedIdentifier;
299
- letterRange : firstLetter whiteSpace? MINUS whiteSpace? lastLetter;
300
- firstLetter : unrestrictedIdentifier;
301
- lastLetter : unrestrictedIdentifier;
300
+ universalLetterRange : {_input.Lt(1 ).Text.StartsWith(" A" ) && _input.Lt(1 ).Text.EndsWith(" Z" )} ? LETTER_RANGE ;
301
+ letterRange : LETTER_RANGE ;
302
302
303
303
doLoopStmt :
304
304
DO endOfStatement
@@ -534,7 +534,7 @@ lineSpecialForm : expression whiteSpace (STEP whiteSpace?)? tuple MINUS (STEP wh
534
534
circleSpecialForm : (expression whiteSpace? DOT whiteSpace?)? CIRCLE whiteSpace (STEP whiteSpace?)? tuple (whiteSpace? COMMA whiteSpace? expression)+;
535
535
scaleSpecialForm : (expression whiteSpace? DOT whiteSpace?)? SCALE whiteSpace tuple whiteSpace? MINUS whiteSpace? tuple;
536
536
tuple : LPAREN whiteSpace? expression whiteSpace? COMMA whiteSpace? expression whiteSpace? RPAREN ;
537
- lineSpecialFormOption : ( B_CHAR | BF ) ;
537
+ lineSpecialFormOption : {_input.Lt( 1 ).Text.ToLower().Equals( " b " ) || _input.Lt( 1 ).Text.ToLower().Equals( " bf " )} ? unrestrictedIdentifier ;
538
538
539
539
subscripts : subscript (whiteSpace? COMMA whiteSpace? subscript)*;
540
540
@@ -544,7 +544,7 @@ unrestrictedIdentifier : identifier | statementKeyword | markerKeyword;
544
544
identifier : typedIdentifier | untypedIdentifier;
545
545
untypedIdentifier : identifierValue;
546
546
typedIdentifier : untypedIdentifier typeHint;
547
- identifierValue : IDENTIFIER | keyword | foreignName | BF ;
547
+ identifierValue : IDENTIFIER | keyword | foreignName;
548
548
foreignName : L_SQUARE_BRACKET foreignIdentifier* R_SQUARE_BRACKET ;
549
549
foreignIdentifier : ~(L_SQUARE_BRACKET | R_SQUARE_BRACKET ) | foreignName;
550
550
@@ -679,7 +679,6 @@ keyword :
679
679
| ANY
680
680
| ARRAY
681
681
| ATTRIBUTE
682
- | B_CHAR
683
682
| BEGIN
684
683
| BOOLEAN
685
684
| BYREF
0 commit comments