aboutsummaryrefslogtreecommitdiff
path: root/lex.c
diff options
context:
space:
mode:
Diffstat (limited to 'lex.c')
-rw-r--r--lex.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/lex.c b/lex.c
index 4cfc7e13..9d592293 100644
--- a/lex.c
+++ b/lex.c
@@ -1,4 +1,4 @@
1char *rcs_lex = "$Id: lex.c,v 3.4 1997/06/11 14:20:51 roberto Exp $"; 1char *rcs_lex = "$Id: lex.c,v 3.4 1997/06/11 18:56:02 roberto Exp roberto $";
2 2
3 3
4#include <ctype.h> 4#include <ctype.h>
@@ -15,13 +15,13 @@ char *rcs_lex = "$Id: lex.c,v 3.4 1997/06/11 14:20:51 roberto Exp $";
15 15
16#define MINBUFF 250 16#define MINBUFF 250
17 17
18#define next() (current = input()) 18static int current; /* look ahead character */
19#define save(x) (yytext[tokensize++] = (x)) 19static ZIO *lex_z;
20#define save_and_next() (save(current), next())
21 20
22 21
23static int current; /* look ahead character */ 22#define next() (current = zgetc(lex_z))
24static Input input; /* input function */ 23#define save(x) (yytext[tokensize++] = (x))
24#define save_and_next() (save(current), next())
25 25
26 26
27#define MAX_IFS 5 27#define MAX_IFS 5
@@ -37,14 +37,14 @@ static struct {
37static int iflevel; /* level of nested $if's */ 37static int iflevel; /* level of nested $if's */
38 38
39 39
40void lua_setinput (Input fn) 40void lua_setinput (ZIO *z)
41{ 41{
42 current = '\n'; 42 current = '\n';
43 lua_linenumber = 0; 43 lua_linenumber = 0;
44 iflevel = 0; 44 iflevel = 0;
45 ifstate[0].skip = 0; 45 ifstate[0].skip = 0;
46 ifstate[0].elsepart = 1; /* to avoid a free $else */ 46 ifstate[0].elsepart = 1; /* to avoid a free $else */
47 input = fn; 47 lex_z = z;
48} 48}
49 49
50 50
@@ -155,7 +155,7 @@ static void ifskip (void)
155 while (ifstate[iflevel].skip) { 155 while (ifstate[iflevel].skip) {
156 if (current == '\n') 156 if (current == '\n')
157 inclinenumber(); 157 inclinenumber();
158 else if (current == 0) 158 else if (current == EOZ)
159 luaI_auxsyntaxerror("input ends inside a $if"); 159 luaI_auxsyntaxerror("input ends inside a $if");
160 else next(); 160 else next();
161 } 161 }
@@ -183,7 +183,7 @@ static void inclinenumber (void)
183 break; 183 break;
184 case 2: /* endinput */ 184 case 2: /* endinput */
185 if (!skip) { 185 if (!skip) {
186 current = 0; 186 current = EOZ;
187 iflevel = 0; /* to allow $endinput inside a $if */ 187 iflevel = 0; /* to allow $endinput inside a $if */
188 } 188 }
189 break; 189 break;
@@ -216,7 +216,7 @@ static void inclinenumber (void)
216 skipspace(); 216 skipspace();
217 if (current == '\n') /* pragma must end with a '\n' ... */ 217 if (current == '\n') /* pragma must end with a '\n' ... */
218 inclinenumber(); 218 inclinenumber();
219 else if (current != 0) /* or eof */ 219 else if (current != EOZ) /* or eof */
220 luaI_auxsyntaxerror("invalid pragma format"); 220 luaI_auxsyntaxerror("invalid pragma format");
221 ifskip(); 221 ifskip();
222 } 222 }
@@ -232,7 +232,7 @@ static int read_long_string (char *yytext, int buffsize)
232 yytext = luaI_buffer(buffsize *= 2); 232 yytext = luaI_buffer(buffsize *= 2);
233 switch (current) 233 switch (current)
234 { 234 {
235 case 0: 235 case EOZ:
236 save(0); 236 save(0);
237 return WRONGTOKEN; 237 return WRONGTOKEN;
238 case '[': 238 case '[':
@@ -295,7 +295,7 @@ int luaY_lex (void)
295 case '-': 295 case '-':
296 save_and_next(); 296 save_and_next();
297 if (current != '-') return '-'; 297 if (current != '-') return '-';
298 do { next(); } while (current != '\n' && current != 0); 298 do { next(); } while (current != '\n' && current != EOZ);
299 continue; 299 continue;
300 300
301 case '[': 301 case '[':
@@ -338,7 +338,7 @@ int luaY_lex (void)
338 yytext = luaI_buffer(buffsize *= 2); 338 yytext = luaI_buffer(buffsize *= 2);
339 switch (current) 339 switch (current)
340 { 340 {
341 case 0: 341 case EOZ:
342 case '\n': 342 case '\n':
343 save(0); 343 save(0);
344 return WRONGTOKEN; 344 return WRONGTOKEN;
@@ -455,7 +455,7 @@ int luaY_lex (void)
455 return NUMBER; 455 return NUMBER;
456 } 456 }
457 457
458 case 0: 458 case EOZ:
459 save(0); 459 save(0);
460 if (iflevel > 0) 460 if (iflevel > 0)
461 luaI_syntaxerror("missing $endif"); 461 luaI_syntaxerror("missing $endif");