diff src/pt-pr-code.cc @ 13245:027a2186cd90

parfor keyword and infrastructure, but handle parfor as normal for loop for now * octave.gperf (octave_kw_id): New keyword ids, parfor_kw and end_parfor_kw. (octave_kw): Add parfor and end_parfor to the struct. * lex.ll (is_keyword_token): Handle parfor and end_parfor. * token.h (token::parfor_end): New end_tok_type enum value. * oct-parse.yy (PARFOR): New token. (loop_command): Handle PARFOR statements. (make_for_command): New args tok_id and maxproc. Handle PARFOR loops. * pt-loop.h (tree_simple_for_command::parallel, tree_simple_for_command:maxproc): New data members. (tree_simple_for_command::tree_simple_for_command): New args parallel_arg and maxproc_arg. Initialize new data members. (tree_simple_for_command::parallel): New function. (tree_simple_for_command::maxproc_expr): New function. * pt-loop.cc (tree_simple_for_command::~tree_simple_for_command): Delete maxproc. (tree_simple_for_command::dup): Pass parallel and maxproc to constructor for duplicate object. * pt-pr-code.cc (tree_print_code::visit_simple_for_command): Handle parallel form. * pt-check.cc (tree_checker::visit_simple_for_command): Likewise. * pt-eval.cc (tree_evaluator::visit_simple_for_command): Note that this is where parallel loops need to be handled.
author John W. Eaton <jwe@octave.org>
date Thu, 29 Sep 2011 02:50:53 -0400
parents cf5ebc0e47e4
children 0c69a564f2be
line wrap: on
line diff
--- a/src/pt-pr-code.cc	Wed Sep 28 21:46:39 2011 -0400
+++ b/src/pt-pr-code.cc	Thu Sep 29 02:50:53 2011 -0400
@@ -214,10 +214,15 @@
 
   indent ();
 
-  os << "for ";
+  os << (cmd.in_parallel () ? "parfor " : "for ");
 
   tree_expression *lhs = cmd.left_hand_side ();
 
+  tree_expression *maxproc = cmd.maxproc_expr ();
+
+  if (maxproc)
+    os << "(";
+
   if (lhs)
     lhs->accept (*this);
 
@@ -228,6 +233,13 @@
   if (expr)
     expr->accept (*this);
 
+  if (maxproc)
+    {
+      os << ", ";
+      maxproc->accept (*this);
+      os << ")";
+    }
+
   newline ();
 
   tree_statement_list *list = cmd.body ();