aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-11-16 14:29:10 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-11-16 14:29:10 -0200
commit39395e12118539d983fdefbbc50d3aac3f53ccad (patch)
treeb34031cfe137496033299663909194def09f8e2f
parent26bf2adaceb18877d836174226d2bfdc3f1fc512 (diff)
downloadlua-39395e12118539d983fdefbbc50d3aac3f53ccad.tar.gz
lua-39395e12118539d983fdefbbc50d3aac3f53ccad.tar.bz2
lua-39395e12118539d983fdefbbc50d3aac3f53ccad.zip
`luaX_syntaxerror' does not need to be public
-rw-r--r--llex.c30
-rw-r--r--llex.h3
2 files changed, 19 insertions, 14 deletions
diff --git a/llex.c b/llex.c
index 4f5dbb3b..670da132 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.89 2001/07/22 00:59:36 roberto Exp $ 2** $Id: llex.c,v 1.91 2001/08/31 19:46:07 roberto Exp $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -58,7 +58,8 @@ void luaX_checklimit (LexState *ls, int val, int limit, const l_char *msg) {
58} 58}
59 59
60 60
61void luaX_syntaxerror (LexState *ls, const l_char *s, const l_char *token) { 61static void luaX_syntaxerror (LexState *ls, const l_char *s,
62 const l_char *token) {
62 l_char buff[MAXSRC]; 63 l_char buff[MAXSRC];
63 luaO_chunkid(buff, getstr(ls->source), MAXSRC); 64 luaO_chunkid(buff, getstr(ls->source), MAXSRC);
64 luaO_verror(ls->L, 65 luaO_verror(ls->L,
@@ -67,16 +68,6 @@ void luaX_syntaxerror (LexState *ls, const l_char *s, const l_char *token) {
67} 68}
68 69
69 70
70void luaX_error (LexState *ls, const l_char *s, int token) {
71 l_char buff[TOKEN_LEN];
72 luaX_token2str(token, buff);
73 if (buff[0] == l_c('\0'))
74 luaX_syntaxerror(ls, s, cast(l_char *, G(ls->L)->Mbuffer));
75 else
76 luaX_syntaxerror(ls, s, buff);
77}
78
79
80void luaX_token2str (int token, l_char *s) { 71void luaX_token2str (int token, l_char *s) {
81 if (token < FIRST_RESERVED) { 72 if (token < FIRST_RESERVED) {
82 lua_assert(token == (l_char)token); 73 lua_assert(token == (l_char)token);
@@ -88,6 +79,21 @@ void luaX_token2str (int token, l_char *s) {
88} 79}
89 80
90 81
82static l_char *token2str_all (LexState *ls, int token, l_char *s) {
83 luaX_token2str(token, s);
84 if (s[0] == l_c('\0'))
85 return cast(l_char *, G(ls->L)->Mbuffer);
86 else
87 return s;
88}
89
90
91void luaX_error (LexState *ls, const l_char *s, int token) {
92 l_char buff[TOKEN_LEN];
93 luaX_syntaxerror(ls, s, token2str_all(ls, token, buff));
94}
95
96
91static void luaX_invalidchar (LexState *ls, int c) { 97static void luaX_invalidchar (LexState *ls, int c) {
92 l_char buff[8]; 98 l_char buff[8];
93 sprintf(buff, l_s("0x%02X"), uchar(c)); 99 sprintf(buff, l_s("0x%02X"), uchar(c));
diff --git a/llex.h b/llex.h
index fbfe092d..69242cee 100644
--- a/llex.h
+++ b/llex.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.h,v 1.37 2001/07/22 00:59:36 roberto Exp $ 2** $Id: llex.h,v 1.38 2001/08/31 19:46:07 roberto Exp $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -65,7 +65,6 @@ void luaX_init (lua_State *L);
65void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source); 65void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source);
66int luaX_lex (LexState *LS, SemInfo *seminfo); 66int luaX_lex (LexState *LS, SemInfo *seminfo);
67void luaX_checklimit (LexState *ls, int val, int limit, const l_char *msg); 67void luaX_checklimit (LexState *ls, int val, int limit, const l_char *msg);
68void luaX_syntaxerror (LexState *ls, const l_char *s, const l_char *token);
69void luaX_error (LexState *ls, const l_char *s, int token); 68void luaX_error (LexState *ls, const l_char *s, int token);
70void luaX_token2str (int token, l_char *s); 69void luaX_token2str (int token, l_char *s);
71 70