Updated hello.c to current syntax.

Fixed a bug in string constant handling.


git-svn-id: http://picoc.googlecode.com/svn/trunk@11 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2008-12-19 04:24:55 +00:00
parent a41ac67b50
commit ead3f08671
2 changed files with 5 additions and 3 deletions

View file

@ -3,3 +3,4 @@ int main()
printf("Hello world\n");
}
main();

7
lex.c
View file

@ -90,17 +90,18 @@ enum LexToken LexGetStringConstant(struct LexState *Lexer)
{
int Escape = FALSE;
Lexer->Pos++;
Lexer->Value.String.Str = Lexer->Pos;
while (Lexer->Pos != Lexer->End && !Escape && *Lexer->Pos != '"')
while (Lexer->Pos != Lexer->End && (*Lexer->Pos != '"' || Escape))
{
if (Escape)
Escape = FALSE;
else if (*Lexer->Pos == '\\')
Escape = TRUE;
Lexer->Pos++;
}
Lexer->Value.String.Len = Lexer->Pos - Lexer->Value.String.Str;
if (*Lexer->Pos != '"')
if (*Lexer->Pos == '"')
Lexer->Pos++;
return TokenStringConstant;