Closed hvr closed 10 years ago
The problem with interpreting strings is that then pretty-printing would be more involved. Anyhow, I fixed this and I think I fixed another bug on the way. Please re-open if your problem still exists.
Thanks! ...while this makes it more work for pretty-printing, it makes it easier for evaluating Lua expressions :-)
The example
a = '\97lo\10\04923"'
From the Lua reference manual fails to parse currently with
lexical error near line: 1 col: 7 at char \
It turns out that interpreting character codes is a bit involved since Haskell's read
doesn't handle that as in Lua. It should be fixed now. When you're happy with the result please tell me and I'll upload a new version to Hackage.
@hvr also, you're aware that we have hslua for Haskell<->Lua bridge, right? You can create a Lua state in it and feed it with strings to execute Lua statements.
For the future of language-lua
I have this idea of using official Lua interpreter's lexer and parser and then create Haskell data structures using FFI.
Thanks, with this fix, language-lua
now behaves to my satisfaction regarding string literals :-)
And yes, I'm aware of hslua
(and it's great at what it does!), but I need more control over the operational aspect of Lua interpretation (especially avoiding the C FFI).
I'm glad it worked. I just pushed a new version to Hackage, version number 0.4.5.
When evaluated with
lua
, the following chunkresults in the output (showing that
\n
is supposed to be decoded)However, when parsed with
language-lua
, the escape-sequence\n
isn't decoded:Moreover,
language-lua
accepts invalid escape sequences, whichlua
s parser would reject: