diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-11-08 10:49:35 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-11-08 10:49:35 -0200 |
commit | 60242e1930e5999a5fcc5491cd597cc2a5bd97fb (patch) | |
tree | c1ffda65488af6a73ae5667136473ec1f4e63d5e | |
parent | a0e9bfbb48fdfae8188333710c2ce86051477a96 (diff) | |
download | lua-60242e1930e5999a5fcc5491cd597cc2a5bd97fb.tar.gz lua-60242e1930e5999a5fcc5491cd597cc2a5bd97fb.tar.bz2 lua-60242e1930e5999a5fcc5491cd597cc2a5bd97fb.zip |
error message for syntax "1..2";
syntax error function is in "lex.c" (it has the token)
-rw-r--r-- | lex.c | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -1,4 +1,4 @@ | |||
1 | char *rcs_lex = "$Id: lex.c,v 2.36 1996/09/25 21:52:00 roberto Exp roberto $"; | 1 | char *rcs_lex = "$Id: lex.c,v 2.38 1996/11/08 12:20:34 roberto Exp roberto $"; |
2 | 2 | ||
3 | 3 | ||
4 | #include <ctype.h> | 4 | #include <ctype.h> |
@@ -30,9 +30,15 @@ void lua_setinput (Input fn) | |||
30 | input = fn; | 30 | input = fn; |
31 | } | 31 | } |
32 | 32 | ||
33 | char *lua_lasttext (void) | 33 | void luaI_syntaxerror (char *s) |
34 | { | 34 | { |
35 | return luaI_buffer(1); | 35 | char msg[256]; |
36 | char *token = luaI_buffer(1); | ||
37 | if (token[0] == 0) | ||
38 | token = "<eof>"; | ||
39 | sprintf (msg,"%s; last token read: \"%s\" at line %d in file `%s'", | ||
40 | s, token, lua_linenumber, lua_parsedfile); | ||
41 | lua_error (msg); | ||
36 | } | 42 | } |
37 | 43 | ||
38 | 44 | ||
@@ -75,11 +81,11 @@ void luaI_addReserved (void) | |||
75 | static int inclinenumber (int pragma_allowed) | 81 | static int inclinenumber (int pragma_allowed) |
76 | { | 82 | { |
77 | if (pragma_allowed && current == '$') { /* is a pragma? */ | 83 | if (pragma_allowed && current == '$') { /* is a pragma? */ |
78 | char buff[MINBUFF]; | 84 | char *buff = luaI_buffer(MINBUFF+1); |
79 | int i = 0; | 85 | int i = 0; |
80 | next(); /* skip $ */ | 86 | next(); /* skip $ */ |
81 | while (isalnum(current)) { | 87 | while (isalnum(current)) { |
82 | if (i >= MINBUFF) lua_error("pragma too long"); | 88 | if (i >= MINBUFF) luaI_syntaxerror("pragma too long"); |
83 | buff[i++] = current; | 89 | buff[i++] = current; |
84 | next(); | 90 | next(); |
85 | } | 91 | } |
@@ -88,7 +94,7 @@ static int inclinenumber (int pragma_allowed) | |||
88 | lua_debug = 1; | 94 | lua_debug = 1; |
89 | else if (strcmp(buff, "nodebug") == 0) | 95 | else if (strcmp(buff, "nodebug") == 0) |
90 | lua_debug = 0; | 96 | lua_debug = 0; |
91 | else lua_error("invalid pragma"); | 97 | else luaI_syntaxerror("invalid pragma"); |
92 | } | 98 | } |
93 | return ++lua_linenumber; | 99 | return ++lua_linenumber; |
94 | } | 100 | } |
@@ -285,7 +291,12 @@ int luaY_lex (void) | |||
285 | a=10.0*a+(current-'0'); | 291 | a=10.0*a+(current-'0'); |
286 | save_and_next(); | 292 | save_and_next(); |
287 | } while (isdigit(current)); | 293 | } while (isdigit(current)); |
288 | if (current == '.') save_and_next(); | 294 | if (current == '.') { |
295 | save_and_next(); | ||
296 | if (current == '.') | ||
297 | luaI_syntaxerror( | ||
298 | "ambiguous syntax (decimal point x string concatenation)"); | ||
299 | } | ||
289 | fraction: | 300 | fraction: |
290 | { double da=0.1; | 301 | { double da=0.1; |
291 | while (isdigit(current)) | 302 | while (isdigit(current)) |