better error message for (deprecated) "%global"

This commit is contained in:
Roberto Ierusalimschy
2003-02-28 14:19:47 -03:00
parent ea16ee41a8
commit 6b6bc532a4
3 changed files with 21 additions and 9 deletions

11
llex.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: llex.c,v 1.116 2002/10/23 19:08:13 roberto Exp roberto $
** $Id: llex.c,v 1.117 2002/12/04 17:38:31 roberto Exp roberto $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -59,15 +59,20 @@ void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) {
}
static void luaX_error (LexState *ls, const char *s, const char *token) {
void luaX_errorline (LexState *ls, const char *s, const char *token, int line) {
lua_State *L = ls->L;
char buff[MAXSRC];
luaO_chunkid(buff, getstr(ls->source), MAXSRC);
luaO_pushfstring(L, "%s:%d: %s near `%s'", buff, ls->linenumber, s, token);
luaO_pushfstring(L, "%s:%d: %s near `%s'", buff, line, s, token);
luaD_throw(L, LUA_ERRSYNTAX);
}
static void luaX_error (LexState *ls, const char *s, const char *token) {
luaX_errorline(ls, s, token, ls->linenumber);
}
void luaX_syntaxerror (LexState *ls, const char *msg) {
const char *lasttoken;
switch (ls->t.token) {