[Metalua-list] More bugs
David Manura
dm.lua at math2.org
Mon Sep 1 12:46:30 GMT+2 2008
On Sun, Aug 31, 2008 at 5:13 PM, Alexander Gladysh wrote:
> Official Lua tests are quite interesting source of information about
> Lua compliance. :-)
>
> http://www.inf.puc-rio.br/~roberto/lua/lua5.1-tests.tar.gz
Here's the patch to lexer.lua I'm currently using. Some of these
fixes were from running those tests.
diff -u metalua/src/compiler/lexer.lua lua2c-0.2.1-20080802/lib/lexer.lua
--- metalua/src/compiler/lexer.lua 2008-02-14 17:43:00.000000000 -0500
+++ lua2c-0.2.1-20080802/lib/lexer.lua 2008-08-02 22:28:31.000000000 -0400
@@ -49,7 +49,7 @@
long_string = "^%[(=*)%[\n?(.-)%]%1%]()",
number_mantissa = {
"^%d+%.?%d*()",
- "^%d*%d%.%d+()" },
+ "^%d*%.%d+()" },
number_exponant = "^[eE][%+%-]?%d+()",
word = "^([%a_][%w_]*)()"
}
@@ -62,7 +62,7 @@
local t = {
a = "\a", b = "\b", f = "\f",
n = "\n", r = "\r", t = "\t", v = "\v",
- ["\\"] = "\\", ["'"] = "'", ['"'] = '"' }
+ ["\\"] = "\\", ["'"] = "'", ['"'] = '"', ["\n"] = "\n" }
return t[x] or error("Unknown escape sequence \\"..x)
end
@@ -81,7 +81,7 @@
-- as many times as required.
----------------------------------------------------------------------
local function unescape_string (s)
- return s:gsub("\\([0-9]+)", unesc_digits):gsub("\\(.)",unesc_letter)
+ return s:gsub("\\([0-9][0-9]?[0-9]?)",
unesc_digits):gsub("\\(.)",unesc_letter)
end
lexer.extractors = {
@@ -105,18 +105,21 @@
local function tk (tag, content)
assert (tag and content)
- local i, ln = previous_i, self.line
+ local i, ln, ln_end = previous_i, self.line, self.line
-- update line numbers
while true do
i = self.src:find("\n", i+1, true)
if not i then break end
if loc and i <= loc then ln = ln+1 end
- if i <= self.i then self.line = self.line+1 else break end
+ if i <= self.i then
+ ln_end = (i == self.i) and self.line or self.line+1
+ self.line = self.line+1
+ else break end
end
local a = { tag = tag,
char = loc,
- lineinfo = { first = ln, last = self.line },
- line = self.line,
+ lineinfo = { first = ln, last = ln_end },
+ line = ln_end,
content }
-- FIXME [EVE] make lineinfo passing less memory consuming
-- FIXME [Fabien] suppress line/lineinfo.line redundancy.
More information about the Metalua-list
mailing list