Closed berbun closed 5 years ago
The multi-line strings bug appears probably because you're running an old version from the command line. Check your PATH
.
The other two I can confirm. I was pretty sure this was tested already, but apparently not strictly enough. Should be easy to fix, though.
I installed it via npm i -g luaparse
, the luaparse --v
says "luaparse v0.2.1".
The other two I can confirm.
btw I added 2 more cases up there, just in case since you haven't noticed.
For the sake of completeness, the following is valid in LuaJIT (not sure about vanilla Lua):
s="1\
2"print(string.byte(s,1,#s))
Outputs:
49 10 50
By using \
followed by newline (CR/LR or both), it is substituted with \n
(LF) char.
Yes, the version available from npm is not fixed. Latest git master at least handles multi-line strings correctly.
Fixed in 28afaef74f6c38baa4d825efd92507fee30a5861 d49b641024c1754797c2cbaecccda8c252a170ea c3e11ee171f70283b44b436844c09bfd5e2fef48.
(That should teach me not to work on several things at once.)
Samples
(unterminated multi-line string seems to raise an exception unless it is run on command-line.)
From command-line
Rundown
The path goes down to
parsePrimaryExpression()
which callsnext()
here, which callslex()
, appending EOF token.