Skip to content

Commit

Permalink
fix latent bug with Lexer::peek and recently introduced bug in Lexer:…
Browse files Browse the repository at this point in the history
…:scan

In Lexer::peek, the code truncated the next list in the case where peek was reentrant.  ie:

  ... peek ... ... peek ...

In TOKpound processing, it should peek relative to the passed in token rather than the global current token.
  • Loading branch information
braddr committed Mar 4, 2012
1 parent 6603da5 commit 06bf3d3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ Token *Lexer::peek(Token *ct)
{
t = new Token();
scan(t);
t->next = NULL;
ct->next = t;
}
return t;
Expand Down Expand Up @@ -1231,7 +1230,7 @@ void Lexer::scan(Token *t)
case '#':
{
p++;
Token *n = peek(&token);
Token *n = peek(t);
if (n->value == TOKidentifier && n->ident == Id::line)
{
nextToken();
Expand Down
1 change: 1 addition & 0 deletions src/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ struct Token
static const char *tochars[TOKMAX];
static void *operator new(size_t sz);

Token() : next(NULL) {}
int isKeyword();
void print();
const char *toChars();
Expand Down

0 comments on commit 06bf3d3

Please sign in to comment.