Fixed for loops of the form:
for (;;) Fixes issue 93 git-svn-id: http://picoc.googlecode.com/svn/trunk@474 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
e45e455b9b
commit
c0a21f5c37
10
parse.c
10
parse.c
|
@ -334,6 +334,9 @@ void ParseFor(struct ParseState *Parser)
|
|||
ProgramFail(Parser, "statement expected");
|
||||
|
||||
ParserCopyPos(&PreConditional, Parser);
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenSemicolon)
|
||||
Condition = TRUE;
|
||||
else
|
||||
Condition = ExpressionParseInt(Parser);
|
||||
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenSemicolon)
|
||||
|
@ -360,6 +363,9 @@ void ParseFor(struct ParseState *Parser)
|
|||
ParseStatement(Parser, FALSE);
|
||||
|
||||
ParserCopyPos(Parser, &PreConditional);
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenSemicolon)
|
||||
Condition = TRUE;
|
||||
else
|
||||
Condition = ExpressionParseInt(Parser);
|
||||
|
||||
if (Condition)
|
||||
|
@ -555,7 +561,9 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
CheckTrailingSemicolon = FALSE;
|
||||
break;
|
||||
|
||||
case TokenSemicolon: break;
|
||||
case TokenSemicolon:
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
break;
|
||||
|
||||
case TokenIntType:
|
||||
case TokenShortType:
|
||||
|
|
16
tests/45_empty_for.c
Normal file
16
tests/45_empty_for.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Count = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
Count++;
|
||||
printf("%d\n", Count);
|
||||
if (Count >= 10)
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
10
tests/45_empty_for.expect
Normal file
10
tests/45_empty_for.expect
Normal file
|
@ -0,0 +1,10 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
|
@ -39,7 +39,8 @@ TESTS= 00_assignment.test \
|
|||
40_stdio.test \
|
||||
41_hashif.test \
|
||||
43_void_param.test \
|
||||
44_scoped_declarations.test
|
||||
44_scoped_declarations.test \
|
||||
45_empty_for.test
|
||||
|
||||
%.test: %.expect %.c
|
||||
@echo Test: $*...
|
||||
|
|
Loading…
Reference in a new issue