diff options
-rw-r--r-- | lex.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,5 +1,9 @@ | |||
1 | char *rcs_lex = "$Id: lex.c,v 2.1 1994/04/15 19:00:28 celes Exp celes $"; | 1 | char *rcs_lex = "$Id: lex.c,v 2.2 1994/08/05 19:27:41 celes Exp celes $"; |
2 | /*$Log: lex.c,v $ | 2 | /*$Log: lex.c,v $ |
3 | * Revision 2.2 1994/08/05 19:27:41 celes | ||
4 | * implementacao de dois buffer de 'yytext' para evitar bug | ||
5 | * no look ahead do yacc | ||
6 | * | ||
3 | * Revision 2.1 1994/04/15 19:00:28 celes | 7 | * Revision 2.1 1994/04/15 19:00:28 celes |
4 | * Retirar chamada da funcao lua_findsymbol associada a cada | 8 | * Retirar chamada da funcao lua_findsymbol associada a cada |
5 | * token NAME. A decisao de chamar lua_findsymbol ou lua_findconstant | 9 | * token NAME. A decisao de chamar lua_findsymbol ou lua_findconstant |
@@ -26,6 +30,8 @@ char *rcs_lex = "$Id: lex.c,v 2.1 1994/04/15 19:00:28 celes Exp celes $"; | |||
26 | #include "table.h" | 30 | #include "table.h" |
27 | #include "y.tab.h" | 31 | #include "y.tab.h" |
28 | 32 | ||
33 | #define lua_strcmp(a,b) (a[0]<b[0]?(-1):(a[0]>b[0]?(1):strcmp(a,b))) | ||
34 | |||
29 | #define next() { current = input(); } | 35 | #define next() { current = input(); } |
30 | #define save(x) { *yytextLast++ = (x); } | 36 | #define save(x) { *yytextLast++ = (x); } |
31 | #define save_and_next() { save(current); next(); } | 37 | #define save_and_next() { save(current); next(); } |
@@ -83,7 +89,7 @@ static int findReserved (char *name) | |||
83 | while (l <= h) | 89 | while (l <= h) |
84 | { | 90 | { |
85 | int m = (l+h)/2; | 91 | int m = (l+h)/2; |
86 | int comp = strcmp(name, reserved[m].name); | 92 | int comp = lua_strcmp(name, reserved[m].name); |
87 | if (comp < 0) | 93 | if (comp < 0) |
88 | h = m-1; | 94 | h = m-1; |
89 | else if (comp == 0) | 95 | else if (comp == 0) |
@@ -114,12 +120,12 @@ int yylex () | |||
114 | while (isalnum(current) || current == '_') | 120 | while (isalnum(current) || current == '_') |
115 | save_and_next(); | 121 | save_and_next(); |
116 | *yytextLast = 0; | 122 | *yytextLast = 0; |
117 | if (strcmp(yytext[currentText], "debug") == 0) | 123 | if (lua_strcmp(yytext[currentText], "debug") == 0) |
118 | { | 124 | { |
119 | yylval.vInt = 1; | 125 | yylval.vInt = 1; |
120 | return DEBUG; | 126 | return DEBUG; |
121 | } | 127 | } |
122 | else if (strcmp(yytext[currentText], "nodebug") == 0) | 128 | else if (lua_strcmp(yytext[currentText], "nodebug") == 0) |
123 | { | 129 | { |
124 | yylval.vInt = 0; | 130 | yylval.vInt = 0; |
125 | return DEBUG; | 131 | return DEBUG; |