aboutsummaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
Diffstat (limited to 'llex.c')
-rw-r--r--llex.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/llex.c b/llex.c
index 384da751..3734b003 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.33 1999/03/11 18:59:19 roberto Exp roberto $ 2** $Id: llex.c,v 1.34 1999/03/25 21:05:05 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -41,14 +41,14 @@ void luaX_init (void) {
41} 41}
42 42
43 43
44#define MAXSRC 40 44#define MAXSRC 80
45 45
46void luaX_syntaxerror (LexState *ls, char *s, char *token) { 46void luaX_syntaxerror (LexState *ls, char *s, char *token) {
47 char buff[MAXSRC]; 47 char buff[MAXSRC];
48 luaL_chunkid(buff, zname(ls->lex_z), sizeof(buff)); 48 luaL_chunkid(buff, zname(ls->lex_z), sizeof(buff));
49 if (token[0] == '\0') 49 if (token[0] == '\0')
50 token = "<eof>"; 50 token = "<eof>";
51 luaL_verror("%.100s;\n last token read: `%.50s' at line %d in %.50s", 51 luaL_verror("%.100s;\n last token read: `%.50s' at line %d in %.80s",
52 s, token, ls->linenumber, buff); 52 s, token, ls->linenumber, buff);
53} 53}
54 54
@@ -70,7 +70,7 @@ void luaX_token2str (int token, char *s) {
70 70
71 71
72static void luaX_invalidchar (LexState *ls, int c) { 72static void luaX_invalidchar (LexState *ls, int c) {
73 char buff[10]; 73 char buff[8];
74 sprintf(buff, "0x%02X", c); 74 sprintf(buff, "0x%02X", c);
75 luaX_syntaxerror(ls, "invalid control char", buff); 75 luaX_syntaxerror(ls, "invalid control char", buff);
76} 76}
@@ -106,17 +106,15 @@ void luaX_setinput (LexState *LS, ZIO *z)
106** ======================================================= 106** =======================================================
107*/ 107*/
108 108
109#define PRAGMASIZE 20 109#define PRAGMASIZE 80
110 110
111static void skipspace (LexState *LS) 111static void skipspace (LexState *LS) {
112{
113 while (LS->current == ' ' || LS->current == '\t' || LS->current == '\r') 112 while (LS->current == ' ' || LS->current == '\t' || LS->current == '\r')
114 next(LS); 113 next(LS);
115} 114}
116 115
117 116
118static int checkcond (LexState *LS, char *buff) 117static int checkcond (LexState *LS, char *buff) {
119{
120 static char *opts[] = {"nil", "1", NULL}; 118 static char *opts[] = {"nil", "1", NULL};
121 int i = luaL_findstring(buff, opts); 119 int i = luaL_findstring(buff, opts);
122 if (i >= 0) return i; 120 if (i >= 0) return i;
@@ -129,8 +127,7 @@ static int checkcond (LexState *LS, char *buff)
129} 127}
130 128
131 129
132static void readname (LexState *LS, char *buff) 130static void readname (LexState *LS, char *buff) {
133{
134 int i = 0; 131 int i = 0;
135 skipspace(LS); 132 skipspace(LS);
136 while (isalnum(LS->current) || LS->current == '_') { 133 while (isalnum(LS->current) || LS->current == '_') {
@@ -148,8 +145,7 @@ static void readname (LexState *LS, char *buff)
148static void inclinenumber (LexState *LS); 145static void inclinenumber (LexState *LS);
149 146
150 147
151static void ifskip (LexState *LS) 148static void ifskip (LexState *LS) {
152{
153 while (LS->ifstate[LS->iflevel].skip) { 149 while (LS->ifstate[LS->iflevel].skip) {
154 if (LS->current == '\n') 150 if (LS->current == '\n')
155 inclinenumber(LS); 151 inclinenumber(LS);
@@ -160,8 +156,7 @@ static void ifskip (LexState *LS)
160} 156}
161 157
162 158
163static void inclinenumber (LexState *LS) 159static void inclinenumber (LexState *LS) {
164{
165 static char *pragmas [] = 160 static char *pragmas [] =
166 {"debug", "nodebug", "endinput", "end", "ifnot", "if", "else", NULL}; 161 {"debug", "nodebug", "endinput", "end", "ifnot", "if", "else", NULL};
167 next(LS); /* skip '\n' */ 162 next(LS); /* skip '\n' */