foralex / picoc

Automatically exported from code.google.com/p/picoc
0 stars 0 forks source link

Allow empty FOR statements #93

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Example:

  for(;;)
  {
      break;
  }

Or 

  for(;i < 2;)
  {
      i = 5;
  }

This can be easily done in function ParseFor by looking ahead in the parse tree.

Example just for first statement in FOR:

Change this:

    if (ParseStatement(Parser, TRUE) != ParseResultOk)
        ProgramFail(Parser, "statement expected");

To:

    if (LexGetToken(Parser, NULL, FALSE) == TokenSemicolon)
    {
        LexGetToken(Parser, NULL, TRUE);
    }
    else if (ParseStatement(Parser, TRUE) != ParseResultOk)
    {
        ProgramFail(Parser, "statement expected");
    }

Similar concept can be applied to all FOR statements.

Original issue reported on code.google.com by duncan.f...@gmail.com on 27 Jul 2010 at 4:12

GoogleCodeExporter commented 8 years ago
Scheduled for release 2.0

Original comment by zik.sale...@gmail.com on 27 Jul 2010 at 10:56

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r474.

Original comment by zik.sale...@gmail.com on 27 Jul 2010 at 11:34