]> git.lizzy.rs Git - metalua.git/commitdiff
weaver sample: not dumping empty ast nodes
authorAlexander Gladysh <agladysh@gmail.com>
Sat, 24 Jan 2009 22:21:53 +0000 (01:21 +0300)
committerAlexander Gladysh <agladysh@gmail.com>
Sat, 24 Jan 2009 22:28:34 +0000 (01:28 +0300)
src/samples/weaver.mlua

index 3820e06ebaed17ae0c11568b6908a7470e07033d..ee744fcf35ad1487a9abc7975e42c02901e27720 100644 (file)
@@ -46,10 +46,12 @@ function weave_ast (src, ast, name)
       local function acc(x) table.insert (_acc, x) end
       
       -- ast Can't be weaved normally, try something else --
-      local function synthetize (ast)         
-         acc "-{expr: "
-         acc (table.tostring (ast, 'nohash', 80, 8))
-         acc " }"
+      local function synthetize (ast)
+         if next(ast) then -- Dumping non-empty nodes only
+            acc "-{expr: "
+            acc (table.tostring (ast, 'nohash', 80, 8))
+            acc " }"
+         end
       end
 
       -- regular weaving of chidren in the parent's sources --