See More

#include #include #include #include #include #include #include #include #include namespace LCompilers::LPython { /********************** AST Pickle *******************/ class PickleVisitor : public AST::PickleBaseVisitor { public: std::string get_str() { return s; } }; std::string pickle_python(AST::ast_t &ast, bool colors, bool indent) { PickleVisitor v; v.use_colors = colors; v.indent = indent; v.visit_ast(ast); return v.get_str(); } /********************** AST Pickle Tree *******************/ class ASTTreeVisitor : public AST::TreeBaseVisitor { public: std::string get_str() { return s; } }; std::string pickle_tree_python(AST::ast_t &ast, bool colors) { ASTTreeVisitor v; v.use_colors = colors; v.visit_ast(ast); return v.get_str(); } /********************** AST Pickle Json *******************/ class ASTJsonVisitor : public LPython::AST::JsonBaseVisitor { public: using LPython::AST::JsonBaseVisitor::JsonBaseVisitor; std::string get_str() { return s; } }; std::string pickle_json(LPython::AST::ast_t &ast, LocationManager &lm) { ASTJsonVisitor v(lm); v.visit_ast(ast); return v.get_str(); } }