diff options
author | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1993-12-22 19:39:15 -0200 |
---|---|---|
committer | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1993-12-22 19:39:15 -0200 |
commit | 70b1eb4e8b478da4c12dba591218a5c8597bd727 (patch) | |
tree | d099f0980453cb0b7b4418145f38f02f840177f9 | |
parent | a4a3357c1c1c39c65845be66d5d1fb4eaf458d7e (diff) | |
download | lua-70b1eb4e8b478da4c12dba591218a5c8597bd727.tar.gz lua-70b1eb4e8b478da4c12dba591218a5c8597bd727.tar.bz2 lua-70b1eb4e8b478da4c12dba591218a5c8597bd727.zip |
Tratamento do token $debug e $nodebug
-rw-r--r-- | lex.c | 34 |
1 files changed, 26 insertions, 8 deletions
@@ -1,5 +1,8 @@ | |||
1 | char *rcs_lex = "$Id$"; | 1 | char *rcs_lex = "$Id: lex.c,v 1.1 1993/12/22 21:15:16 roberto Exp celes $"; |
2 | /*$Log$*/ | 2 | /*$Log: lex.c,v $ |
3 | * Revision 1.1 1993/12/22 21:15:16 roberto | ||
4 | * Initial revision | ||
5 | **/ | ||
3 | 6 | ||
4 | #include <ctype.h> | 7 | #include <ctype.h> |
5 | #include <math.h> | 8 | #include <math.h> |
@@ -84,17 +87,33 @@ int yylex () | |||
84 | yytextLast = yytext; | 87 | yytextLast = yytext; |
85 | switch (current) | 88 | switch (current) |
86 | { | 89 | { |
87 | case 0: return 0; | ||
88 | case '\n': lua_linenumber++; | 90 | case '\n': lua_linenumber++; |
89 | case ' ': | 91 | case ' ': |
90 | case '\t': | 92 | case '\t': |
91 | save_and_next(); | 93 | next(); |
92 | continue; | 94 | continue; |
95 | |||
96 | case '$': | ||
97 | next(); | ||
98 | while (isalnum(current) || current == '_') | ||
99 | save_and_next(); | ||
100 | *yytextLast = 0; | ||
101 | if (strcmp(yytext, "debug") == 0) | ||
102 | { | ||
103 | yylval.vInt = 1; | ||
104 | return DEBUG; | ||
105 | } | ||
106 | else if (strcmp(yytext, "nodebug") == 0) | ||
107 | { | ||
108 | yylval.vInt = 0; | ||
109 | return DEBUG; | ||
110 | } | ||
111 | return WRONGTOKEN; | ||
93 | 112 | ||
94 | case '-': | 113 | case '-': |
95 | save_and_next(); | 114 | save_and_next(); |
96 | if (current != '-') return '-'; | 115 | if (current != '-') return '-'; |
97 | do { save_and_next(); } while (current != '\n' && current != 0); | 116 | do { next(); } while (current != '\n' && current != 0); |
98 | continue; | 117 | continue; |
99 | 118 | ||
100 | case '<': | 119 | case '<': |
@@ -195,11 +214,10 @@ fraction: while (isdigit(current)) save_and_next(); | |||
195 | yylval.vFloat = atof(yytext); | 214 | yylval.vFloat = atof(yytext); |
196 | return NUMBER; | 215 | return NUMBER; |
197 | 216 | ||
198 | default: | 217 | default: /* also end of file */ |
199 | { | 218 | { |
200 | int temp = current; | ||
201 | save_and_next(); | 219 | save_and_next(); |
202 | return temp; | 220 | return *yytext; |
203 | } | 221 | } |
204 | } | 222 | } |
205 | } | 223 | } |