@@ -1276,7 +1276,7 @@ private DMASTProcStatement For() {
12761276 Consume ( TokenType . DM_RightParenthesis , "Expected ')' in for after to expression" ) ;
12771277 ExtraColonPeriod ( ) ;
12781278
1279- return new DMASTProcStatementFor ( loc , new DMASTExpressionInRange ( loc , assign . LHS , assign . RHS , endRange , step ) , null , null , dmTypes , GetForBody ( ) ) ;
1279+ return new DMASTProcStatementFor ( loc , new DMASTExpressionInRange ( loc , assign . LHS , assign . RHS , endRange , step ) , null , null , null , dmTypes , GetForBody ( ) ) ;
12801280 } else {
12811281 Emit ( WarningCode . BadExpression , "Expected = before to in for" ) ;
12821282 return new DMASTInvalidProcStatement ( loc ) ;
@@ -1291,20 +1291,20 @@ private DMASTProcStatement For() {
12911291 Consume ( TokenType . DM_RightParenthesis , "Expected ')' in for after expression 2" ) ;
12921292 ExtraColonPeriod ( ) ;
12931293
1294- return new DMASTProcStatementFor ( loc , new DMASTExpressionIn ( loc , expr1 , listExpr ) , null , null , dmTypes , GetForBody ( ) ) ;
1294+ return new DMASTProcStatementFor ( loc , new DMASTExpressionIn ( loc , expr1 , listExpr ) , null , null , null , dmTypes , GetForBody ( ) ) ;
12951295 }
12961296
12971297 if ( ! Check ( ForSeparatorTypes ) ) {
12981298 Consume ( TokenType . DM_RightParenthesis , "Expected ')' in for after expression 1" ) ;
12991299 ExtraColonPeriod ( ) ;
13001300
1301- return new DMASTProcStatementFor ( loc , expr1 , null , null , dmTypes , GetForBody ( ) ) ;
1301+ return new DMASTProcStatementFor ( loc , expr1 , null , null , null , dmTypes , GetForBody ( ) ) ;
13021302 }
13031303
13041304 if ( Check ( TokenType . DM_RightParenthesis ) ) {
13051305 ExtraColonPeriod ( ) ;
13061306
1307- return new DMASTProcStatementFor ( loc , expr1 , null , null , dmTypes , GetForBody ( ) ) ;
1307+ return new DMASTProcStatementFor ( loc , expr1 , null , null , null , dmTypes , GetForBody ( ) ) ;
13081308 }
13091309
13101310 Whitespace ( ) ;
@@ -1321,29 +1321,44 @@ private DMASTProcStatement For() {
13211321 Consume ( TokenType . DM_RightParenthesis , "Expected ')' in for after expression 2" ) ;
13221322 ExtraColonPeriod ( ) ;
13231323
1324- return new DMASTProcStatementFor ( loc , expr1 , expr2 , null , dmTypes , GetForBody ( ) ) ;
1324+ return new DMASTProcStatementFor ( loc , expr1 , expr2 , null , null , dmTypes , GetForBody ( ) ) ;
13251325 }
13261326
13271327 if ( Check ( TokenType . DM_RightParenthesis ) ) {
13281328 ExtraColonPeriod ( ) ;
13291329
1330- return new DMASTProcStatementFor ( loc , expr1 , expr2 , null , dmTypes , GetForBody ( ) ) ;
1330+ return new DMASTProcStatementFor ( loc , expr1 , expr2 , null , null , dmTypes , GetForBody ( ) ) ;
13311331 }
13321332
13331333 Whitespace ( ) ;
13341334 DMASTExpression ? expr3 = Expression ( ) ;
1335+ DMASTProcStatement ? statement3 = null ;
13351336 if ( expr3 == null ) {
1337+ CheckForStatementIncrementor ( ref expr3 , ref statement3 ) ;
1338+
13361339 if ( Current ( ) . Type != TokenType . DM_RightParenthesis ) {
13371340 Emit ( WarningCode . BadExpression , "Expected 3nd expression in for" ) ;
13381341 }
1339-
1340- expr3 = new DMASTConstantNull ( loc ) ;
13411342 }
13421343
13431344 Consume ( TokenType . DM_RightParenthesis , "Expected ')' in for after expression 3" ) ;
13441345 ExtraColonPeriod ( ) ;
13451346
1346- return new DMASTProcStatementFor ( loc , expr1 , expr2 , expr3 , dmTypes , GetForBody ( ) ) ;
1347+ return new DMASTProcStatementFor ( loc , expr1 , expr2 , expr3 , statement3 , dmTypes , GetForBody ( ) ) ;
1348+
1349+ void CheckForStatementIncrementor ( ref DMASTExpression ? expr3 , ref DMASTProcStatement ? statement3 ) {
1350+ DMASTProcStatementSleep ? sleep = Sleep ( ) ;
1351+ if ( sleep == null ) {
1352+ expr3 = new DMASTConstantNull ( loc ) ;
1353+ statement3 = sleep ;
1354+ return ;
1355+ }
1356+
1357+ // TODO: additional tests, e.g., animate(...)
1358+
1359+ // if no matches, null
1360+ expr3 = new DMASTConstantNull ( loc ) ;
1361+ }
13471362
13481363 DMASTProcBlockInner GetForBody ( ) {
13491364 Whitespace ( ) ;
0 commit comments