diff options
Diffstat (limited to 'llex.c')
-rw-r--r-- | llex.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 2.13 2005/11/08 19:45:14 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 2.14 2005/12/07 15:32:52 roberto Exp roberto $ |
3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -319,7 +319,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { | |||
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | int luaX_lex (LexState *ls, SemInfo *seminfo) { | 322 | static int llex (LexState *ls, SemInfo *seminfo) { |
323 | luaZ_resetbuffer(ls->buff); | 323 | luaZ_resetbuffer(ls->buff); |
324 | for (;;) { | 324 | for (;;) { |
325 | switch (ls->current) { | 325 | switch (ls->current) { |
@@ -432,4 +432,20 @@ int luaX_lex (LexState *ls, SemInfo *seminfo) { | |||
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | #undef next | 435 | |
436 | void luaX_next (LexState *ls) { | ||
437 | ls->lastline = ls->linenumber; | ||
438 | if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ | ||
439 | ls->t = ls->lookahead; /* use this one */ | ||
440 | ls->lookahead.token = TK_EOS; /* and discharge it */ | ||
441 | } | ||
442 | else | ||
443 | ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ | ||
444 | } | ||
445 | |||
446 | |||
447 | void luaX_lookahead (LexState *ls) { | ||
448 | lua_assert(ls->lookahead.token == TK_EOS); | ||
449 | ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); | ||
450 | } | ||
451 | |||