From: Alexander Gladysh Date: Sat, 24 Jan 2009 22:21:53 +0000 (+0300) Subject: weaver sample: not dumping empty ast nodes X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=a165100e8371ac84c172ac1e0ba16b17fa21df4d;p=metalua.git weaver sample: not dumping empty ast nodes --- diff --git a/src/samples/weaver.mlua b/src/samples/weaver.mlua index 3820e06..ee744fc 100644 --- a/src/samples/weaver.mlua +++ b/src/samples/weaver.mlua @@ -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 --