From f3c26ea55e2f2c1d222312bf75035359c439ed21 Mon Sep 17 00:00:00 2001 From: fche Date: Sun, 5 Jun 2005 16:35:28 +0000 Subject: 2005-06-05 Frank Ch. Eigler Implement for/next/continue/break/while statements. * staptree.h: Declare new 0-arity statement types. Tweak for_loop. * parse.cxx: Parse them all. * translate.cxx (c_unparser): Maintain break/continue label stack. (visit_for_loop, *_statement): New implementations. * elaborate.*, staptree.cxx: Mechanical changes. * testsuite/parseok/ten.stp, semko/twelve.stp, transko/two.stp, transok/five.stp: New tests. --- staptree.cxx | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) (limited to 'staptree.cxx') diff --git a/staptree.cxx b/staptree.cxx index 756fbc1e..3ee34950 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -161,6 +161,7 @@ void literal_string::print (ostream& o) o << '"' << value << '"'; } + void literal_number::print (ostream& o) { o << value; @@ -290,7 +291,14 @@ void block::print (ostream& o) void for_loop::print (ostream& o) { - o << "" << endl; + o << "for ("; + init->print (o); + o << "; "; + cond->print (o); + o << "; "; + incr->print (o); + o << ")" << endl; + block->print (o); } @@ -330,6 +338,20 @@ void delete_statement::print (ostream& o) o << "delete " << *value; } +void next_statement::print (ostream& o) +{ + o << "next"; +} + +void break_statement::print (ostream& o) +{ + o << "break"; +} + +void continue_statement::print (ostream& o) +{ + o << "continue"; +} void if_statement::print (ostream& o) { @@ -463,6 +485,24 @@ if_statement::visit (visitor* u) u->visit_if_statement (this); } +void +next_statement::visit (visitor* u) +{ + u->visit_next_statement (this); +} + +void +break_statement::visit (visitor* u) +{ + u->visit_break_statement (this); +} + +void +continue_statement::visit (visitor* u) +{ + u->visit_continue_statement (this); +} + void literal_string::visit(visitor* u) { @@ -624,6 +664,21 @@ traversing_visitor::visit_delete_statement (delete_statement* s) s->value->visit (this); } +void +traversing_visitor::visit_next_statement (next_statement* s) +{ +} + +void +traversing_visitor::visit_break_statement (break_statement* s) +{ +} + +void +traversing_visitor::visit_continue_statement (continue_statement* s) +{ +} + void traversing_visitor::visit_literal_string (literal_string* e) { @@ -797,6 +852,24 @@ throwing_visitor::visit_delete_statement (delete_statement* s) throwone (s->tok); } +void +throwing_visitor::visit_next_statement (next_statement* s) +{ + throwone (s->tok); +} + +void +throwing_visitor::visit_break_statement (break_statement* s) +{ + throwone (s->tok); +} + +void +throwing_visitor::visit_continue_statement (continue_statement* s) +{ + throwone (s->tok); +} + void throwing_visitor::visit_literal_string (literal_string* e) { -- cgit