aboutsummaryrefslogtreecommitdiff
path: root/lex.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-14 19:40:14 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-14 19:40:14 -0200
commit86b35cf4f6a824880239069d0afe282e95806aaa (patch)
tree78352c354fc6befe1af900606cb84b23a40235e0 /lex.c
parent3b7a36653b5da227502ec5a3c677b6a351af67be (diff)
downloadlua-86b35cf4f6a824880239069d0afe282e95806aaa.tar.gz
lua-86b35cf4f6a824880239069d0afe282e95806aaa.tar.bz2
lua-86b35cf4f6a824880239069d0afe282e95806aaa.zip
unification of symbol tree and constant tree
Diffstat (limited to 'lex.c')
-rw-r--r--lex.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lex.c b/lex.c
index 7aad1d0d..d0075a53 100644
--- a/lex.c
+++ b/lex.c
@@ -1,4 +1,4 @@
1char *rcs_lex = "$Id: lex.c,v 2.9 1994/11/03 17:09:20 roberto Exp roberto $"; 1char *rcs_lex = "$Id: lex.c,v 2.10 1994/11/13 14:39:04 roberto Exp roberto $";
2 2
3 3
4#include <ctype.h> 4#include <ctype.h>
@@ -7,6 +7,8 @@ char *rcs_lex = "$Id: lex.c,v 2.9 1994/11/03 17:09:20 roberto Exp roberto $";
7#include <stdlib.h> 7#include <stdlib.h>
8#include <string.h> 8#include <string.h>
9 9
10#include "tree.h"
11#include "table.h"
10#include "opcode.h" 12#include "opcode.h"
11#include "inout.h" 13#include "inout.h"
12#include "y.tab.h" 14#include "y.tab.h"
@@ -19,9 +21,8 @@ char *rcs_lex = "$Id: lex.c,v 2.9 1994/11/03 17:09:20 roberto Exp roberto $";
19#define save_and_next() { save(current); next(); } 21#define save_and_next() { save(current); next(); }
20 22
21static int current; 23static int current;
22static char yytext[2][256]; 24static char yytext[256];
23static char *yytextLast; 25static char *yytextLast;
24static int currentText = 0;
25 26
26static Input input; 27static Input input;
27 28
@@ -34,7 +35,7 @@ void lua_setinput (Input fn)
34char *lua_lasttext (void) 35char *lua_lasttext (void)
35{ 36{
36 *yytextLast = 0; 37 *yytextLast = 0;
37 return yytext[currentText]; 38 return yytext;
38} 39}
39 40
40 41
@@ -87,10 +88,9 @@ static int findReserved (char *name)
87int yylex (void) 88int yylex (void)
88{ 89{
89 float a; 90 float a;
90 currentText = !currentText;
91 while (1) 91 while (1)
92 { 92 {
93 yytextLast = yytext[currentText]; 93 yytextLast = yytext;
94#if 0 94#if 0
95 fprintf(stderr,"'%c' %d\n",current,current); 95 fprintf(stderr,"'%c' %d\n",current,current);
96#endif 96#endif
@@ -110,12 +110,12 @@ int yylex (void)
110 while (isalnum(current) || current == '_') 110 while (isalnum(current) || current == '_')
111 save_and_next(); 111 save_and_next();
112 *yytextLast = 0; 112 *yytextLast = 0;
113 if (lua_strcmp(yytext[currentText], "debug") == 0) 113 if (lua_strcmp(yytext, "debug") == 0)
114 { 114 {
115 yylval.vInt = 1; 115 yylval.vInt = 1;
116 return DEBUG; 116 return DEBUG;
117 } 117 }
118 else if (lua_strcmp(yytext[currentText], "nodebug") == 0) 118 else if (lua_strcmp(yytext, "nodebug") == 0)
119 { 119 {
120 yylval.vInt = 0; 120 yylval.vInt = 0;
121 return DEBUG; 121 return DEBUG;
@@ -179,7 +179,7 @@ int yylex (void)
179 } 179 }
180 next(); /* skip the delimiter */ 180 next(); /* skip the delimiter */
181 *yytextLast = 0; 181 *yytextLast = 0;
182 yylval.pChar = yytext[currentText]; 182 yylval.vWord = luaI_findconstant(lua_constcreate(yytext));
183 return STRING; 183 return STRING;
184 } 184 }
185 185
@@ -200,9 +200,9 @@ int yylex (void)
200 int res; 200 int res;
201 do { save_and_next(); } while (isalnum(current) || current == '_'); 201 do { save_and_next(); } while (isalnum(current) || current == '_');
202 *yytextLast = 0; 202 *yytextLast = 0;
203 res = findReserved(yytext[currentText]); 203 res = findReserved(yytext);
204 if (res) return res; 204 if (res) return res;
205 yylval.pChar = yytext[currentText]; 205 yylval.pNode = lua_constcreate(yytext);
206 return NAME; 206 return NAME;
207 } 207 }
208 208
@@ -266,7 +266,7 @@ fraction:
266 default: /* also end of file */ 266 default: /* also end of file */
267 { 267 {
268 save_and_next(); 268 save_and_next();
269 return yytext[currentText][0]; 269 return yytext[0];
270 } 270 }
271 } 271 }
272 } 272 }