Skip to content

Commit

Permalink
Fix some Unit-Tests after Grammar changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vogel612 committed Jan 19, 2018
1 parent 22c706e commit c18550a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
44 changes: 22 additions & 22 deletions Rubberduck.Parsing/Grammar/VBAParser.g4
Expand Up @@ -586,28 +586,28 @@ visibility : PRIVATE | PUBLIC | FRIEND | GLOBAL;

// 5.6 Expressions
expression :
// Literal Expression has to come before lExpression, otherwise it'll be classified as simple name expression instead.
whiteSpace? LPAREN whiteSpace? expression whiteSpace? RPAREN # parenthesizedExpr
| literalExpression # literalExpr
| lExpression # lExpr
| builtInType # builtInTypeExpr
| TYPEOF whiteSpace expression # typeofexpr // To make the grammar SLL, the type-of-is-expression is actually the child of an IS relational op.
| NEW whiteSpace expression # newExpr
| expression whiteSpace? POW whiteSpace? expression # powOp
| MINUS whiteSpace? expression # unaryMinusOp
| expression whiteSpace? (MULT | DIV) whiteSpace? expression # multOp
| expression whiteSpace? INTDIV whiteSpace? expression # intDivOp
| expression whiteSpace? MOD whiteSpace? expression # modOp
| expression whiteSpace? (PLUS | MINUS) whiteSpace? expression # addOp
| expression whiteSpace? AMPERSAND whiteSpace? expression # concatOp
| expression whiteSpace? (EQ | NEQ | LT | GT | LEQ | GEQ | LIKE | IS) whiteSpace? expression # relationalOp
| NOT whiteSpace? expression # logicalNotOp
| expression whiteSpace? AND whiteSpace? expression # logicalAndOp
| expression whiteSpace? OR whiteSpace? expression # logicalOrOp
| expression whiteSpace? XOR whiteSpace? expression # logicalXorOp
| expression whiteSpace? EQV whiteSpace? expression # logicalEqvOp
| expression whiteSpace? IMP whiteSpace? expression # logicalImpOp
| HASH expression # markedFileNumberExpr // Added to support special forms such as Input(file1, #file1)
// Literal Expression has to come before lExpression, otherwise it'll be classified as simple name expression instead.
whiteSpace? LPAREN whiteSpace? expression whiteSpace? RPAREN # parenthesizedExpr
| NEW whiteSpace expression # newExpr
| expression whiteSpace? POW whiteSpace? expression # powOp
| MINUS whiteSpace? expression # unaryMinusOp
| expression whiteSpace? (MULT | DIV) whiteSpace? expression # multOp
| expression whiteSpace? INTDIV whiteSpace? expression # intDivOp
| expression whiteSpace? MOD whiteSpace? expression # modOp
| expression whiteSpace? (PLUS | MINUS) whiteSpace? expression # addOp
| expression whiteSpace? AMPERSAND whiteSpace? expression # concatOp
| expression whiteSpace? (EQ | NEQ | LT | GT | LEQ | GEQ | LIKE | IS) whiteSpace? expression # relationalOp
| NOT whiteSpace? expression # logicalNotOp
| expression whiteSpace? AND whiteSpace? expression # logicalAndOp
| expression whiteSpace? OR whiteSpace? expression # logicalOrOp
| expression whiteSpace? XOR whiteSpace? expression # logicalXorOp
| expression whiteSpace? EQV whiteSpace? expression # logicalEqvOp
| expression whiteSpace? IMP whiteSpace? expression # logicalImpOp
| literalExpression # literalExpr
| lExpression # lExpr
| builtInType # builtInTypeExpr
| TYPEOF whiteSpace expression # typeofexpr // To make the grammar SLL, the type-of-is-expression is actually the child of an IS relational op.
| HASH expression # markedFileNumberExpr // Added to support special forms such as Input(file1, #file1)
;

// 5.6.5 Literal Expressions
Expand Down
8 changes: 4 additions & 4 deletions RubberduckTests/Grammar/VBAParserTests.cs
Expand Up @@ -162,7 +162,7 @@ Sub DoSomething()
30 End With
End Sub
";
var result = Parse(code);
var result = Parse(code, PredictionMode.Sll);
AssertTree(result.Item1, result.Item2, "//statementLabelDefinition", matches => matches.Count == 3);
AssertTree(result.Item1, result.Item2, "//withStmt");
}
Expand Down Expand Up @@ -383,7 +383,7 @@ public void TestDefDirectiveSameDefDirectiveMultipleLetterSpec()
public void TestDefDirectiveLetterRange()
{
string code = @"DefBool B-C: DefByte Y-X: DefInt I-J: DefLng L-M: DefLngLng N-O: DefLngPtr P-Q: DefCur C-D: DefSng G-H: DefDbl D-E: DefDate T-U: DefStr E-F: DefObj O-P: DefVar V-W";
var parseResult = Parse(code);
var parseResult = Parse(code, PredictionMode.Sll);
AssertTree(parseResult.Item1, parseResult.Item2, "//letterRange", matches => matches.Count == 13);
}

Expand Down Expand Up @@ -1274,7 +1274,7 @@ public void TestSingleLineIfRealWorldExample3()
Sub Test()
If Not oP_Window Is Nothing Then If Not oP_Window.Visible Then Unload oP_Window: Set oP_Window = Nothing
End Sub";
var parseResult = Parse(code);
var parseResult = Parse(code, PredictionMode.Sll);
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt", matches => matches.Count == 2);
}

Expand Down Expand Up @@ -1577,7 +1577,7 @@ Sub Test()
Debug.Print ""SecondO:""; ans(1)
End If
End Sub";
var parseResult = Parse(code);
var parseResult = Parse(code, PredictionMode.Sll);
AssertTree(parseResult.Item1, parseResult.Item2, "//debugPrintStmt", matches => matches.Count == 2);
}

Expand Down
Expand Up @@ -167,14 +167,14 @@ public void UnhandledOnErrorResumeNext_QuickFixWorks_MultipleIssues()
On Error GoTo ErrorHandler1
Exit Sub
ErrorHandler:
ErrorHandler1:
If Err.Number > 0 Then 'TODO: handle specific error
Err.Clear
Resume Next
End If
Exit Sub
ErrorHandler1:
ErrorHandler:
If Err.Number > 0 Then 'TODO: handle specific error
Err.Clear
Resume Next
Expand Down Expand Up @@ -217,14 +217,14 @@ public void UnhandledOnErrorResumeNext_QuickFixWorks_MultipleIssuesAndExistingLa
ErrorHandler1:
Exit Sub
ErrorHandler:
ErrorHandler2:
If Err.Number > 0 Then 'TODO: handle specific error
Err.Clear
Resume Next
End If
Exit Sub
ErrorHandler2:
ErrorHandler:
If Err.Number > 0 Then 'TODO: handle specific error
Err.Clear
Resume Next
Expand Down

0 comments on commit c18550a

Please sign in to comment.