diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-27 15:35:50 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-27 15:35:50 +0100 |
commit | c1cf887d702a36729bab0257247066745223cf6e (patch) | |
tree | 31958bdfafc4603a95581b751ac996311c06ef2f /src/llex.js | |
parent | 6beeccbd0a859f3a9d1be4142d16a3d11ac30743 (diff) | |
download | fengari-c1cf887d702a36729bab0257247066745223cf6e.tar.gz fengari-c1cf887d702a36729bab0257247066745223cf6e.tar.bz2 fengari-c1cf887d702a36729bab0257247066745223cf6e.zip |
TK_LOCAL, TK_NAME, TK_INT
Diffstat (limited to 'src/llex.js')
-rw-r--r-- | src/llex.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/llex.js b/src/llex.js index 1adac0a..479fe48 100644 --- a/src/llex.js +++ b/src/llex.js @@ -250,7 +250,7 @@ const txtToken = function(ls, token) { case R.TK_NAME: case R.TK_STRING: case R.TK_FLT: case R.TK_INT: save(ls, '\0'); - return lapi.lua_pushstring(ls.L, `'${ls.buff.buffer}'`); + return lapi.lua_pushstring(ls.L, `'${ls.buff.buffer.join('')}'`); default: return luaX_token2str(ls, token); } @@ -306,7 +306,10 @@ const read_long_string = function(ls, seminfo, sep) { case '\n': case '\r': { save(ls, '\n'); inclinenumber(ls); - if (!seminfo) ls.buff.n = 0; + if (!seminfo) { + ls.buff.n = 0; + ls.buff.buffer = []; + } break; } default: { @@ -444,6 +447,7 @@ const read_string = function(ls, del, seminfo) { const llex = function(ls, seminfo) { ls.buff.n = 0; + ls.buff.buffer = []; for (;;) { switch (ls.current) { @@ -463,9 +467,11 @@ const llex = function(ls, seminfo) { if (ls.current === '[') { /* long comment? */ let sep = skip_sep(ls); ls.buff.n = 0; /* 'skip_sep' may dirty the buffer */ + ls.buff.buffer = []; if (sep >= 0) { read_long_string(ls, null, sep); /* skip long comment */ ls.buff.n = 0; /* previous call may dirty the buff. */ + ls.buff.buffer = []; break; } } |