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:
parent
bd30654f74
commit
70cc4eae49
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
|||
CC=gcc
|
||||
CFLAGS=-Wall -g
|
||||
CFLAGS=-Wall -g -DDEBUG_HEAP
|
||||
LIBS=-lm
|
||||
|
||||
TARGET = picoc
|
||||
|
|
26
lex.c
26
lex.c
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue