]> git.lizzy.rs Git - metalua.git/commitdiff
weaver sample: normalizing lineinfo first/last positions
authorAlexander Gladysh <agladysh@gmail.com>
Sun, 25 Jan 2009 16:02:16 +0000 (19:02 +0300)
committerAlexander Gladysh <agladysh@gmail.com>
Sun, 25 Jan 2009 16:02:16 +0000 (19:02 +0300)
If first is after the last, swap them. This fixes extra spaces bug.

src/samples/weaver.mlua

index 5a266be80f00b80fdd0c0c3bdbb85ed525338b5f..a5d43a93ae2c56a9f9da0bed953b2ac01d5666a2 100644 (file)
@@ -35,6 +35,12 @@ function weave_ast (src, ast, name)
          if parent then weaveable [parent] = false end
       else
          weaveable [ast] = true
+         
+         -- normalize lineinfo
+         -- TODO: FIXME
+         if ast.lineinfo.first[3] > ast.lineinfo.last[3] then
+           ast.lineinfo.first, ast.lineinfo.last = ast.lineinfo.last, ast.lineinfo.first
+         end
       end
       ast_children [ast] = { }
       ast_parent [ast] = parent