Mercurial > hg > octave-lyh
diff src/pt-loop.cc @ 3484:8b1f46ac2b64
[project @ 2000-01-27 23:30:45 by jwe]
author | jwe |
---|---|
date | Thu, 27 Jan 2000 23:30:48 +0000 |
parents | bc3fdfe311a3 |
children | e5d5848370c9 |
line wrap: on
line diff
--- a/src/pt-loop.cc +++ b/src/pt-loop.cc @@ -115,6 +115,92 @@ tw.visit_while_command (*this); } +// Do-While + +void +tree_do_while_command::eval (void) +{ + if (error_state) + return; + + if (! expr) + panic_impossible (); + + for (;;) + { + if (list) + { + list->eval (); + + if (error_state) + { + eval_error (); + return; + } + } + + if (quit_loop_now () || ! expr->is_logically_true ("do-while")) + break; + } +} + +void +tree_do_while_command::eval_error (void) +{ + if (error_state > 0) + ::error ("evaluating do-while command near line %d, column %d", + line (), column ()); +} + +void +tree_do_while_command::accept (tree_walker& tw) +{ + tw.visit_do_while_command (*this); +} + +// Do-Until + +void +tree_do_until_command::eval (void) +{ + if (error_state) + return; + + if (! expr) + panic_impossible (); + + for (;;) + { + if (list) + { + list->eval (); + + if (error_state) + { + eval_error (); + return; + } + } + + if (quit_loop_now () || expr->is_logically_true ("do-until")) + break; + } +} + +void +tree_do_until_command::eval_error (void) +{ + if (error_state > 0) + ::error ("evaluating do-until command near line %d, column %d", + line (), column ()); +} + +void +tree_do_until_command::accept (tree_walker& tw) +{ + tw.visit_do_until_command (*this); +} + // For. tree_simple_for_command::~tree_simple_for_command (void)