1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
/*
* lexerproxy.c
* lexer proxy for Lua parser -- implements assert removal
* Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>
* 11 May 2007 11:18:57
* This code is hereby placed in the public domain.
* Add <<#include "proxy.c">> just before the definition of luaX_next in llex.c
*/
#include <string.h>
bool lua_evaluate_assert = false;
static int nexttoken(LexState *ls, SemInfo *seminfo)
{
for (;;) {
int n;
int t=llex(ls,seminfo);
if (t!=TK_NAME) return t;
if (lua_evaluate_assert || (strcmp(getstr(seminfo->ts),"assert_type")!=0
&& strcmp(getstr(seminfo->ts),"assert_bool")!=0))
return t;
t=nexttoken(ls,&ls->lookahead.seminfo);
if (t!='(') {
ls->lookahead.token = t;
return TK_NAME;
}
for (n=1; n>0; ) {
t=llex(ls,seminfo);
if (t==TK_EOS) return t;
if (t=='(') n++;
if (t==')') n--;
}
}
}
#define llex nexttoken
|