diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-09-15 14:29:52 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-09-15 14:29:52 -0300 |
| commit | 98ec7995912af0aaaf9a97c5bc1be17e9b601af9 (patch) | |
| tree | abc823aa4f22f434cef2452a09b7fe7b8d385fe7 | |
| parent | b6888a158b43c7391e2e4837cf4ae91e8c5e8371 (diff) | |
| download | lua-98ec7995912af0aaaf9a97c5bc1be17e9b601af9.tar.gz lua-98ec7995912af0aaaf9a97c5bc1be17e9b601af9.tar.bz2 lua-98ec7995912af0aaaf9a97c5bc1be17e9b601af9.zip | |
Detail
Code for multi-character tokens can start right after maximum char.
| -rw-r--r-- | llex.c | 1 | ||||
| -rw-r--r-- | llex.h | 8 |
2 files changed, 7 insertions, 2 deletions
| @@ -81,7 +81,6 @@ void luaX_init (lua_State *L) { | |||
| 81 | 81 | ||
| 82 | const char *luaX_token2str (LexState *ls, int token) { | 82 | const char *luaX_token2str (LexState *ls, int token) { |
| 83 | if (token < FIRST_RESERVED) { /* single-byte symbols? */ | 83 | if (token < FIRST_RESERVED) { /* single-byte symbols? */ |
| 84 | lua_assert(token == cast_uchar(token)); | ||
| 85 | if (lisprint(token)) | 84 | if (lisprint(token)) |
| 86 | return luaO_pushfstring(ls->L, "'%c'", token); | 85 | return luaO_pushfstring(ls->L, "'%c'", token); |
| 87 | else /* control character */ | 86 | else /* control character */ |
| @@ -7,11 +7,17 @@ | |||
| 7 | #ifndef llex_h | 7 | #ifndef llex_h |
| 8 | #define llex_h | 8 | #define llex_h |
| 9 | 9 | ||
| 10 | #include <limits.h> | ||
| 11 | |||
| 10 | #include "lobject.h" | 12 | #include "lobject.h" |
| 11 | #include "lzio.h" | 13 | #include "lzio.h" |
| 12 | 14 | ||
| 13 | 15 | ||
| 14 | #define FIRST_RESERVED 257 | 16 | /* |
| 17 | ** Single-char tokens (terminal symbols) are represented by their own | ||
| 18 | ** numeric code. Other tokens start at the following value. | ||
| 19 | */ | ||
| 20 | #define FIRST_RESERVED (UCHAR_MAX + 1) | ||
| 15 | 21 | ||
| 16 | 22 | ||
| 17 | #if !defined(LUA_ENV) | 23 | #if !defined(LUA_ENV) |
