lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>If error messages have the format
>
>filename:linenumber:column: text
>
>editors, such as emacs, will bring its user to the appropriate
>character in the source file identified by the error message.  [...]
>
>Please add an option for both lua and luac that specifies that errors
>be reported in the above format.

It's hard to cater for all tastes and needs. In this case, it's a simple change
in llex.c (at least for parse errors in files):

In Lua 4.0, change luaX_syntaxerror in llex.c to

 void luaX_syntaxerror (LexState *ls, const char *s, const char *token) {
   char buff[MAXSRC],*b;
   luaO_chunkid(buff, ls->source->str, sizeof(buff));
   if (buff[0]=='f') {
    b=buff+6;
    buff[strlen(buff)-1]=0;
   }
   else
     b=buff;
   luaO_verror(ls->L, "\n%.80s:%d: %.99s; last token read: `%.30s'",
	       b, ls->linenumber, s, token);
 }

This will affect both lua and luac.
--lhf