Skip to content

Commit d14326f

Browse files
committed
fixes #1064 (added lexer token for ocal literals)
1 parent c193a3a commit d14326f

File tree

3 files changed

+1293
-1282
lines changed

3 files changed

+1293
-1282
lines changed

Rubberduck.Parsing/Grammar/VBA.g4

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
* - made seekStmt, lockStmt, unlockStmt, getStmt and widthStmt accept a fileNumber (needed to support '#')
7474
* - fixed precompiler directives, which can now be nested. they still can't interfere with other blocks though.
7575
* - optional parameters can be a valueStmt.
76+
* - added support for Octal literals
7677
*
7778
*======================================================================================
7879
*
@@ -665,7 +666,7 @@ letterrange : certainIdentifier (WS? MINUS WS? certainIdentifier)?;
665666

666667
lineLabel : ambiguousIdentifier ':';
667668

668-
literal : COLORLITERAL | DATELITERAL | DOUBLELITERAL | INTEGERLITERAL | STRINGLITERAL | TRUE | FALSE | NOTHING | NULL;
669+
literal : HEXLITERAL | OCTLITERAL | DATELITERAL | DOUBLELITERAL | INTEGERLITERAL | STRINGLITERAL | TRUE | FALSE | NOTHING | NULL;
669670

670671
type : (baseType | complexType) (WS? LPAREN WS? RPAREN)?;
671672

@@ -908,10 +909,12 @@ R_SQUARE_BRACKET : ']';
908909
// literals
909910
STRINGLITERAL : '"' (~["\r\n] | '""')* '"';
910911
DATELITERAL : '#' [0-9]+ '/' [0-9]+ '/' [0-9]+ '#';
911-
COLORLITERAL : '&H' [0-9A-F]+ '&'?;
912+
OCTLITERAL : '&O' [0-8]+ '&'?;
913+
HEXLITERAL : '&H' [0-9A-F]+ '&'?;
912914
INTEGERLITERAL : (PLUS|MINUS)? ('0'..'9')+ ( ('e' | 'E') INTEGERLITERAL)* ('#' | '&')?;
913915
DOUBLELITERAL : (PLUS|MINUS)? ('0'..'9')* '.' ('0'..'9')+ ( ('e' | 'E') (PLUS|MINUS)? ('0'..'9')+)* ('#' | '&')?;
914916
BYTELITERAL : ('0'..'9')+;
917+
915918
// whitespace, line breaks, comments, ...
916919
LINE_CONTINUATION : [ \t]+ '_' '\r'? '\n' -> skip;
917920
NEWLINE : (':' WS?) | (WS? ('\r'? '\n') WS?);

0 commit comments

Comments
 (0)