formatted += ';';
}
+void ProgramCompiler::Formatter::visit(Jump &jump)
+{
+ formatted += jump.keyword;
+ formatted += ';';
+}
+
ProgramCompiler::DeclarationCombiner::DeclarationCombiner():
toplevel(true),
virtual void visit(ProgramSyntax::Conditional &);
virtual void visit(ProgramSyntax::Iteration &);
virtual void visit(ProgramSyntax::Return &);
+ virtual void visit(ProgramSyntax::Jump &);
};
template<typename T>
return parse_passthrough();
else if(token=="return")
return parse_return();
+ else if(token=="break" || token=="continue" || token=="discard")
+ {
+ RefPtr<Jump> jump = new Jump;
+ jump->keyword = parse_token();
+ expect(";");
+
+ return jump;
+ }
else if(is_qualifier(token) || is_type(token))
return parse_variable_declaration();
else if(!token.empty())
}
+void Jump::visit(NodeVisitor &visitor)
+{
+ visitor.visit(*this);
+}
+
+
void NodeVisitor::visit(Assignment &assign)
{
visit(static_cast<BinaryExpression &>(assign));
virtual void visit(NodeVisitor &);
};
+struct Jump: Node
+{
+ std::string keyword;
+
+ virtual Jump *clone() const { return new Jump(*this); }
+ virtual void visit(NodeVisitor &);
+};
+
struct NodeVisitor
{
virtual ~NodeVisitor() { }
virtual void visit(Iteration &) { }
virtual void visit(Passthrough &) { }
virtual void visit(Return &) { }
+ virtual void visit(Jump &) { }
};
struct TraversingVisitor: NodeVisitor