]> git.lizzy.rs Git - metalua.git/commitdiff
fixed some missing lineinfo in mlp
authorFabien Fleutot <fabien@MacFabien.home>
Sun, 14 Sep 2008 12:07:41 +0000 (14:07 +0200)
committerFabien Fleutot <fabien@MacFabien.home>
Sun, 14 Sep 2008 12:07:41 +0000 (14:07 +0200)
src/compiler/mlp_misc.lua
src/compiler/mlp_stat.lua
src/compiler/mlp_table.lua

index 429baaad34122f5ac4d822a21dd9e0fc1312a8c7..b76b13664dce292a2cd3c9e6a33e2f70586eb319 100644 (file)
@@ -135,7 +135,7 @@ function id2string (id)
       -- That is, without sugar:
       return {tag="String",  {tag="Index", {tag="Splice", id[1] }, 
                                            {tag="Number", 1 } } }
-   else error ("Not an identifier: "..table.tostring(id)) end
+   else error ("Identifier expected: "..table.tostring(id)) end
 end
 
 --------------------------------------------------------------------------------
index cf330e6d3defbad2e428d0847bacc01c5f74447c..ab89a522b6a65f3a5e1f9490d0c060b3ded13239 100644 (file)
@@ -123,10 +123,15 @@ local method_name = gg.onkeyword{ name = "method invocation", ":", id,
 local function funcdef_builder(x)
    local name, method, func = x[1], x[2], x[3]
    if method then 
-      name = { tag="Index", name, method }
+      name = { tag="Index", name, method, lineinfo = {
+         first = name.lineinfo.first,
+         last  = method.lineinfo.last } }
       _G.table.insert (func[1], 1, {tag="Id", "self"}) 
    end
-   return { tag="Set", {name}, {func} } 
+   local r = { tag="Set", {name}, {func} } 
+   r[1].lineinfo = name.lineinfo
+   r[2].lineinfo = func.lineinfo
+   return r
 end 
 
 
index bca15102db5a684fe0295867dc3e8e82d32bb745..dbaa7846cb4ea25f907f424f52812ef3ad5d8435 100644 (file)
@@ -65,9 +65,12 @@ function table_field (lx)
    if lx:is_keyword (lx:peek(), "[") then return bracket_field (lx) end
    local e = _expr (lx)
    if lx:is_keyword (lx:peek(), "=") then 
-      if e.tag ~= 'Id' then _G.table.print(e,80) end
-      assert (e.tag == "Id", "Identifier required on the left of = in table")
-      lx:next(); return {tag="Pair", {tag="String", e[1]}, _expr(lx)} 
+      lx:next(); -- skip the "="
+      local key = id2string(e)
+      local val = _expr(lx)
+      local r = { tag="Pair", key, val } 
+      r.lineinfo = { first = key.lineinfo.first, last = val.lineinfo.last }
+      return r
    else return e end
 end