Skip to content

Commit d018afc

Browse files
committed
Made the tests pass with a not very pretty modification of the LINE_CONTINUATION lexer rule.
1 parent f91d542 commit d018afc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Rubberduck.Parsing/Grammar/VBALexer.g4

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,14 @@ UNDERSCORE : '_';
301301
WS : [ \t];
302302
GUIDLITERAL : '{' [0-9A-F]+ '-' [0-9A-F]+ '-' [0-9A-F]+ '-' [0-9A-F]+ '-' [0-9A-F]+ '}';
303303
IDENTIFIER : ~[[\](){}\r\n\t.,'"|!@#$%^&*\-+:=; 0-9-/\\-] ~[[\](){}\r\n\t.,'"|!@#$%^&*\-+:=; -]*;
304-
LINE_CONTINUATION : [ \t]+ UNDERSCORE [ \t]* '\r'? '\n';
304+
LINE_CONTINUATION : [ \t]+ UNDERSCORE [ \t]* '\r'? '\n' WS_NOT_FOLLOWED_BY_LINE_CONTINUATION*;
305305
// The following rule is needed in order to capture hex literals without format prefixes which start with a digit. Needed for VBForm resources.
306-
BARE_HEX_LITERAL : [0-9] [0-9a-fA-F]*;
306+
BARE_HEX_LITERAL : [0-9] [0-9a-fA-F]*;
307+
fragment WS_NOT_FOLLOWED_BY_LINE_CONTINUATION : [ \t] {(char)_input.La(1) != '_'
308+
|| ((char)_input.La(2) != '\r'
309+
&& (char)_input.La(2) != '\n'
310+
&& (char)_input.La(2) != '\t'
311+
&& (char)_input.La(2) != ' ')}?;
307312
fragment LETTER : [a-zA-Z_äöüÄÖÜ];
308313
fragment DIGIT : [0-9];
309314
fragment LETTERORDIGIT : [a-zA-Z0-9_äöüÄÖÜ];

Rubberduck.Parsing/Grammar/VBAParser.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ complexType :
601601
fieldLength : MULT whiteSpace? (numberLiteral | identifierValue);
602602

603603
//Statement labels can only appear at the start of a line.
604-
statementLabelDefinition : {_input.La(-1) == NEWLINE}? (combinedLabels | identifierStatementLabel | standaloneLineNumberLabel);
604+
statementLabelDefinition : {_input.La(-1) == NEWLINE || _input.La(-1) == LINE_CONTINUATION}? (combinedLabels | identifierStatementLabel | standaloneLineNumberLabel);
605605
identifierStatementLabel : legalLabelIdentifier whiteSpace? COLON;
606606
standaloneLineNumberLabel :
607607
lineNumberLabel whiteSpace? COLON

0 commit comments

Comments
 (0)