|
Subject: Re: Removing debug assertions Newsgroups: gmane.comp.lang.lua.general Date: 2007-05-11 14:28:17 GMT (2 years, 7 weeks, 5 days, 3 hours and 45 minutes ago) > Another option would be token filtering, but that is something of an > arcane art to me at this point.
/*
* proxy.c
* lexer proxy for Lua parser -- implements assert removal
* Luiz Henrique de Figueiredo <lhf <at> 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>
static int nexttoken(LexState *ls, SemInfo *seminfo)
{
for (;;) {
int n;
int t=llex(ls,seminfo);
if (t!=TK_NAME) return t;
if (strcmp(getstr(seminfo->ts),"assert")!=0) return t;
t=llex(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
|
|
|