Skip to content

Commit ee0fdab

Browse files
committed
Merge pull request #1349 from autoboosh/shortliteralfix
shortliteral + neq/geq/leq cleanup (#1345 and #1346)
2 parents d5efed8 + 77f7994 commit ee0fdab

16 files changed

+1193
-1176
lines changed

RetailCoder.VBE/Inspections/OptionBaseInspection.cs

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

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

3535
return issues;

Rubberduck.Parsing/Grammar/VBALexer.cs

Lines changed: 997 additions & 979 deletions
Large diffs are not rendered by default.

Rubberduck.Parsing/Grammar/VBALexer.g4

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ ASSIGN : ':=';
204204
DIV : '/';
205205
INTDIV : '\\';
206206
EQ : '=';
207-
GEQ : '>=';
207+
GEQ : '>=' | '=>';
208208
GT : '>';
209-
LEQ : '<=';
209+
LEQ : '<=' | '=<';
210210
LPAREN : '(';
211211
LT : '<';
212212
MINUS : '-';
213213
MULT : '*';
214-
NEQ : '<>';
214+
NEQ : '<>' | '><';
215215
PLUS : '+';
216216
POW : '^';
217217
RPAREN : ')';
@@ -225,9 +225,20 @@ R_SQUARE_BRACKET : ']';
225225
STRINGLITERAL : '"' (~["\r\n] | '""')* '"';
226226
OCTLITERAL : '&O' [0-8]+ '&'?;
227227
HEXLITERAL : '&H' [0-9A-F]+ '&'?;
228-
SHORTLITERAL : (PLUS|MINUS)? DIGIT+ ('#' | '&' | '@')?;
229-
INTEGERLITERAL : SHORTLITERAL (E SHORTLITERAL)?;
230-
DOUBLELITERAL : (PLUS|MINUS)? DIGIT* '.' DIGIT+ (E SHORTLITERAL)?;
228+
FLOATLITERAL :
229+
FLOATINGPOINTLITERAL FLOATINGPOINTTYPESUFFIX?
230+
| DECIMALLITERAL FLOATINGPOINTTYPESUFFIX;
231+
fragment FLOATINGPOINTLITERAL :
232+
DECIMALLITERAL EXPONENT
233+
| DECIMALLITERAL '.' DECIMALLITERAL? EXPONENT?
234+
| '.' DECIMALLITERAL EXPONENT?;
235+
INTEGERLITERAL : DECIMALLITERAL INTEGERTYPESUFFIX?;
236+
fragment INTEGERTYPESUFFIX : [%&^];
237+
fragment FLOATINGPOINTTYPESUFFIX : [!#@];
238+
fragment EXPONENT : EXPONENTLETTER EXPONENTSIGN? DIGIT+;
239+
fragment EXPONENTLETTER : [DEde];
240+
fragment EXPONENTSIGN : [+-];
241+
fragment DECIMALLITERAL : DIGIT+;
231242
DATELITERAL : '#' DATEORTIME '#';
232243
fragment DATEORTIME : DATEVALUE WS? TIMEVALUE | DATEVALUE | TIMEVALUE;
233244
fragment DATEVALUE : DATEVALUEPART DATESEPARATOR DATEVALUEPART (DATESEPARATOR DATEVALUEPART)?;

Rubberduck.Parsing/Grammar/VBAParser.cs

Lines changed: 86 additions & 87 deletions
Large diffs are not rendered by default.

Rubberduck.Parsing/Grammar/VBAParser.g4

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module :
3434
whiteSpace?
3535
;
3636

37-
moduleHeader : VERSION whiteSpace DOUBLELITERAL whiteSpace? CLASS? endOfStatement;
37+
moduleHeader : VERSION whiteSpace numberLiteral whiteSpace? CLASS? endOfStatement;
3838

3939
moduleConfig :
4040
BEGIN (whiteSpace GUIDLITERAL whiteSpace ambiguousIdentifier whiteSpace?)? endOfStatement
@@ -43,18 +43,18 @@ moduleConfig :
4343
;
4444

4545
moduleConfigElement :
46-
ambiguousIdentifier whiteSpace* EQ whiteSpace* literal (COLON SHORTLITERAL)? endOfStatement
46+
ambiguousIdentifier whiteSpace* EQ whiteSpace* literal (COLON numberLiteral)? endOfStatement
4747
;
4848

4949
moduleAttributes : (attributeStmt endOfStatement)+;
5050

5151
moduleDeclarations : moduleDeclarationsElement (endOfStatement moduleDeclarationsElement)* endOfStatement;
5252

5353
moduleOption :
54-
OPTION_BASE whiteSpace SHORTLITERAL # optionBaseStmt
54+
OPTION_BASE whiteSpace numberLiteral # optionBaseStmt
5555
| OPTION_COMPARE whiteSpace (BINARY | TEXT | DATABASE) # optionCompareStmt
56-
| OPTION_EXPLICIT # optionExplicitStmt
57-
| OPTION_PRIVATE_MODULE # optionPrivateModuleStmt
56+
| OPTION_EXPLICIT # optionExplicitStmt
57+
| OPTION_PRIVATE_MODULE # optionPrivateModuleStmt
5858
;
5959

6060
moduleDeclarationsElement :
@@ -365,7 +365,7 @@ selectCaseStmt :
365365
sC_Selection :
366366
IS whiteSpace? comparisonOperator whiteSpace? valueStmt # caseCondIs
367367
| valueStmt whiteSpace TO whiteSpace valueStmt # caseCondTo
368-
| valueStmt # caseCondValue
368+
| valueStmt # caseCondValue
369369
;
370370

371371
sC_Case :
@@ -374,8 +374,8 @@ sC_Case :
374374
;
375375

376376
sC_Cond :
377-
ELSE # caseCondElse
378-
| sC_Selection (whiteSpace? COMMA whiteSpace? sC_Selection)* # caseCondSelection
377+
ELSE # caseCondElse
378+
| sC_Selection (whiteSpace? COMMA whiteSpace? sC_Selection)* # caseCondSelection
379379
;
380380

381381
sendkeysStmt : SENDKEYS whiteSpace valueStmt (whiteSpace? COMMA whiteSpace? valueStmt)?;
@@ -533,7 +533,7 @@ lineLabel : (ambiguousIdentifier | numberLiteral) COLON;
533533

534534
literal : numberLiteral | DATELITERAL | STRINGLITERAL | TRUE | FALSE | NOTHING | NULL | EMPTY;
535535

536-
numberLiteral : HEXLITERAL | OCTLITERAL | DOUBLELITERAL | INTEGERLITERAL | SHORTLITERAL;
536+
numberLiteral : HEXLITERAL | OCTLITERAL | FLOATLITERAL | INTEGERLITERAL;
537537

538538
type : (baseType | complexType) (whiteSpace? LPAREN whiteSpace? RPAREN)?;
539539

Rubberduck.Parsing/Grammar/VBAParserBaseListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\TestProj\TestProj\Grammar\VBAParser.g4 by ANTLR 4.3
11+
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\RubberduckParserTest\RubberduckParserTest\VBAParser.g4 by ANTLR 4.3
1212

1313
// Unreachable code detected
1414
#pragma warning disable 0162

Rubberduck.Parsing/Grammar/VBAParserBaseVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\TestProj\TestProj\Grammar\VBAParser.g4 by ANTLR 4.3
11+
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\RubberduckParserTest\RubberduckParserTest\VBAParser.g4 by ANTLR 4.3
1212

1313
// Unreachable code detected
1414
#pragma warning disable 0162

Rubberduck.Parsing/Grammar/VBAParserListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\TestProj\TestProj\Grammar\VBAParser.g4 by ANTLR 4.3
11+
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\RubberduckParserTest\RubberduckParserTest\VBAParser.g4 by ANTLR 4.3
1212

1313
// Unreachable code detected
1414
#pragma warning disable 0162

Rubberduck.Parsing/Grammar/VBAParserVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\TestProj\TestProj\Grammar\VBAParser.g4 by ANTLR 4.3
11+
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\RubberduckParserTest\RubberduckParserTest\VBAParser.g4 by ANTLR 4.3
1212

1313
// Unreachable code detected
1414
#pragma warning disable 0162

Rubberduck.Parsing/Preprocessing/VBAConditionalCompilationParser.cs

Lines changed: 70 additions & 72 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)