MoeOrganization / moe

An -OFun prototype of an Ultra Modern Perl 5
http://moe.iinteractive.com
MIT License
279 stars 46 forks source link

pretty-printing of AST dumps and a bit of configurability for REPL #65

Closed prakashk closed 11 years ago

prakashk commented 11 years ago
moe> 1 + 2
{"CompilationUnitNode" : {"ScopeNode" : {"StatementsNode" : [{"BinaryOpNode" : {"lhs" : {"IntLiteralNode" : 1}, "operator" : "+", "rhs" : {"IntLiteralNode" : 2}}}]}}}
3

Turn on pretty-printing (use on, or yes, or 1 for option values)

moe> :set prettyPrintAST 1

moe> 1 + 2
{
  "CompilationUnitNode" : {
    "ScopeNode" : {
      "StatementsNode" : [
        {
          "BinaryOpNode" : {
            "lhs" : {
              "IntLiteralNode" : 1
            },
            "operator" : "+",
            "rhs" : {
              "IntLiteralNode" : 2
            }
          }
        }
      ]
    }
  }
}
3

Other options handled for now: printOutput and dumpAST

awwaiid commented 11 years ago

Nice! That should make debugging / verifying parsing easier.

--Brock

stevan commented 11 years ago

@prakashk++