]> git.lizzy.rs Git - metalua.git/commitdiff
added option in metalua to print lineinfo together with AST
authorfabien <fabien@fabien-ubuntu.(none)>
Thu, 11 Sep 2008 08:03:30 +0000 (10:03 +0200)
committerfabien <fabien@fabien-ubuntu.(none)>
Thu, 11 Sep 2008 08:03:30 +0000 (10:03 +0200)
src/compiler/metalua.mlua

index 130735999278c43962789df223725cb96a6cbe48..21725b8c5c98a5b7750b458247a424a8210ab3cf 100644 (file)
@@ -65,6 +65,9 @@ parser = clopts {
    {  short = 'a', long = 'print-ast',  type = 'boolean',
       usage = 'print the AST resulting from file compilation'  
    },
+   {  short = 'A', long = 'print-ast-lineinfo',  type = 'boolean',
+      usage = 'print the AST resulting from file compilation, including lineinfo data'  
+   },
    {  short = 'b', long = 'metabugs', type = 'boolean',
       usage = 'show syntax errors as compile-time execution errors' 
    },
@@ -176,12 +179,13 @@ local function main (...)
 
    -------------------------------------------------------------------
    -- AST printing
-   if cfg['print-ast'] then 
+   if cfg['print-ast'] or cfg['print-ast-lineinfo'] then 
       verb_print "Resulting AST:"
       for x in ivalues(code) do
          printf("--- AST From %s: ---", table.tostring(x.source, 'nohash'))
          if x.origin and x.origin.tag=='File' then x=x[1][1][2][1] end
-         table.print(x, 80, 'nohash')
+         if cfg['print-ast-lineinfo'] then table.print(x, 80)
+         else table.print(x, 80, 'nohash') end
       end 
    end