diff options
| -rw-r--r-- | lua.stx | 23 |
1 files changed, 13 insertions, 10 deletions
| @@ -1,6 +1,6 @@ | |||
| 1 | %{ | 1 | %{ |
| 2 | 2 | ||
| 3 | char *rcs_luastx = "$Id: lua.stx,v 3.26 1996/01/22 18:39:37 roberto Exp roberto $"; | 3 | char *rcs_luastx = "$Id: lua.stx,v 3.27 1996/01/23 17:50:29 roberto Exp $"; |
| 4 | 4 | ||
| 5 | #include <stdio.h> | 5 | #include <stdio.h> |
| 6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
| @@ -56,9 +56,12 @@ static int nfields=0; | |||
| 56 | 56 | ||
| 57 | static void yyerror (char *s) | 57 | static void yyerror (char *s) |
| 58 | { | 58 | { |
| 59 | static char msg[256]; | 59 | char msg[256]; |
| 60 | sprintf (msg,"%s near \"%s\" at line %d in file `%s'", | 60 | char *token = lua_lasttext(); |
| 61 | s, lua_lasttext (), lua_linenumber, lua_parsedfile); | 61 | if (token[0] == 0) |
| 62 | token = "<eof>"; | ||
| 63 | sprintf (msg,"%s; last token read: \"%s\" at line %d in file `%s'", | ||
| 64 | s, token, lua_linenumber, lua_parsedfile); | ||
| 62 | lua_error (msg); | 65 | lua_error (msg); |
| 63 | } | 66 | } |
| 64 | 67 | ||
| @@ -67,7 +70,7 @@ static void code_byte (Byte c) | |||
| 67 | if (pc>maxcurr-2) /* 1 byte free to code HALT of main code */ | 70 | if (pc>maxcurr-2) /* 1 byte free to code HALT of main code */ |
| 68 | { | 71 | { |
| 69 | if (maxcurr >= MAX_INT) | 72 | if (maxcurr >= MAX_INT) |
| 70 | lua_error("code size overflow"); | 73 | yyerror("code size overflow"); |
| 71 | maxcurr *= 2; | 74 | maxcurr *= 2; |
| 72 | if (maxcurr >= MAX_INT) | 75 | if (maxcurr >= MAX_INT) |
| 73 | maxcurr = MAX_INT; | 76 | maxcurr = MAX_INT; |
| @@ -117,7 +120,7 @@ static void push_field (Word name) | |||
| 117 | if (nfields < MAXFIELDS) | 120 | if (nfields < MAXFIELDS) |
| 118 | fields[nfields++] = name; | 121 | fields[nfields++] = name; |
| 119 | else | 122 | else |
| 120 | lua_error ("too many fields in nested constructors"); | 123 | yyerror ("too many fields in nested constructors"); |
| 121 | } | 124 | } |
| 122 | 125 | ||
| 123 | static void flush_record (int n) | 126 | static void flush_record (int n) |
| @@ -142,7 +145,7 @@ static void flush_list (int m, int n) | |||
| 142 | code_byte(m); | 145 | code_byte(m); |
| 143 | } | 146 | } |
| 144 | else | 147 | else |
| 145 | lua_error ("list constructor too long"); | 148 | yyerror ("list constructor too long"); |
| 146 | code_byte(n); | 149 | code_byte(n); |
| 147 | } | 150 | } |
| 148 | 151 | ||
| @@ -151,7 +154,7 @@ static void add_localvar (TreeNode *name) | |||
| 151 | if (nlocalvar < MAXLOCALS) | 154 | if (nlocalvar < MAXLOCALS) |
| 152 | localvar[nlocalvar++] = name; | 155 | localvar[nlocalvar++] = name; |
| 153 | else | 156 | else |
| 154 | lua_error ("too many local variables"); | 157 | yyerror ("too many local variables"); |
| 155 | } | 158 | } |
| 156 | 159 | ||
| 157 | static void store_localvar (TreeNode *name, int n) | 160 | static void store_localvar (TreeNode *name, int n) |
| @@ -159,7 +162,7 @@ static void store_localvar (TreeNode *name, int n) | |||
| 159 | if (nlocalvar+n < MAXLOCALS) | 162 | if (nlocalvar+n < MAXLOCALS) |
| 160 | localvar[nlocalvar+n] = name; | 163 | localvar[nlocalvar+n] = name; |
| 161 | else | 164 | else |
| 162 | lua_error ("too many local variables"); | 165 | yyerror ("too many local variables"); |
| 163 | } | 166 | } |
| 164 | 167 | ||
| 165 | static void add_varbuffer (Long var) | 168 | static void add_varbuffer (Long var) |
| @@ -167,7 +170,7 @@ static void add_varbuffer (Long var) | |||
| 167 | if (nvarbuffer < MAXVAR) | 170 | if (nvarbuffer < MAXVAR) |
| 168 | varbuffer[nvarbuffer++] = var; | 171 | varbuffer[nvarbuffer++] = var; |
| 169 | else | 172 | else |
| 170 | lua_error ("variable buffer overflow"); | 173 | yyerror ("variable buffer overflow"); |
| 171 | } | 174 | } |
| 172 | 175 | ||
| 173 | static void code_number (float f) | 176 | static void code_number (float f) |
