diff options
| -rw-r--r-- | lex.c | 11 |
1 files changed, 7 insertions, 4 deletions
| @@ -1,4 +1,4 @@ | |||
| 1 | char *rcs_lex = "$Id: lex.c,v 3.1 1997/04/12 15:01:49 roberto Exp roberto $"; | 1 | char *rcs_lex = "$Id: lex.c,v 3.2 1997/04/14 15:30:29 roberto Exp roberto $"; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | #include <ctype.h> | 4 | #include <ctype.h> |
| @@ -151,6 +151,7 @@ static void inclinenumber (void); | |||
| 151 | 151 | ||
| 152 | static void ifskip (int thisiflevel) | 152 | static void ifskip (int thisiflevel) |
| 153 | { | 153 | { |
| 154 | if (thisiflevel < 0) return; | ||
| 154 | while (iflevel > thisiflevel && | 155 | while (iflevel > thisiflevel && |
| 155 | (ifstate[thisiflevel] == 0 || ifstate[thisiflevel] == 3)) { | 156 | (ifstate[thisiflevel] == 0 || ifstate[thisiflevel] == 3)) { |
| 156 | if (current == '\n') | 157 | if (current == '\n') |
| @@ -165,7 +166,7 @@ static void ifskip (int thisiflevel) | |||
| 165 | static void inclinenumber (void) | 166 | static void inclinenumber (void) |
| 166 | { | 167 | { |
| 167 | static char *pragmas [] = | 168 | static char *pragmas [] = |
| 168 | {"debug", "nodebug", "end", "ifnot", "if", "else", NULL}; | 169 | {"debug", "nodebug", "end", "ifnot", "if", "else", "endinput", NULL}; |
| 169 | next(); /* skip '\n' */ | 170 | next(); /* skip '\n' */ |
| 170 | ++lua_linenumber; | 171 | ++lua_linenumber; |
| 171 | if (current == '$') { /* is a pragma? */ | 172 | if (current == '$') { /* is a pragma? */ |
| @@ -198,6 +199,9 @@ static void inclinenumber (void) | |||
| 198 | luaI_auxsyntaxerror("unmatched $else"); | 199 | luaI_auxsyntaxerror("unmatched $else"); |
| 199 | ifstate[iflevel-1] = ifstate[iflevel-1] | 2; | 200 | ifstate[iflevel-1] = ifstate[iflevel-1] | 2; |
| 200 | break; | 201 | break; |
| 202 | case 6: /* endinput */ | ||
| 203 | current = 0; | ||
| 204 | break; | ||
| 201 | default: | 205 | default: |
| 202 | luaI_auxsynterrbf("invalid pragma", buff); | 206 | luaI_auxsynterrbf("invalid pragma", buff); |
| 203 | } | 207 | } |
| @@ -206,8 +210,7 @@ static void inclinenumber (void) | |||
| 206 | inclinenumber(); | 210 | inclinenumber(); |
| 207 | else if (current != 0) /* or eof */ | 211 | else if (current != 0) /* or eof */ |
| 208 | luaI_auxsyntaxerror("invalid pragma format"); | 212 | luaI_auxsyntaxerror("invalid pragma format"); |
| 209 | if (iflevel > 0) | 213 | ifskip(iflevel-1); |
| 210 | ifskip(iflevel-1); | ||
| 211 | } | 214 | } |
| 212 | } | 215 | } |
| 213 | 216 | ||
