Skip to content

Commit 8ab4c6c

Browse files
committed
Reorder TypeOf rules in expressions to the front
1 parent e771718 commit 8ab4c6c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Rubberduck.Parsing/Grammar/VBAParser.g4

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,13 @@ forEachStmt :
341341

342342
// expression EQ expression refactored to expression to allow SLL
343343
forNextStmt :
344-
FOR whiteSpace expression whiteSpace TO whiteSpace expression (whiteSpace STEP whiteSpace expression)? endOfStatement
344+
FOR whiteSpace expression whiteSpace TO whiteSpace expression stepStmt? whiteSpace* endOfStatement
345345
block
346346
statementLabelDefinition? whiteSpace? NEXT (whiteSpace expression)?
347347
;
348348

349+
stepStmt : whiteSpace STEP whiteSpace expression;
350+
349351
functionStmt :
350352
(visibility whiteSpace)? (STATIC whiteSpace)? FUNCTION whiteSpace? functionName (whiteSpace? argList)? (whiteSpace? asTypeClause)? endOfStatement
351353
block
@@ -588,6 +590,8 @@ visibility : PRIVATE | PUBLIC | FRIEND | GLOBAL;
588590
expression :
589591
// Literal Expression has to come before lExpression, otherwise it'll be classified as simple name expression instead.
590592
whiteSpace? LPAREN whiteSpace? expression whiteSpace? RPAREN # parenthesizedExpr
593+
| TYPEOF whiteSpace expression # typeofexpr // To make the grammar SLL, the type-of-is-expression is actually the child of an IS relational op.
594+
| HASH expression # markedFileNumberExpr // Added to support special forms such as Input(file1, #file1)
591595
| NEW whiteSpace expression # newExpr
592596
| expression whiteSpace? POW whiteSpace? expression # powOp
593597
| MINUS whiteSpace? expression # unaryMinusOp
@@ -606,8 +610,6 @@ expression :
606610
| literalExpression # literalExpr
607611
| lExpression # lExpr
608612
| builtInType # builtInTypeExpr
609-
| TYPEOF whiteSpace expression # typeofexpr // To make the grammar SLL, the type-of-is-expression is actually the child of an IS relational op.
610-
| HASH expression # markedFileNumberExpr // Added to support special forms such as Input(file1, #file1)
611613
;
612614

613615
// 5.6.5 Literal Expressions

0 commit comments

Comments
 (0)