# HG changeset patch # User John W. Eaton # Date 1317281758 14400 # Node ID 0c69a564f2beb9b417cdb7da61335275b6cf819a # Parent 027a2186cd9019893750d3d376a724a4fadea615 additional parfor changes * octave.gperf (octave_kw_id): Use endparfor_kw, not end_parfor_kw. (octave_kw): Use endparfor, not end_parfor. Change all uses. * help.cc (keywords): Include parfor and endparfor in the list. * pt-pr-code.cc (tree_print_code::visit_simple_for_command): Print endparfor if in parallel. diff --git a/src/help.cc b/src/help.cc --- a/src/help.cc +++ b/src/help.cc @@ -432,7 +432,7 @@ "-*- texinfo -*-\n\ @deftypefn {Keyword} {} break\n\ Exit the innermost enclosing do, while or for loop.\n\ -@seealso{do, while, for, continue}\n\ +@seealso{do, while, for, parfor, continue}\n\ @end deftypefn"), pair_type ("case", @@ -455,7 +455,7 @@ "-*- texinfo -*-\n\ @deftypefn {Keyword} {} continue\n\ Jump to the end of the innermost enclosing do, while or for loop.\n\ -@seealso{do, while, for, break}\n\ +@seealso{do, while, for, parfor, break}\n\ @end deftypefn"), pair_type ("do", @@ -485,7 +485,7 @@ @deftypefn {Keyword} {} end\n\ Mark the end of any @code{for}, @code{if}, @code{do}, @code{while}, or\n\ @code{function} block.\n\ -@seealso{for, if, do, while, function}\n\ +@seealso{for, parfor, if, do, while, function}\n\ @end deftypefn"), pair_type ("end_try_catch", @@ -523,6 +523,13 @@ @seealso{if}\n\ @end deftypefn"), + pair_type ("endparfor", + "-*- texinfo -*-\n\ +@deftypefn {Keyword} {} endparfor\n\ +Mark the end of a parfor loop. See @code{parfor} for an example.\n\ +@seealso{parfor}\n\ +@end deftypefn"), + pair_type ("endswitch", "-*- texinfo -*-\n\ @deftypefn {Keyword} {} endswitch\n\ @@ -549,7 +556,7 @@ endfor\n\ @end group\n\ @end example\n\ -@seealso{do, while}\n\ +@seealso{do, parfor, while}\n\ @end deftypefn"), pair_type ("function", @@ -608,6 +615,22 @@ @seealso{switch}\n\ @end deftypefn"), + pair_type ("parfor", + "-*- texinfo -*-\n\ +@deftypefn {Keyword} {} for @var{i} = @var{range}\n\ +@deftypefnx {Keyword} {} for (@var{i} = @var{range}, @var{maxproc})\n\ +Begin a for loop that may execute in parallel.\n\ +\n\ +@example\n\ +@group\n\ +parfor i = 1:10\n\ + i\n\ +endparfor\n\ +@end group\n\ +@end example\n\ +@seealso{do, for, while}\n\ +@end deftypefn"), + pair_type ("persistent", "-*- texinfo -*-\n\ @deftypefn {Keyword} {} persistent @var{var}\n\ diff --git a/src/lex.ll b/src/lex.ll --- a/src/lex.ll +++ b/src/lex.ll @@ -1496,11 +1496,6 @@ lexer_flags.at_beginning_of_statement = true; break; - case end_parfor_kw: - yylval.tok_val = new token (token::parfor_end, l, c); - lexer_flags.at_beginning_of_statement = true; - break; - case end_try_catch_kw: yylval.tok_val = new token (token::try_catch_end, l, c); lexer_flags.at_beginning_of_statement = true; @@ -1526,6 +1521,11 @@ lexer_flags.at_beginning_of_statement = true; break; + case endparfor_kw: + yylval.tok_val = new token (token::parfor_end, l, c); + lexer_flags.at_beginning_of_statement = true; + break; + case endswitch_kw: yylval.tok_val = new token (token::switch_end, l, c); lexer_flags.at_beginning_of_statement = true; diff --git a/src/oct-parse.yy b/src/oct-parse.yy --- a/src/oct-parse.yy +++ b/src/oct-parse.yy @@ -1785,6 +1785,10 @@ end_error ("if", ettype, l, c); break; + case token::parfor_end: + end_error ("parfor", ettype, l, c); + break; + case token::try_catch_end: end_error ("try", ettype, l, c); break; diff --git a/src/octave.gperf b/src/octave.gperf --- a/src/octave.gperf +++ b/src/octave.gperf @@ -35,7 +35,6 @@ else_kw, elseif_kw, end_kw, - end_parfor_kw, end_try_catch_kw, end_unwind_protect_kw, endclassdef_kw, @@ -44,6 +43,7 @@ endfunction_kw, endif_kw, endmethods_kw, + endparfor_kw, endproperties_kw, endswitch_kw, endwhile_kw, @@ -81,7 +81,6 @@ else, ELSE, else_kw elseif, ELSEIF, elseif_kw end, END, end_kw -end_parfor, END, end_parfor_kw end_try_catch, END, end_try_catch_kw end_unwind_protect, END, end_unwind_protect_kw endclassdef, END, endclassdef_kw @@ -90,6 +89,7 @@ endfunction, END, endfunction_kw endif, END, endif_kw endmethods, END, endmethods_kw +endparfor, END, endparfor_kw endproperties, END, endproperties_kw endswitch, END, endswitch_kw endwhile, END, endwhile_kw diff --git a/src/pt-pr-code.cc b/src/pt-pr-code.cc --- a/src/pt-pr-code.cc +++ b/src/pt-pr-code.cc @@ -257,7 +257,7 @@ indent (); - os << "endfor"; + os << (cmd.in_parallel () ? "endparfor" : "endfor"); } void