Fixed lexer EOF handling when whitespace at end of file

git-svn-id: http://picoc.googlecode.com/svn/trunk@63 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2009-02-03 11:09:07 +00:00
parent bd30654f74
commit 70cc4eae49
2 changed files with 15 additions and 13 deletions

View file

@ -1,5 +1,5 @@
CC=gcc
CFLAGS=-Wall -g
CFLAGS=-Wall -g -DDEBUG_HEAP
LIBS=-lm
TARGET = picoc

26
lex.c
View file

@ -214,18 +214,6 @@ enum LexToken LexScanGetToken(struct LexState *Lexer, struct Value **Value)
do
{
if (Lexer->Pos == Lexer->End)
{ /* end of input */
if (Lexer->FileName == StrEmpty)
{ /* get interactive input */
char LineBuffer[LINEBUFFER_MAX];
if (fgets(&LineBuffer[0], LINEBUFFER_MAX, stdin) == NULL)
return TokenEOF;
}
else
return TokenEOF;
}
*Value = &LexValue;
while (Lexer->Pos != Lexer->End && isspace(*Lexer->Pos))
{
@ -235,6 +223,20 @@ enum LexToken LexScanGetToken(struct LexState *Lexer, struct Value **Value)
Lexer->Pos++;
}
if (Lexer->Pos == Lexer->End)
{ /* end of input */
if (Lexer->FileName == StrEmpty)
{ /* get interactive input */
char LineBuffer[LINEBUFFER_MAX];
if (fgets(&LineBuffer[0], LINEBUFFER_MAX, stdin) == NULL)
return TokenEOF;
// XXX - finish this
}
else
return TokenEOF;
}
ThisChar = *Lexer->Pos;
if (isCidstart(ThisChar))
return LexGetWord(Lexer, *Value);