Skip to content

Commit 105d146

Browse files
committed
fine-tuned numeric tokens (closes #753)
1 parent 95c679e commit 105d146

File tree

5 files changed

+4030
-4015
lines changed

5 files changed

+4030
-4015
lines changed

RetailCoder.VBE/Inspections/OptionBaseInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public override IEnumerable<CodeInspectionResultBase> GetInspectionResults()
3030
return new List<CodeInspectionResultBase>();
3131
}
3232

33-
var issues = options.Where(option => ((VBAParser.OptionBaseStmtContext)option.Context).INTEGERLITERAL().GetText() == "1")
33+
var issues = options.Where(option => ((VBAParser.OptionBaseStmtContext)option.Context).SHORTLITERAL().GetText() == "1")
3434
.Select(issue => new OptionBaseInspectionResult(this, issue.QualifiedName.QualifiedModuleName));
3535

3636
return issues;

Rubberduck.Parsing/Grammar/VBA.g4

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ moduleAttributes : (attributeStmt NEWLINE+)+;
123123
moduleDeclarations : moduleDeclarationsElement (NEWLINE+ moduleDeclarationsElement)*;
124124

125125
moduleOption :
126-
OPTION_BASE INTEGERLITERAL # optionBaseStmt
127-
| OPTION_COMPARE (BINARY | TEXT | DATABASE) # optionCompareStmt
126+
OPTION_BASE WS? SHORTLITERAL # optionBaseStmt
127+
| OPTION_COMPARE WS? (BINARY | TEXT | DATABASE) # optionCompareStmt
128128
| OPTION_EXPLICIT # optionExplicitStmt
129129
| OPTION_PRIVATE_MODULE # optionPrivateModuleStmt
130130
;
@@ -666,7 +666,7 @@ letterrange : certainIdentifier (WS? MINUS WS? certainIdentifier)?;
666666

667667
lineLabel : ambiguousIdentifier ':';
668668

669-
literal : HEXLITERAL | OCTLITERAL | DATELITERAL | DOUBLELITERAL | INTEGERLITERAL | STRINGLITERAL | TRUE | FALSE | NOTHING | NULL;
669+
literal : HEXLITERAL | OCTLITERAL | DATELITERAL | DOUBLELITERAL | INTEGERLITERAL | SHORTLITERAL | STRINGLITERAL | TRUE | FALSE | NOTHING | NULL;
670670

671671
type : (baseType | complexType) (WS? LPAREN WS? RPAREN)?;
672672

@@ -906,15 +906,14 @@ L_SQUARE_BRACKET : '[';
906906
R_SQUARE_BRACKET : ']';
907907

908908

909-
// literals
910-
STRINGLITERAL : '"' (~["\r\n] | '""')* '"';
911-
DATELITERAL : '#' [0-9]+ '/' [0-9]+ '/' [0-9]+ '#';
912-
OCTLITERAL : '&O' [0-8]+ '&'?;
913-
HEXLITERAL : '&H' [0-9A-F]+ '&'?;
914-
SHORTLITERAL : (PLUS|MINUS)? ('0'..'9')+ ('#' | '&' | '@')?
915-
INTEGERLITERAL : SHORTLITERAL ( ('e' | 'E') SHORTLITERAL)*;
916-
DOUBLELITERAL : (PLUS|MINUS)? ('0'..'9')* '.' ('0'..'9')+ ( ('e' | 'E') SHORTLITERAL)*;
917-
BYTELITERAL : ('0'..'9')+;
909+
// literals
910+
STRINGLITERAL : '"' (~["\r\n] | '""')* '"';
911+
DATELITERAL : '#' DIGIT+ '/' DIGIT+ '/' DIGIT+ '#';
912+
OCTLITERAL : '&O' [0-8]+ '&'?;
913+
HEXLITERAL : '&H' [0-9A-F]+ '&'?;
914+
SHORTLITERAL : (PLUS|MINUS)? DIGIT+ ('#' | '&' | '@')?;
915+
INTEGERLITERAL : SHORTLITERAL (E SHORTLITERAL)?;
916+
DOUBLELITERAL : (PLUS|MINUS)? DIGIT* '.' DIGIT+ (E SHORTLITERAL)?;
918917
919918
// whitespace, line breaks, comments, ...
920919
LINE_CONTINUATION : [ \t]+ '_' '\r'? '\n' -> skip;
@@ -928,6 +927,7 @@ IDENTIFIER : (~[\[\]\(\)\r\n\t.,'"|!@#$%^&*-+:=; ])+ | L_SQUARE_BRACKET (~[!\]\
928927
929928
// letters
930929
fragment LETTER : [a-zA-Z_äöüÄÖÜ];
930+
fragment DIGIT : [0-9];
931931
fragment LETTERORDIGIT : [a-zA-Z0-9_äöüÄÖÜ];
932932
933933
// case insensitive chars

0 commit comments

Comments
 (0)