17 std::ostringstream oss;
18 std::string ptype = (
object ==
true) ?
"Object" :
"Program";
19 oss << ptype <<
" {\n";
20 for (
const auto §ion :
sections) {
21 oss <<
" " << section->toString() <<
"\n";
32 std::ostringstream oss;
33 oss <<
"Section " << (
type ==
DATA ?
"data" :
"code") <<
" {\n";
35 oss <<
" " << stmt->toString() <<
"\n";
46 std::ostringstream oss;
48 for (
const auto &operand :
operands) {
49 oss <<
" " << operand.op;
59 std::ostringstream oss;
60 oss <<
"Variable: " <<
name <<
" (type: " <<
type <<
")";
72 std::ostringstream stream;
73 stream <<
"Module: (" <<
name <<
")";
82 std::ostringstream stream;
83 stream <<
"Object: (" <<
name <<
")";
92 return "Label: " +
name;
100 return "Expression: " +
value + (
isNumeric ?
" (numeric)" :
" (symbolic)");
104 visitor.
visit(*
this);
108 return "Comment: " +
text;
Visitor interface for traversing the AST node hierarchy.
virtual void visit(ProgramNode &node)=0
std::string toString() const override
void accept(ASTVisitor &visitor) override
void accept(ASTVisitor &visitor) override
std::string toString() const override
std::vector< Operand > operands
Inc instruction
instruction opcode
std::string toString() const override
void accept(ASTVisitor &visitor) override
void accept(ASTVisitor &visitor) override
std::string toString() const override
std::string toString() const override
void accept(ASTVisitor &visitor) override
virtual std::string toString() const override
std::vector< std::unique_ptr< SectionNode > > sections
virtual void accept(ASTVisitor &visitor) override
void accept(ASTVisitor &visitor) override
std::vector< std::unique_ptr< ASTNode > > statements
std::string toString() const override
std::string toString() const override
void accept(ASTVisitor &visitor) override
AST node hierarchy for the MXVM parser using the Visitor pattern.