Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make parser understand multiple line continuations inside lExpressions #6168

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Rubberduck.Parsing/Grammar/VBAParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,13 @@ variantLiteralIdentifier : EMPTY | NULL;

lExpression :
lExpression LPAREN whiteSpace? argumentList? whiteSpace? RPAREN # indexExpr
| lExpression mandatoryLineContinuation? DOT mandatoryLineContinuation? printMethod (whiteSpace outputList)? # objectPrintExpr
| lExpression mandatoryLineContinuation? DOT mandatoryLineContinuation? unrestrictedIdentifier # memberAccessExpr
| lExpression mandatoryLineContinuation? dictionaryAccess mandatoryLineContinuation? unrestrictedIdentifier # dictionaryAccessExpr
| lExpression mandatoryLineContinuation* DOT mandatoryLineContinuation* printMethod (whiteSpace outputList)? # objectPrintExpr
| lExpression mandatoryLineContinuation* DOT mandatoryLineContinuation* unrestrictedIdentifier # memberAccessExpr
| lExpression mandatoryLineContinuation* dictionaryAccess mandatoryLineContinuation* unrestrictedIdentifier # dictionaryAccessExpr
| ME # instanceExpr
| identifier # simpleNameExpr
| DOT mandatoryLineContinuation? unrestrictedIdentifier # withMemberAccessExpr
| dictionaryAccess mandatoryLineContinuation? unrestrictedIdentifier # withDictionaryAccessExpr
| DOT whiteSpace? unrestrictedIdentifier # withMemberAccessExpr
| dictionaryAccess whiteSpace? unrestrictedIdentifier # withDictionaryAccessExpr
| lExpression mandatoryLineContinuation whiteSpace? LPAREN whiteSpace? argumentList? whiteSpace? RPAREN # whitespaceIndexExpr
;

Expand Down
23 changes: 23 additions & 0 deletions RubberduckTests/Grammar/VBAParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3989,6 +3989,29 @@ End Type
AssertTree(parseResult.Item1, parseResult.Item2, "//unrestrictedIdentifier", matches => matches.Count == 1);
}


// Adapted from opened issue https://github.com/rubberduck-vba/Rubberduck/issues/6164
[Test]
[TestCase(@"b _
_
. _
c")]
[TestCase(@"b _
. _
_
c")]
[TestCase(@"b _
_
. _
_
c")]
public void ParserCanDealWithMultiplyLineContinuedMemberAccess(string lineContinuedMemberAccess)
{
string code = $"Sub Test()\r\n a = {lineContinuedMemberAccess}\r\nEnd Sub";
var parseResult = Parse(code);
AssertTree(parseResult.Item1, parseResult.Item2, "//lExpression", matches => matches.Count == 3);
}

// Adapted from opened issue https://github.com/rubberduck-vba/Rubberduck/issues/4875
[Test]
[TestCase("form.Line (0, 0)-(12, 12), RGB(255, 255, 0), B")]
Expand Down