]> git.lizzy.rs Git - metalua.git/blobdiff - src/compiler/metalua.mlua
Merge branch 'master' of git@github.com:fab13n/metalua into cleanup
[metalua.git] / src / compiler / metalua.mlua
index 3647e4394c5f302abecb4ec417c881d64acca0c1..3c3564d0c37b167e47cf329f27cde1ae0ad92d63 100644 (file)
@@ -48,6 +48,9 @@ parser = clopts {
    {  short = 'A', long = 'print-ast-lineinfo',  type = 'boolean',
       usage = 'print the AST resulting from file compilation, including lineinfo data'
    },
+   {  short = 'S', long = 'print-src',  type = 'boolean',
+      usage = 'print the AST resulting from file compilation, as re-gerenerated sources'
+   },
    {  short = 'b', long = 'metabugs', type = 'boolean',
       usage = 'show syntax errors as compile-time execution errors'
    },
@@ -170,6 +173,18 @@ local function main (...)
       end
    end
 
+   -------------------------------------------------------------------
+   -- Source printing
+   if cfg['print-src'] then
+      verb_print "Resulting sources:"
+      require 'metalua.ast_to_string'
+      for x in ivalues(code) do
+         printf("--- Source From %s: ---", table.tostring(x.source, 'nohash'))
+         if x.origin and x.origin.tag=='File' then x=x[1][1][2][1] end
+         print (ast_to_string (x))
+      end
+   end
+
    -------------------------------------------------------------------
    -- Insert runtime loader
    if cfg['no-runtime'] then