From e2d327308d9024cbbb80ea21c056f38591319234 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 26 May 2014 12:12:22 +0200 Subject: Assembler. Debug trace stuff. --- Parser.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Parser.cpp') diff --git a/Parser.cpp b/Parser.cpp index 2a0146a6..10d2188a 100644 --- a/Parser.cpp +++ b/Parser.cpp @@ -42,6 +42,31 @@ void eth::killBigints(sp::utree const& _this) } } +void eth::debugOutAST(ostream& _out, sp::utree const& _this) +{ + switch (_this.which()) + { + case sp::utree_type::list_type: + switch (_this.tag()) + { + case 0: _out << "( "; for (auto const& i: _this) { debugOutAST(_out, i); _out << " "; } _out << ")"; break; + case 1: _out << "@ "; debugOutAST(_out, _this.front()); break; + case 2: _out << "@@ "; debugOutAST(_out, _this.front()); break; + case 3: _out << "[ "; debugOutAST(_out, _this.front()); _out << " ] "; debugOutAST(_out, _this.back()); break; + case 4: _out << "[[ "; debugOutAST(_out, _this.front()); _out << " ]] "; debugOutAST(_out, _this.back()); break; + case 5: _out << "{ "; for (auto const& i: _this) { debugOutAST(_out, i); _out << " "; } _out << "}"; break; + default:; + } + + break; + case sp::utree_type::int_type: _out << _this.get(); break; + case sp::utree_type::string_type: _out << "\"" << _this.get, sp::utree_type::string_type>>() << "\""; break; + case sp::utree_type::symbol_type: _out << _this.get, sp::utree_type::symbol_type>>(); break; + case sp::utree_type::any_type: _out << *_this.get(); break; + default: _out << "nil"; + } +} + void eth::parseTreeLLL(string const& _s, sp::utree& o_out) { using qi::ascii::space; -- cgit v1.2.3