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
14
parse.c
14
parse.c
|
@ -334,7 +334,10 @@ void ParseFor(struct ParseState *Parser)
|
||||||
ProgramFail(Parser, "statement expected");
|
ProgramFail(Parser, "statement expected");
|
||||||
|
|
||||||
ParserCopyPos(&PreConditional, Parser);
|
ParserCopyPos(&PreConditional, Parser);
|
||||||
Condition = ExpressionParseInt(Parser);
|
if (LexGetToken(Parser, NULL, FALSE) == TokenSemicolon)
|
||||||
|
Condition = TRUE;
|
||||||
|
else
|
||||||
|
Condition = ExpressionParseInt(Parser);
|
||||||
|
|
||||||
if (LexGetToken(Parser, NULL, TRUE) != TokenSemicolon)
|
if (LexGetToken(Parser, NULL, TRUE) != TokenSemicolon)
|
||||||
ProgramFail(Parser, "';' expected");
|
ProgramFail(Parser, "';' expected");
|
||||||
|
@ -360,7 +363,10 @@ void ParseFor(struct ParseState *Parser)
|
||||||
ParseStatement(Parser, FALSE);
|
ParseStatement(Parser, FALSE);
|
||||||
|
|
||||||
ParserCopyPos(Parser, &PreConditional);
|
ParserCopyPos(Parser, &PreConditional);
|
||||||
Condition = ExpressionParseInt(Parser);
|
if (LexGetToken(Parser, NULL, FALSE) == TokenSemicolon)
|
||||||
|
Condition = TRUE;
|
||||||
|
else
|
||||||
|
Condition = ExpressionParseInt(Parser);
|
||||||
|
|
||||||
if (Condition)
|
if (Condition)
|
||||||
{
|
{
|
||||||
|
@ -555,7 +561,9 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
||||||
CheckTrailingSemicolon = FALSE;
|
CheckTrailingSemicolon = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokenSemicolon: break;
|
case TokenSemicolon:
|
||||||
|
CheckTrailingSemicolon = FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
case TokenIntType:
|
case TokenIntType:
|
||||||
case TokenShortType:
|
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 \
|
40_stdio.test \
|
||||||
41_hashif.test \
|
41_hashif.test \
|
||||||
43_void_param.test \
|
43_void_param.test \
|
||||||
44_scoped_declarations.test
|
44_scoped_declarations.test \
|
||||||
|
45_empty_for.test
|
||||||
|
|
||||||
%.test: %.expect %.c
|
%.test: %.expect %.c
|
||||||
@echo Test: $*...
|
@echo Test: $*...
|
||||||
|
|
Loading…
Reference in a new issue