# HG changeset patch # User John W. Eaton # Date 1234759755 18000 # Node ID 5dd06f19e9be34c68d099716e064d235f6c73d5b # Parent 6dc61981d18b50d6b41a9833f1fd192e8a64c8b1 handle commands in the lexer diff -r 6dc61981d18b -r 5dd06f19e9be scripts/ChangeLog --- a/scripts/ChangeLog Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/ChangeLog Sun Feb 15 23:49:15 2009 -0500 @@ -1,3 +1,28 @@ +2009-02-15 John W. Eaton + + * help/doc.m, help/help.m, help/lookfor.m, help/type.m, + help/which.m, image/colormap.m, miscellaneous/delete.m, + miscellaneous/dir.m, miscellaneous/edit.m, + miscellaneous/intwarning.m, miscellaneous/ls.m, + miscellaneous/mex.m, miscellaneous/mkoctfile.m, + miscellaneous/run.m, miscellaneous/what.m, path/savepath.m, + pkg/pkg.m, plot/axis.m, plot/box.m, plot/caxis.m, plot/cla.m, + plot/close.m, plot/colorbar.m, plot/grid.m, plot/hidden.m, + plot/hold.m, plot/legend.m, plot/orient.m, plot/print.m, + plot/shading.m, plot/title.m, plot/xlabel.m, plot/ylabel.m, + plot/zlabel.m, testfun/demo.m, testfun/example.m, testfun/fail.m, + testfun/rundemos.m, testfun/test.m: + Delete "PKG_ADD: mark_as_command" directive. + + * scripts/edit.m: Avoid command-style function call syntax when + assigning results in tests. + + * deprecated/mark_as_rawcommand.m, deprecated/unmark_rawcommand.m, + deprecated/israwcommand.m, deprecated/mark_as_command.m, + deprecated/unmark_command.m, deprecated/iscommand.m: + New functions. + * deprecated/Makefile.in (SOURCES): Add them to the list. + 2009-02-15 Ben Abbott * plot/subplot.m: Compatible placement of subplots. diff -r 6dc61981d18b -r 5dd06f19e9be scripts/deprecated/Makefile.in --- a/scripts/deprecated/Makefile.in Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/deprecated/Makefile.in Sun Feb 15 23:49:15 2009 -0500 @@ -42,18 +42,21 @@ hypergeometric_cdf.m hypergeometric_inv.m hypergeometric_pdf.m \ hypergeometric_rnd.m intersection.m is_bool.m is_complex.m \ is_list.m is_matrix.m is_scalar.m is_square.m is_stream.m \ - is_struct.m is_symmetric.m is_vector.m isstr.m lchol.m loadimage.m \ - lognormal_cdf.m lognormal_inv.m lognormal_pdf.m lognormal_rnd.m \ - meshdom.m normal_cdf.m normal_inv.m normal_pdf.m normal_rnd.m \ - pascal_cdf.m pascal_inv.m pascal_pdf.m pascal_rnd.m poisson_cdf.m \ - poisson_inv.m poisson_pdf.m poisson_rnd.m polyinteg.m setstr.m \ - spatan2.m spchol2inv.m spcholinv.m spcumprod.m spcumsum.m \ - spchol.m spdet.m spdiag.m spfind.m spinv.m spkron.m splchol.m \ - splu.m spmax.m spmin.m spprod.m spqr.m spsum.m spsumsq.m \ - struct_contains.m struct_elements.m t_cdf.m t_inv.m t_pdf.m \ - t_rnd.m uniform_cdf.m uniform_inv.m uniform_pdf.m uniform_rnd.m \ - weibcdf.m weibinv.m weibpdf.m weibrnd.m weibull_cdf.m \ - weibull_inv.m weibull_pdf.m weibull_rnd.m wiener_rnd.m str2mat.m + is_struct.m is_symmetric.m is_vector.m iscommand.m israwcommand.m \ + isstr.m lchol.m loadimage.m lognormal_cdf.m lognormal_inv.m \ + lognormal_pdf.m lognormal_rnd.m mark_as_command.m \ + mark_as_rawcommand.m meshdom.m normal_cdf.m normal_inv.m \ + normal_pdf.m normal_rnd.m pascal_cdf.m pascal_inv.m pascal_pdf.m \ + pascal_rnd.m poisson_cdf.m poisson_inv.m poisson_pdf.m \ + poisson_rnd.m polyinteg.m setstr.m spatan2.m spchol2inv.m \ + spcholinv.m spcumprod.m spcumsum.m spchol.m spdet.m spdiag.m \ + spfind.m spinv.m spkron.m splchol.m splu.m spmax.m spmin.m \ + spprod.m spqr.m spsum.m spsumsq.m struct_contains.m \ + struct_elements.m t_cdf.m t_inv.m t_pdf.m t_rnd.m uniform_cdf.m \ + uniform_inv.m uniform_pdf.m uniform_rnd.m unmark_command.m \ + unmark_rawcommand.m weibcdf.m weibinv.m weibpdf.m weibrnd.m \ + weibull_cdf.m weibull_inv.m weibull_pdf.m weibull_rnd.m \ + wiener_rnd.m str2mat.m DISTFILES = $(addprefix $(srcdir)/, Makefile.in $(SOURCES)) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/deprecated/iscommand.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/iscommand.m Sun Feb 15 23:49:15 2009 -0500 @@ -0,0 +1,44 @@ +## Copyright (C) 2009 John W. Eaton +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Built-in Function} {} iscommand (@var{name}) +## This function is obsolete and will be removed from a future +## version of Octave. +## @end deftypefn + +## Author: jwe + +## Deprecated in version 3.2 + +function retval = iscommand () + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "iscommand is obsolete and will be removed from a future version of Octave"); + endif + + if (nargin == 0) + retval = {}; + else + retval = true; + endif + +endfunction diff -r 6dc61981d18b -r 5dd06f19e9be scripts/deprecated/israwcommand.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/israwcommand.m Sun Feb 15 23:49:15 2009 -0500 @@ -0,0 +1,44 @@ +## Copyright (C) 2009 John W. Eaton +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Built-in Function} {} israwcommand (@var{name}) +## This function is obsolete and will be removed from a future +## version of Octave. +## @end deftypefn + +## Author: jwe + +## Deprecated in version 3.2 + +function retval = israwcommand () + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "israwcommand is obsolete and will be removed from a future version of Octave"); + endif + + if (nargin == 0) + retval = {}; + else + retval = true; + endif + +endfunction diff -r 6dc61981d18b -r 5dd06f19e9be scripts/deprecated/mark_as_command.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/mark_as_command.m Sun Feb 15 23:49:15 2009 -0500 @@ -0,0 +1,38 @@ +## Copyright (C) 2009 John W. Eaton +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Built-in Function} {} mark_as_command (@var{name}) +## This function is obsolete and will be removed from a future +## version of Octave. +## @end deftypefn + +## Author: jwe + +## Deprecated in version 3.2 + +function mark_as_command () + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "mark_as_command is obsolete and will be removed from a future version of Octave"); + endif + +endfunction diff -r 6dc61981d18b -r 5dd06f19e9be scripts/deprecated/mark_as_rawcommand.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/mark_as_rawcommand.m Sun Feb 15 23:49:15 2009 -0500 @@ -0,0 +1,38 @@ +## Copyright (C) 2009 John W. Eaton +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Built-in Function} {} mark_as_rawcommand (@var{name}) +## This function is obsolete and will be removed from a future +## version of Octave. +## @end deftypefn + +## Author: jwe + +## Deprecated in version 3.2 + +function mark_as_rawcommand () + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "mark_as_rawcommand is obsolete and will be removed from a future version of Octave"); + endif + +endfunction diff -r 6dc61981d18b -r 5dd06f19e9be scripts/deprecated/unmark_command.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/unmark_command.m Sun Feb 15 23:49:15 2009 -0500 @@ -0,0 +1,38 @@ +## Copyright (C) 2009 John W. Eaton +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Built-in Function} {} unmark_command (@var{name}) +## This function is obsolete and will be removed from a future +## version of Octave. +## @end deftypefn + +## Author: jwe + +## Deprecated in version 3.2 + +function unmark_command () + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "unmark_command is obsolete and will be removed from a future version of Octave"); + endif + +endfunction diff -r 6dc61981d18b -r 5dd06f19e9be scripts/deprecated/unmark_rawcommand.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/unmark_rawcommand.m Sun Feb 15 23:49:15 2009 -0500 @@ -0,0 +1,38 @@ +## Copyright (C) 2009 John W. Eaton +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Built-in Function} {} unmark_rawcommand (@var{name}) +## This function is obsolete and will be removed from a future +## version of Octave. +## @end deftypefn + +## Author: jwe + +## Deprecated in version 3.2 + +function unmark_rawcommand () + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "unmark_rawcommand is obsolete and will be removed from a future version of Octave"); + endif + +endfunction diff -r 6dc61981d18b -r 5dd06f19e9be scripts/help/doc.m --- a/scripts/help/doc.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/help/doc.m Sun Feb 15 23:49:15 2009 -0500 @@ -34,8 +34,6 @@ ## Author: Soren Hauberg ## Adapted-by: jwe -## PKG_ADD: mark_as_command doc - function retval = doc (fname) if (nargin == 0 || nargin == 1) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/help/help.m --- a/scripts/help/help.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/help/help.m Sun Feb 15 23:49:15 2009 -0500 @@ -29,8 +29,6 @@ ## @seealso{doc, which, lookfor} ## @end deftypefn -## PKG_ADD: mark_as_command help - function help (name) if (nargin == 0) disp ("Help is available for the topics listed below."); diff -r 6dc61981d18b -r 5dd06f19e9be scripts/help/lookfor.m --- a/scripts/help/lookfor.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/help/lookfor.m Sun Feb 15 23:49:15 2009 -0500 @@ -39,8 +39,6 @@ ## @seealso{help, which} ## @end deftypefn -## PKG_ADD: mark_as_command lookfor - function [out_fun, out_help_text] = lookfor (str, extra) if (strcmpi (str, "-all")) ## The difference between using '-all' and not, is which part of the caches diff -r 6dc61981d18b -r 5dd06f19e9be scripts/help/type.m --- a/scripts/help/type.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/help/type.m Sun Feb 15 23:49:15 2009 -0500 @@ -26,8 +26,6 @@ ## each requested function. ## @end deftypefn -## PKG_ADD: mark_as_command type - function retval = type (varargin) ## Parse input if (nargin == 0) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/help/which.m --- a/scripts/help/which.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/help/which.m Sun Feb 15 23:49:15 2009 -0500 @@ -21,8 +21,6 @@ ## @seealso{help, lookfor} ## @end deffn -## PKG_ADD: mark_as_command which - function varargout = which (varargin) if (nargin > 0 && iscellstr (varargin)) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/image/colormap.m --- a/scripts/image/colormap.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/image/colormap.m Sun Feb 15 23:49:15 2009 -0500 @@ -38,8 +38,6 @@ ## Created: July 1994 ## Adapted-By: jwe -## PKG_ADD: mark_as_command colormap - function cmap = colormap (map) if (nargin > 1) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/miscellaneous/delete.m --- a/scripts/miscellaneous/delete.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/miscellaneous/delete.m Sun Feb 15 23:49:15 2009 -0500 @@ -22,8 +22,6 @@ ## Delete the named file or graphics handle. ## @end deftypefn -## PKG_ADD: mark_as_command delete - ## Author: jwe function delete (arg) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/miscellaneous/dir.m --- a/scripts/miscellaneous/dir.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/miscellaneous/dir.m Sun Feb 15 23:49:15 2009 -0500 @@ -49,8 +49,6 @@ ## Author: jwe -## PKG_ADD: mark_as_command dir - ## FIXME -- this is quite slow for large directories, so perhaps ## it should be converted to C++. diff -r 6dc61981d18b -r 5dd06f19e9be scripts/miscellaneous/edit.m --- a/scripts/miscellaneous/edit.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/miscellaneous/edit.m Sun Feb 15 23:49:15 2009 -0500 @@ -134,8 +134,6 @@ ## Original version by Paul Kienzle distributed as free software in the ## public domain. -## PKG_ADD: mark_as_command edit - function ret = edit (file, state) ## Pick up globals or default them. @@ -498,13 +496,13 @@ endfunction %!test -%! s.editor = edit get editor; -%! s.home = edit get home; -%! s.author = edit get author; -%! s.email = edit get email; -%! s.license = edit get license; -%! s.editinplace = edit get editinplace; -%! s.mode = edit get mode; +%! s.editor = edit ("get", "editor"); +%! s.home = edit ("get", "home"); +%! s.author = edit ("get", "author"); +%! s.email = edit ("get", "email"); +%! s.license = edit ("get", "license"); +%! s.editinplace = edit ("get", "editinplace"); +%! s.mode = edit ("get", "mode"); %! edit editor none %! edit home none %! edit author none diff -r 6dc61981d18b -r 5dd06f19e9be scripts/miscellaneous/intwarning.m --- a/scripts/miscellaneous/intwarning.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/miscellaneous/intwarning.m Sun Feb 15 23:49:15 2009 -0500 @@ -65,8 +65,6 @@ ## @seealso{warning} ## @end deftypefn -## PKG_ADD: mark_as_command intwarning - function y = intwarning (x) if (nargin != 1) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/miscellaneous/ls.m --- a/scripts/miscellaneous/ls.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/miscellaneous/ls.m Sun Feb 15 23:49:15 2009 -0500 @@ -35,8 +35,6 @@ ## Author: jwe -## PKG_ADD: mark_as_command ls - function retval = ls (varargin) global __ls_command__; diff -r 6dc61981d18b -r 5dd06f19e9be scripts/miscellaneous/mex.m --- a/scripts/miscellaneous/mex.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/miscellaneous/mex.m Sun Feb 15 23:49:15 2009 -0500 @@ -23,8 +23,6 @@ ## @seealso{mkoctfile} ## @end deftypefn -## PKG_ADD: mark_as_command mex - function mex (varargin) args = {"--mex", varargin{:}}; mkoctfile (args{:}); diff -r 6dc61981d18b -r 5dd06f19e9be scripts/miscellaneous/mkoctfile.m --- a/scripts/miscellaneous/mkoctfile.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/miscellaneous/mkoctfile.m Sun Feb 15 23:49:15 2009 -0500 @@ -117,8 +117,6 @@ ## @end table ## @end deftypefn -## PKG_ADD: mark_as_command mkoctfile - function mkoctfile (varargin) bindir = octave_config_info ("bindir"); diff -r 6dc61981d18b -r 5dd06f19e9be scripts/miscellaneous/run.m --- a/scripts/miscellaneous/run.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/miscellaneous/run.m Sun Feb 15 23:49:15 2009 -0500 @@ -26,8 +26,6 @@ ## @seealso{system} ## @end deftypefn -## PKG_ADD: mark_as_command run - function run (s) if (nargin != 1) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/miscellaneous/what.m --- a/scripts/miscellaneous/what.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/miscellaneous/what.m Sun Feb 15 23:49:15 2009 -0500 @@ -27,8 +27,6 @@ ## @seealso{which} ## @end deftypefn -## PKG_ADD: mark_as_command what - function ret = what (d) if (nargin == 0) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/path/savepath.m --- a/scripts/path/savepath.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/path/savepath.m Sun Feb 15 23:49:15 2009 -0500 @@ -27,8 +27,6 @@ ## Author: Bill Denney -##PKGADD: mark_as_command savepath - function varargout = savepath (savefile) retval = 1; diff -r 6dc61981d18b -r 5dd06f19e9be scripts/pkg/pkg.m --- a/scripts/pkg/pkg.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/pkg/pkg.m Sun Feb 15 23:49:15 2009 -0500 @@ -195,8 +195,6 @@ ## @end table ## @end deftypefn -## PKG_ADD: mark_as_command pkg - function [local_packages, global_packages] = pkg (varargin) ## Installation prefix (FIXME: what should these be on windows?) persistent user_prefix = false; diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/axis.m --- a/scripts/plot/axis.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/axis.m Sun Feb 15 23:49:15 2009 -0500 @@ -114,8 +114,6 @@ ## Author: jwe -## PKG_ADD: mark_as_command axis - function varargout = axis (varargin) [h, varargin, nargin] = __plt_get_axis_arg__ ("axis", varargin{:}); diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/box.m --- a/scripts/plot/box.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/box.m Sun Feb 15 23:49:15 2009 -0500 @@ -27,8 +27,6 @@ ## Author: jwe -## PKG_ADD: mark_as_command box - function box (varargin) h = gca (); diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/caxis.m --- a/scripts/plot/caxis.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/caxis.m Sun Feb 15 23:49:15 2009 -0500 @@ -35,8 +35,6 @@ ## this axes rather than the current axes. ## @end deftypefn -## PKG_ADD: mark_as_command caxis - function varargout = caxis (varargin) [h, varargin, nargin] = __plt_get_axis_arg__ ("caxis", varargin{:}); diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/cla.m --- a/scripts/plot/cla.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/cla.m Sun Feb 15 23:49:15 2009 -0500 @@ -29,8 +29,6 @@ ## Author: Ben Abbott ## Created: 2008-10-03 -## PKG_ADD: mark_as_command cla - function cla (varargin) if (nargin > 2) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/close.m --- a/scripts/plot/close.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/close.m Sun Feb 15 23:49:15 2009 -0500 @@ -29,8 +29,6 @@ ## Author: jwe -## PKG_ADD: mark_as_command close - function retval = close (arg1, arg2) figs = []; diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/colorbar.m --- a/scripts/plot/colorbar.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/colorbar.m Sun Feb 15 23:49:15 2009 -0500 @@ -46,9 +46,6 @@ ## as the axes handle on which to add the colorbar. ## @end deftypefn - -## PKG_ADD: mark_as_command colorbar - function h = colorbar (varargin) ax = []; loc = "eastoutside"; diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/grid.m --- a/scripts/plot/grid.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/grid.m Sun Feb 15 23:49:15 2009 -0500 @@ -37,8 +37,6 @@ ## Author: jwe -## PKG_ADD: mark_as_command grid - function grid (varargin) persistent grid_on = false; diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/hidden.m --- a/scripts/plot/hidden.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/hidden.m Sun Feb 15 23:49:15 2009 -0500 @@ -25,8 +25,6 @@ ## @seealso{mesh, meshc, surf} ## @end deftypefn -## PKG_ADD: mark_as_command hidden - function retval = hidden (mode) if (nargin == 0) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/hold.m --- a/scripts/plot/hold.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/hold.m Sun Feb 15 23:49:15 2009 -0500 @@ -40,8 +40,6 @@ ## ## @end deftypefn -## PKG_ADD: mark_as_command hold - function hold (varargin) if (nargin > 0 && numel (varargin{1}) == 1 && ishandle (varargin{1}(1)) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/legend.m --- a/scripts/plot/legend.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/legend.m Sun Feb 15 23:49:15 2009 -0500 @@ -76,8 +76,6 @@ ## @end table ## @end deftypefn -## PKG_ADD mark_as_command legend - function legend (varargin) [ca, varargin, nargin] = __plt_get_axis_arg__ ("legend", varargin{:}); diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/orient.m --- a/scripts/plot/orient.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/orient.m Sun Feb 15 23:49:15 2009 -0500 @@ -26,8 +26,6 @@ ## Author: Paul Kienzle ## Adapted-By: jwe -## PKG_ADD: mark_as_command orient - function retval = orient (varargin) nargs = nargin; diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/print.m --- a/scripts/plot/print.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/print.m Sun Feb 15 23:49:15 2009 -0500 @@ -126,8 +126,6 @@ ## Author: Daniel Heiserer ## Adapted-By: jwe -## PKG_ADD: mark_as_command print - function print (varargin) orientation = orient (); diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/shading.m --- a/scripts/plot/shading.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/shading.m Sun Feb 15 23:49:15 2009 -0500 @@ -40,8 +40,6 @@ ## Author: Kai Habel -## PKG_ADD: mark_as_command shading - function shading (varargin) [ax, varargin] = __plt_get_axis_arg__ ("shading", varargin{:}); diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/title.m --- a/scripts/plot/title.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/title.m Sun Feb 15 23:49:15 2009 -0500 @@ -23,8 +23,6 @@ ## Create a title object and return a handle to it. ## @end deftypefn -## PKG_ADD: mark_as_command title - ## Author: jwe function h = title (s, varargin) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/xlabel.m --- a/scripts/plot/xlabel.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/xlabel.m Sun Feb 15 23:49:15 2009 -0500 @@ -28,8 +28,6 @@ ## bar, stairs, title} ## @end deftypefn -## PKG_ADD: mark_as_command xlabel - ## Author: jwe function retval = xlabel (varargin) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/ylabel.m --- a/scripts/plot/ylabel.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/ylabel.m Sun Feb 15 23:49:15 2009 -0500 @@ -23,8 +23,6 @@ ## @seealso{xlabel}. ## @end deftypefn -## PKG_ADD: mark_as_command ylabel - ## Author: jwe function retval = ylabel (varargin) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/plot/zlabel.m --- a/scripts/plot/zlabel.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/plot/zlabel.m Sun Feb 15 23:49:15 2009 -0500 @@ -23,8 +23,6 @@ ## @seealso{xlabel}. ## @end deftypefn -## PKG_ADD: mark_as_command zlabel - ## Author: jwe function retval = zlabel (varargin) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/testfun/demo.m --- a/scripts/testfun/demo.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/testfun/demo.m Sun Feb 15 23:49:15 2009 -0500 @@ -74,8 +74,6 @@ ## use the current figure window but pause if not plotting in the ## first subplot. -## PKG_ADD: mark_as_command demo - function demo (name, n) if (nargin < 1 || nargin > 2) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/testfun/example.m --- a/scripts/testfun/example.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/testfun/example.m Sun Feb 15 23:49:15 2009 -0500 @@ -32,8 +32,6 @@ ## @seealso{demo, test} ## @end deftypefn -## PKG_ADD: mark_as_command example - function [code_r, idx_r] = example (name, n) if (nargin < 1 || nargin > 2) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/testfun/fail.m --- a/scripts/testfun/fail.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/testfun/fail.m Sun Feb 15 23:49:15 2009 -0500 @@ -48,8 +48,6 @@ ## Author: Paul Kienzle -## PKG_ADD mark_as_command fail - function ret = fail (code, pattern, warning_pattern) if (nargin < 1 || nargin > 3) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/testfun/rundemos.m --- a/scripts/testfun/rundemos.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/testfun/rundemos.m Sun Feb 15 23:49:15 2009 -0500 @@ -20,8 +20,6 @@ ## @deftypefn {Function File} {} rundemos (@var{directory}) ## @end deftypefn -## PKG_ADD: mark_as_command rundemos - ## Author: jwe function rundemos (directory) diff -r 6dc61981d18b -r 5dd06f19e9be scripts/testfun/test.m --- a/scripts/testfun/test.m Sun Feb 15 16:31:16 2009 -0500 +++ b/scripts/testfun/test.m Sun Feb 15 23:49:15 2009 -0500 @@ -73,8 +73,6 @@ ## can include them in test sections which means that we can use ## octave flow control for both kinds of tests. -## PKG_ADD: mark_as_command test - function [__ret1, __ret2, __ret3, __ret4] = test (__name, __flag, __fid) ## Information from test will be introduced by "key". persistent __signal_fail = "!!!!! "; diff -r 6dc61981d18b -r 5dd06f19e9be src/ChangeLog --- a/src/ChangeLog Sun Feb 15 16:31:16 2009 -0500 +++ b/src/ChangeLog Sun Feb 15 23:49:15 2009 -0500 @@ -1,5 +1,44 @@ 2009-02-15 John W. Eaton + * defun.cc, defun-int.h, defun-dld.h (DEFUN_INTERNAL, + DEFCONSTFUN_INTERNAL, DEFUNX_INTERNAL, DEFUN_DLD_INTERNAL, + DEFUNX_DLD_INTERNAL, install_builtin_function, + install_dld_function, install_mex_function): + Delete IS_TEXT_FCN arg. Fix all uses. + (DEFMD, DEFUN_TEXT): Delete. + * mkbuiltins, mkgendoc: Adapt to DEFUN macro changes. + + * lex.h, lex.l (lexer_flags::at_beginning_of_statement): + New data member. Set it as needed in rules. + (is_keyword_token): + Handle lexer_flags::at_beginning_of_statement. + (next_token_can_follow_bin_op, looks_like_command_arg): New functions. + (handle_identifier): Use them to determine + Don't check is_command_name or is_rawcommand_name. + * parse.y (statement): Recognize word_list_cmd here. + (expression): Not here. + + * lex.l (handle_string): Delete arg TEXT_STYLE. + (BIN_OP_RETURN, XBIN_OP_RETURN): New arg, BOS. Change all uses. + + * lex.h, lex.l (lexer_flags::doing_raw_command): Delete data + member and all uses. + + * debug.cc, dirfns.cc, error.cc, input.cc, lex.l, load-path.cc, + load-save.cc, oct-hist.cc, ov-class.cc, pager.cc, parse.y, + pr-output.cc, sysdep.cc, utils.cc, variables.cc: + Replace all uses of DEFCMD with DEFUN. + + * variables.cc (command_set, rawcommand_set): Delete static variables. + (mark_as_command, unmark_command, is_command_name, + mark_as_rawcommand, unmark_raw_command, is_rawcommand_name): Delete. + (Fmark_as_command, Funmark_command, Fiscommand, + Fmark_as_rawcommand, Funmark_rawcommand, Fisrawcommand): + Convert to .m files and move to scripts/deprecated. + * variables.h (mark_as_command, is_command_name, + is_marked_as_rawcommand, mark_as_rawcommand, unmark_rawcommand, + is_rawcommand_name): Delete decls. + * lex.h, lex.l (lexer_flags.looking_at_object_index): Now a std::list object instead of an int. Push TRUE to list at start of object index. Push FALSE at diff -r 6dc61981d18b -r 5dd06f19e9be src/debug.cc --- a/src/debug.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/debug.cc Sun Feb 15 23:49:15 2009 -0500 @@ -490,7 +490,7 @@ return retval; } -DEFCMD (dbstop, args, , +DEFUN (dbstop, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{rline} =} dbstop (@var{func}, @var{line}, @dots{})\n\ Set a breakpoint in a function\n\ @@ -522,7 +522,7 @@ return intmap_to_ov (retval); } -DEFCMD (dbclear, args, , +DEFUN (dbclear, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} dbclear (@var{func}, @var{line}, @dots{})\n\ Delete a breakpoint in a function\n\ @@ -551,7 +551,7 @@ return retval; } -DEFCMD (dbstatus, args, nargout, +DEFUN (dbstatus, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {lst =} dbstatus (@var{func})\n\ Return a vector containing the lines on which a function has \n\ @@ -646,7 +646,7 @@ } } -DEFCMD (dbwhere, , , +DEFUN (dbwhere, , , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} dbwhere ()\n\ Show where we are in the code\n\ @@ -745,7 +745,7 @@ os.flush (); } -DEFCMD (dbtype, args, , +DEFUN (dbtype, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} dbtype ()\n\ List script file with line numbers.\n\ @@ -851,7 +851,7 @@ return retval; } -DEFCMD (dbstack, args, nargout, +DEFUN (dbstack, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{stack}, @var{idx}]} dbstack (@var{n})\n\ Print or return current stack information. With optional argument\n\ @@ -959,7 +959,7 @@ } } -DEFCMD (dbup, args, , +DEFUN (dbup, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} dbup (@var{n})\n\ In debugging mode, move up the execution stack @var{n} frames.\n\ @@ -974,7 +974,7 @@ return retval; } -DEFCMD (dbdown, args, , +DEFUN (dbdown, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} dbdown (@var{n})\n\ In debugging mode, move down the execution stack @var{n} frames.\n\ @@ -989,7 +989,7 @@ return retval; } -DEFCMD (dbstep, args, , +DEFUN (dbstep, args, , "-*- texinfo -*-\n\ @deftypefn {Command} {} dbstep @var{n}\n\ @deftypefnx {Command} {} dbstep in\n\ @@ -1063,7 +1063,7 @@ DEFALIAS (dbnext, dbstep); -DEFCMD (dbcont, args, , +DEFUN (dbcont, args, , "-*- texinfo -*-\n\ @deftypefn {Command} {} dbcont ()\n\ In debugging mode, quit debugging mode and continue execution.\n\ @@ -1087,7 +1087,7 @@ return octave_value_list (); } -DEFCMD (dbquit, args, , +DEFUN (dbquit, args, , "-*- texinfo -*-\n\ @deftypefn {Command} {} dbquit ()\n\ In debugging mode, quit debugging mode and return to the top level.\n\ @@ -1111,7 +1111,7 @@ return octave_value_list (); } -DEFCMD (isdebugmode, args, , +DEFUN (isdebugmode, args, , "-*- texinfo -*-\n\ @deftypefn {Command} {} isdebugmode ()\n\ Return true if debug mode is on, otherwise false.\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/defun-dld.h --- a/src/defun-dld.h Sun Feb 15 16:31:16 2009 -0500 +++ b/src/defun-dld.h Sun Feb 15 23:49:15 2009 -0500 @@ -43,7 +43,7 @@ #if defined (MAKE_BUILTINS) #define DEFUN_DLD(name, args_name, nargout_name, doc) \ - DEFUN_DLD_INTERNAL (name, args_name, nargout_name, false, doc) + DEFUN_DLD_INTERNAL (name, args_name, nargout_name, doc) // This one can be used when `name' cannot be used directly (if it is // already defined as a macro). In that case, name is already a @@ -53,7 +53,7 @@ // (the convention is to use a prefix of "G", so "foo" becomes "Gfoo"). #define DEFUNX_DLD(name, fname, gname, args_name, nargout_name, doc) \ - DEFUNX_DLD_INTERNAL (name, fname, args_name, nargout_name, false, doc) + DEFUNX_DLD_INTERNAL (name, fname, args_name, nargout_name, doc) #else diff -r 6dc61981d18b -r 5dd06f19e9be src/defun-int.h --- a/src/defun-int.h Sun Feb 15 16:31:16 2009 -0500 +++ b/src/defun-int.h Sun Feb 15 23:49:15 2009 -0500 @@ -40,19 +40,17 @@ extern OCTINTERP_API void install_builtin_function (octave_builtin::fcn f, const std::string& name, - const std::string& doc, bool is_text_fcn = false, + const std::string& doc, bool can_hide_function = true); extern OCTINTERP_API void install_dld_function (octave_dld_function::fcn f, const std::string& name, - const octave_shlib& shl, - const std::string& doc, bool is_text_fcn = false, + const octave_shlib& shl, const std::string& doc, bool relative = false); extern OCTINTERP_API void install_mex_function (void *fptr, bool fmex, const std::string& name, - const octave_shlib& shl, bool is_text_fcn = false, - bool relative = false); + const octave_shlib& shl, bool relative = false); extern OCTINTERP_API void alias_builtin (const std::string& alias, const std::string& name); @@ -108,35 +106,33 @@ // mkdefs will create a .def file for every .cc file that uses DEFUN, // or DEFCMD. -#define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ +#define DEFUN_INTERNAL(name, args_name, nargout_name, doc) \ BEGIN_INSTALL_BUILTIN \ - XDEFUN_INTERNAL (name, args_name, nargout_name, is_text_fcn, doc) \ + XDEFUN_INTERNAL (name, args_name, nargout_name, doc) \ END_INSTALL_BUILTIN -#define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ +#define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \ BEGIN_INSTALL_BUILTIN \ - XDEFCONSTFUN_INTERNAL (name, args_name, nargout_name, is_text_fcn, doc) \ + XDEFCONSTFUN_INTERNAL (name, args_name, nargout_name, doc) \ END_INSTALL_BUILTIN -#define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, \ - is_text_fcn, doc) \ +#define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \ BEGIN_INSTALL_BUILTIN \ - XDEFUNX_INTERNAL (name, fname, args_name, nargout_name, is_text_fcn, doc) \ + XDEFUNX_INTERNAL (name, fname, args_name, nargout_name, doc) \ END_INSTALL_BUILTIN // Generate code to install name in the symbol table. The script // mkdefs will create a .def file for every .cc file that uses // DEFUN_DLD. -#define DEFUN_DLD_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ +#define DEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) \ BEGIN_INSTALL_BUILTIN \ - XDEFUN_DLD_INTERNAL (name, args_name, nargout_name, is_text_fcn, doc) \ + XDEFUN_DLD_INTERNAL (name, args_name, nargout_name, doc) \ END_INSTALL_BUILTIN -#define DEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, \ - is_text_fcn, doc) \ +#define DEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) \ BEGIN_INSTALL_BUILTIN \ - XDEFUNX_DLD_INTERNAL (name, fname, args_name, nargout_name, is_text_fcn, doc) \ + XDEFUNX_DLD_INTERNAL (name, fname, args_name, nargout_name, doc) \ END_INSTALL_BUILTIN // Generate code for making another name for an existing function. @@ -151,14 +147,13 @@ // Generate the first line of the function definition. This ensures // that the internal functions all have the same signature. -#define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ +#define DEFUN_INTERNAL(name, args_name, nargout_name, doc) \ DECLARE_FUN (name, args_name, nargout_name) -#define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ +#define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \ DECLARE_FUN (name, args_name, nargout_name) -#define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, \ - is_text_fcn, doc) \ +#define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \ DECLARE_FUNX (fname, args_name, nargout_name) // No definition is required for an alias. diff -r 6dc61981d18b -r 5dd06f19e9be src/defun.cc --- a/src/defun.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/defun.cc Sun Feb 15 23:49:15 2009 -0500 @@ -80,21 +80,17 @@ void install_builtin_function (octave_builtin::fcn f, const std::string& name, - const std::string& doc, bool is_text_fcn, + const std::string& doc, bool /* can_hide_function -- not yet implemented */) { octave_value fcn (new octave_builtin (f, name, doc)); symbol_table::install_built_in_function (name, fcn); - - if (is_text_fcn) - mark_as_command (name); } void install_dld_function (octave_dld_function::fcn f, const std::string& name, - const octave_shlib& shl, - const std::string& doc, bool is_text_fcn, + const octave_shlib& shl, const std::string& doc, bool relative) { octave_dld_function *fcn = new octave_dld_function (f, shl, name, doc); @@ -105,15 +101,11 @@ octave_value fval (fcn); symbol_table::install_built_in_function (name, fval); - - if (is_text_fcn) - mark_as_command (name); } void install_mex_function (void *fptr, bool fmex, const std::string& name, - const octave_shlib& shl, bool is_text_fcn, - bool relative) + const octave_shlib& shl, bool relative) { octave_mex_function *fcn = new octave_mex_function (fptr, fmex, shl, name); @@ -123,9 +115,6 @@ octave_value fval (fcn); symbol_table::install_built_in_function (name, fval); - - if (is_text_fcn) - mark_as_command (name); } void diff -r 6dc61981d18b -r 5dd06f19e9be src/defun.h --- a/src/defun.h Sun Feb 15 16:31:16 2009 -0500 +++ b/src/defun.h Sun Feb 15 23:49:15 2009 -0500 @@ -43,7 +43,7 @@ // doc is the simple help text for the function. #define DEFUN(name, args_name, nargout_name, doc) \ - DEFUN_INTERNAL (name, args_name, nargout_name, false, doc) + DEFUN_INTERNAL (name, args_name, nargout_name, doc) // This one can be used when `name' cannot be used directly (if it is // already defined as a macro). In that case, name is already a @@ -51,24 +51,11 @@ // too (the convention is to use a prefix of "F", so "foo" becomes "Ffoo"). #define DEFUNX(name, fname, args_name, nargout_name, doc) \ - DEFUNX_INTERNAL (name, fname, args_name, nargout_name, false, doc) - -// Define a builtin command-style function. -// -// This is like DEFUN, except that it defines a function that can be -// called from the Octave language without using parenthesis to -// surround the arguments). - -#define DEFCMD(name, args_name, nargout_name, doc) \ - DEFUN_INTERNAL (name, args_name, nargout_name, true, doc) - -// For backward compatibility. - -#define DEFUN_TEXT DEFCMD + DEFUNX_INTERNAL (name, fname, args_name, nargout_name, doc) // This is a function with a name that can't be hidden by a variable. #define DEFCONSTFUN(name, args_name, nargout_name, doc) \ - DEFCONSTFUN_INTERNAL (name, args_name, nargout_name, true, doc) + DEFCONSTFUN_INTERNAL (name, args_name, nargout_name, doc) // Make alias another name for the existing function name. This macro // must be used in the same file where name is defined, after the diff -r 6dc61981d18b -r 5dd06f19e9be src/dirfns.cc --- a/src/dirfns.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/dirfns.cc Sun Feb 15 23:49:15 2009 -0500 @@ -96,7 +96,7 @@ return cd_ok; } -DEFCMD (cd, args, , +DEFUN (cd, args, , "-*- texinfo -*-\n\ @deffn {Command} cd dir\n\ @deffnx {Command} chdir dir\n\ @@ -206,7 +206,7 @@ // FIXME -- should maybe also allow second arg to specify // mode? OTOH, that might cause trouble with compatibility later... -DEFCMD (mkdir, args, , +DEFUN (mkdir, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} mkdir (@var{dir})\n\ @deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} mkdir (@var{parent}, @var{dir})\n\ @@ -289,7 +289,7 @@ return retval; } -DEFCMD (rmdir, args, , +DEFUN (rmdir, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} rmdir (@var{dir})\n\ @deftypefnx {Built-in Function} {[@var{status}, @var{msg}, @var{msgid}] =} rmdir (@var{dir}, @code{\"s\"})\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/error.cc --- a/src/error.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/error.cc Sun Feb 15 23:49:15 2009 -0500 @@ -1033,7 +1033,7 @@ return retval; } -DEFCMD (warning, args, nargout, +DEFUN (warning, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} warning (@var{template}, @dots{})\n\ @deftypefnx {Built-in Function} {} warning (@var{id}, @var{template}, @dots{})\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/input.cc --- a/src/input.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/input.cc Sun Feb 15 23:49:15 2009 -0500 @@ -934,7 +934,7 @@ return retval; } -DEFCMD (echo, args, , +DEFUN (echo, args, , "-*- texinfo -*-\n\ @deffn {Command} echo options\n\ Control whether commands are displayed as they are executed. Valid\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/lex.h --- a/src/lex.h Sun Feb 15 16:31:16 2009 -0500 +++ b/src/lex.h Sun Feb 15 23:49:15 2009 -0500 @@ -82,6 +82,10 @@ // matrix definition. bool convert_spaces_to_comma; + // TRUE means we are at the beginning of a statement, where a + // command name is possible. + bool at_beginning_of_statement; + // TRUE means we're in the middle of defining a function. bool defining_func; @@ -116,9 +120,6 @@ // GAG. Stupid kludge so that [[1,2][3,4]] will work. bool do_comma_insert; - // TRUE means we're doing a raw input command. - bool doing_rawcommand; - // TRUE means we're looking at an indirect reference to a // structure element. bool looking_at_indirect_ref; diff -r 6dc61981d18b -r 5dd06f19e9be src/lex.l --- a/src/lex.l Sun Feb 15 16:31:16 2009 -0500 +++ b/src/lex.l Sun Feb 15 23:49:15 2009 -0500 @@ -1,7 +1,7 @@ /* Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006, 2007 John W. Eaton + 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 John W. Eaton This file is part of Octave. @@ -156,7 +156,7 @@ } \ while (0) -#define BIN_OP_RETURN(tok, convert) \ +#define BIN_OP_RETURN(tok, convert, bos) \ do \ { \ yylval.tok_val = new token (input_line_number, current_input_column); \ @@ -165,15 +165,16 @@ lexer_flags.quote_is_transpose = false; \ lexer_flags.convert_spaces_to_comma = convert; \ lexer_flags.looking_for_object_index = false; \ + lexer_flags.at_beginning_of_statement = bos; \ COUNT_TOK_AND_RETURN (tok); \ } \ while (0) -#define XBIN_OP_RETURN(tok, convert) \ +#define XBIN_OP_RETURN(tok, convert, bos) \ do \ { \ gripe_matlab_incompatible_operator (yytext); \ - BIN_OP_RETURN (tok, convert); \ + BIN_OP_RETURN (tok, convert, bos); \ } \ while (0) @@ -288,7 +289,7 @@ static bool next_token_is_postfix_unary_op (bool spc_prev); static std::string strip_trailing_whitespace (char *s); static void handle_number (void); -static int handle_string (char delim, int text_style = 0); +static int handle_string (char delim); static int handle_close_bracket (bool spc_gobbled, int bracket_type); static int handle_identifier (void); static bool have_continuation (bool trailing_comments_ok = true); @@ -339,6 +340,9 @@ BEGIN (NESTED_FUNCTION_BEGIN); xunput (yytext[0], yytext); + + lexer_flags.at_beginning_of_statement = true; + COUNT_TOK_AND_RETURN (';'); } @@ -347,14 +351,14 @@ BEGIN (INITIAL); xunput (yytext[0], yytext); + prep_for_nested_function (); + COUNT_TOK_AND_RETURN (FCN); } %{ -// Help and other command-style functions are a pain in the ass. This -// stuff needs to be simplified. May require some changes in the -// parser too. +// Help and other command-style functions. %} {NL} { @@ -366,8 +370,8 @@ lexer_flags.quote_is_transpose = false; lexer_flags.convert_spaces_to_comma = true; - lexer_flags.doing_rawcommand = false; lexer_flags.looking_for_object_index = false; + lexer_flags.at_beginning_of_statement = true; COUNT_TOK_AND_RETURN ('\n'); } @@ -376,9 +380,7 @@ LEXER_DEBUG ("[\\;\\,]"); lexer_flags.looking_for_object_index = false; - - if (lexer_flags.doing_rawcommand) - TOK_PUSH_AND_RETURN (yytext, SQ_STRING); + lexer_flags.at_beginning_of_statement = true; BEGIN (INITIAL); @@ -391,8 +393,10 @@ [\"\'] { LEXER_DEBUG ("[\\\"\\']"); + lexer_flags.at_beginning_of_statement = false; + current_input_column++; - int tok = handle_string (yytext[0], true); + int tok = handle_string (yytext[0]); COUNT_TOK_AND_RETURN (tok); } @@ -403,6 +407,7 @@ std::string tok = strip_trailing_whitespace (yytext); lexer_flags.looking_for_object_index = false; + lexer_flags.at_beginning_of_statement = false; TOK_PUSH_AND_RETURN (tok, SQ_STRING); } @@ -430,6 +435,7 @@ lexer_flags.looking_at_object_index.pop_front (); lexer_flags.looking_for_object_index = true; + lexer_flags.at_beginning_of_statement = false; int c = yytext[yyleng-1]; int cont_is_spc = eat_continuation (); @@ -455,6 +461,7 @@ lexer_flags.looking_at_object_index.pop_front (); lexer_flags.looking_for_object_index = true; + lexer_flags.at_beginning_of_statement = false; int c = yytext[yyleng-1]; int cont_is_spc = eat_continuation (); @@ -483,6 +490,7 @@ lexer_flags.quote_is_transpose = false; lexer_flags.convert_spaces_to_comma = true; lexer_flags.looking_for_object_index = false; + lexer_flags.at_beginning_of_statement = false; if (! lexer_flags.looking_at_object_index.front ()) { @@ -509,6 +517,8 @@ current_input_column += yyleng; + lexer_flags.at_beginning_of_statement = false; + int tmp = eat_continuation (); if (! lexer_flags.looking_at_object_index.front ()) @@ -556,6 +566,7 @@ lexer_flags.quote_is_transpose = false; lexer_flags.convert_spaces_to_comma = true; lexer_flags.looking_for_object_index = false; + lexer_flags.at_beginning_of_statement = false; COUNT_TOK_AND_RETURN (';'); } @@ -578,6 +589,7 @@ lexer_flags.quote_is_transpose = false; lexer_flags.convert_spaces_to_comma = true; + lexer_flags.at_beginning_of_statement = false; if (nesting_level.none ()) return LEXICAL_ERROR; @@ -602,6 +614,7 @@ lexer_flags.quote_is_transpose = false; lexer_flags.convert_spaces_to_comma = true; lexer_flags.looking_for_object_index = false; + lexer_flags.at_beginning_of_statement = false; if (lexer_flags.defining_func && ! lexer_flags.parsed_function_name) lexer_flags.looking_at_return_list = true; @@ -624,6 +637,7 @@ lexer_flags.looking_at_object_index.pop_front (); lexer_flags.looking_for_object_index = true; + lexer_flags.at_beginning_of_statement = false; TOK_RETURN (']'); } @@ -727,6 +741,7 @@ lexer_flags.convert_spaces_to_comma = false; lexer_flags.looking_at_function_handle++; lexer_flags.looking_for_object_index = false; + lexer_flags.at_beginning_of_statement = false; COUNT_TOK_AND_RETURN ('@'); } @@ -742,12 +757,20 @@ input_line_number++; current_input_column = 1; + lexer_flags.quote_is_transpose = false; lexer_flags.convert_spaces_to_comma = true; + if (nesting_level.none ()) - COUNT_TOK_AND_RETURN ('\n'); + { + lexer_flags.at_beginning_of_statement = true; + COUNT_TOK_AND_RETURN ('\n'); + } else if (nesting_level.is_paren ()) - gripe_matlab_incompatible ("bare newline inside parentheses"); + { + lexer_flags.at_beginning_of_statement = false; + gripe_matlab_incompatible ("bare newline inside parentheses"); + } else if (nesting_level.is_bracket_or_brace ()) return LEXICAL_ERROR; } @@ -821,6 +844,7 @@ current_input_column = 1; block_comment_nesting_level++; promptflag--; + bool eof = false; process_comment (true, eof); } @@ -829,49 +853,50 @@ // Other operators. %} -":" { LEXER_DEBUG (":"); BIN_OP_RETURN (':', false); } - -".+" { LEXER_DEBUG (".+"); XBIN_OP_RETURN (EPLUS, false); } -".-" { LEXER_DEBUG (".-"); XBIN_OP_RETURN (EMINUS, false); } -".*" { LEXER_DEBUG (".*"); BIN_OP_RETURN (EMUL, false); } -"./" { LEXER_DEBUG ("./"); BIN_OP_RETURN (EDIV, false); } -".\\" { LEXER_DEBUG (".\\"); BIN_OP_RETURN (ELEFTDIV, false); } -".^" { LEXER_DEBUG (".^"); BIN_OP_RETURN (EPOW, false); } -".**" { LEXER_DEBUG (".**"); XBIN_OP_RETURN (EPOW, false); } -".'" { LEXER_DEBUG (".'"); do_comma_insert_check (); BIN_OP_RETURN (TRANSPOSE, true); } -"++" { LEXER_DEBUG ("++"); do_comma_insert_check (); XBIN_OP_RETURN (PLUS_PLUS, true); } -"--" { LEXER_DEBUG ("--"); do_comma_insert_check (); XBIN_OP_RETURN (MINUS_MINUS, true); } -"<=" { LEXER_DEBUG ("<="); BIN_OP_RETURN (EXPR_LE, false); } -"==" { LEXER_DEBUG ("=="); BIN_OP_RETURN (EXPR_EQ, false); } -"~=" { LEXER_DEBUG ("~="); BIN_OP_RETURN (EXPR_NE, false); } -"!=" { LEXER_DEBUG ("!="); XBIN_OP_RETURN (EXPR_NE, false); } -">=" { LEXER_DEBUG (">="); BIN_OP_RETURN (EXPR_GE, false); } -"&" { LEXER_DEBUG ("&"); BIN_OP_RETURN (EXPR_AND, false); } -"|" { LEXER_DEBUG ("|"); BIN_OP_RETURN (EXPR_OR, false); } -"<" { LEXER_DEBUG ("<"); BIN_OP_RETURN (EXPR_LT, false); } -">" { LEXER_DEBUG (">"); BIN_OP_RETURN (EXPR_GT, false); } -"+" { LEXER_DEBUG ("+"); BIN_OP_RETURN ('+', false); } -"-" { LEXER_DEBUG ("-"); BIN_OP_RETURN ('-', false); } -"*" { LEXER_DEBUG ("*"); BIN_OP_RETURN ('*', false); } -"/" { LEXER_DEBUG ("/"); BIN_OP_RETURN ('/', false); } -"\\" { LEXER_DEBUG ("\\"); BIN_OP_RETURN (LEFTDIV, false); } -";" { LEXER_DEBUG (";"); BIN_OP_RETURN (';', true); } -"," { LEXER_DEBUG (","); BIN_OP_RETURN (',', true); } -"^" { LEXER_DEBUG ("^"); BIN_OP_RETURN (POW, false); } -"**" { LEXER_DEBUG ("**"); XBIN_OP_RETURN (POW, false); } -"=" { LEXER_DEBUG ("="); BIN_OP_RETURN ('=', true); } -"&&" { LEXER_DEBUG ("&&"); BIN_OP_RETURN (EXPR_AND_AND, false); } -"||" { LEXER_DEBUG ("||"); BIN_OP_RETURN (EXPR_OR_OR, false); } -"<<" { LEXER_DEBUG ("<<"); XBIN_OP_RETURN (LSHIFT, false); } -">>" { LEXER_DEBUG (">>"); XBIN_OP_RETURN (RSHIFT, false); } +":" { LEXER_DEBUG (":"); BIN_OP_RETURN (':', false, false); } + +".+" { LEXER_DEBUG (".+"); XBIN_OP_RETURN (EPLUS, false, false); } +".-" { LEXER_DEBUG (".-"); XBIN_OP_RETURN (EMINUS, false, false); } +".*" { LEXER_DEBUG (".*"); BIN_OP_RETURN (EMUL, false, false); } +"./" { LEXER_DEBUG ("./"); BIN_OP_RETURN (EDIV, false, false); } +".\\" { LEXER_DEBUG (".\\"); BIN_OP_RETURN (ELEFTDIV, false, false); } +".^" { LEXER_DEBUG (".^"); BIN_OP_RETURN (EPOW, false, false); } +".**" { LEXER_DEBUG (".**"); XBIN_OP_RETURN (EPOW, false, false); } +".'" { LEXER_DEBUG (".'"); do_comma_insert_check (); BIN_OP_RETURN (TRANSPOSE, true, false); } +"++" { LEXER_DEBUG ("++"); do_comma_insert_check (); XBIN_OP_RETURN (PLUS_PLUS, true, false); } +"--" { LEXER_DEBUG ("--"); do_comma_insert_check (); XBIN_OP_RETURN (MINUS_MINUS, true, false); } +"<=" { LEXER_DEBUG ("<="); BIN_OP_RETURN (EXPR_LE, false, false); } +"==" { LEXER_DEBUG ("=="); BIN_OP_RETURN (EXPR_EQ, false, false); } +"~=" { LEXER_DEBUG ("~="); BIN_OP_RETURN (EXPR_NE, false, false); } +"!=" { LEXER_DEBUG ("!="); XBIN_OP_RETURN (EXPR_NE, false, false); } +">=" { LEXER_DEBUG (">="); BIN_OP_RETURN (EXPR_GE, false, false); } +"&" { LEXER_DEBUG ("&"); BIN_OP_RETURN (EXPR_AND, false, false); } +"|" { LEXER_DEBUG ("|"); BIN_OP_RETURN (EXPR_OR, false, false); } +"<" { LEXER_DEBUG ("<"); BIN_OP_RETURN (EXPR_LT, false, false); } +">" { LEXER_DEBUG (">"); BIN_OP_RETURN (EXPR_GT, false, false); } +"+" { LEXER_DEBUG ("+"); BIN_OP_RETURN ('+', false, false); } +"-" { LEXER_DEBUG ("-"); BIN_OP_RETURN ('-', false, false); } +"*" { LEXER_DEBUG ("*"); BIN_OP_RETURN ('*', false, false); } +"/" { LEXER_DEBUG ("/"); BIN_OP_RETURN ('/', false, false); } +"\\" { LEXER_DEBUG ("\\"); BIN_OP_RETURN (LEFTDIV, false, false); } +";" { LEXER_DEBUG (";"); BIN_OP_RETURN (';', true, true); } +"," { LEXER_DEBUG (","); BIN_OP_RETURN (',', true, ! lexer_flags.looking_at_object_index.front ()); } +"^" { LEXER_DEBUG ("^"); BIN_OP_RETURN (POW, false, false); } +"**" { LEXER_DEBUG ("**"); XBIN_OP_RETURN (POW, false, false); } +"=" { LEXER_DEBUG ("="); BIN_OP_RETURN ('=', true, false); } +"&&" { LEXER_DEBUG ("&&"); BIN_OP_RETURN (EXPR_AND_AND, false, false); } +"||" { LEXER_DEBUG ("||"); BIN_OP_RETURN (EXPR_OR_OR, false, false); } +"<<" { LEXER_DEBUG ("<<"); XBIN_OP_RETURN (LSHIFT, false, false); } +">>" { LEXER_DEBUG (">>"); XBIN_OP_RETURN (RSHIFT, false, false); } + {NOT} { LEXER_DEBUG ("{NOT}"); if (yytext[0] == '~') - BIN_OP_RETURN (EXPR_NOT, false); + BIN_OP_RETURN (EXPR_NOT, false, false); else - XBIN_OP_RETURN (EXPR_NOT, false); + XBIN_OP_RETURN (EXPR_NOT, false, false); } "(" { @@ -887,6 +912,7 @@ lexer_flags.looking_at_indirect_ref = false; lexer_flags.looking_for_object_index = false; + lexer_flags.at_beginning_of_statement = false; nesting_level.paren (); promptflag--; @@ -905,6 +931,7 @@ lexer_flags.quote_is_transpose = true; lexer_flags.convert_spaces_to_comma = nesting_level.is_bracket_or_brace (); lexer_flags.looking_for_object_index = true; + lexer_flags.at_beginning_of_statement = false; do_comma_insert_check (); @@ -915,26 +942,27 @@ LEXER_DEBUG ("."); lexer_flags.looking_for_object_index = false; + lexer_flags.at_beginning_of_statement = false; TOK_RETURN ('.'); } -"+=" { LEXER_DEBUG ("+="); XBIN_OP_RETURN (ADD_EQ, false); } -"-=" { LEXER_DEBUG ("-="); XBIN_OP_RETURN (SUB_EQ, false); } -"*=" { LEXER_DEBUG ("*="); XBIN_OP_RETURN (MUL_EQ, false); } -"/=" { LEXER_DEBUG ("/="); XBIN_OP_RETURN (DIV_EQ, false); } -"\\=" { LEXER_DEBUG ("\\="); XBIN_OP_RETURN (LEFTDIV_EQ, false); } -".+=" { LEXER_DEBUG (".+="); XBIN_OP_RETURN (ADD_EQ, false); } -".-=" { LEXER_DEBUG (".-="); XBIN_OP_RETURN (SUB_EQ, false); } -".*=" { LEXER_DEBUG (".*="); XBIN_OP_RETURN (EMUL_EQ, false); } -"./=" { LEXER_DEBUG ("./="); XBIN_OP_RETURN (EDIV_EQ, false); } -".\\=" { LEXER_DEBUG (".\\="); XBIN_OP_RETURN (ELEFTDIV_EQ, false); } -{POW}= { LEXER_DEBUG ("{POW}="); XBIN_OP_RETURN (POW_EQ, false); } -{EPOW}= { LEXER_DEBUG ("{EPOW}="); XBIN_OP_RETURN (EPOW_EQ, false); } -"&=" { LEXER_DEBUG ("&="); XBIN_OP_RETURN (AND_EQ, false); } -"|=" { LEXER_DEBUG ("|="); XBIN_OP_RETURN (OR_EQ, false); } -"<<=" { LEXER_DEBUG ("<<="); XBIN_OP_RETURN (LSHIFT_EQ, false); } -">>=" { LEXER_DEBUG (">>="); XBIN_OP_RETURN (RSHIFT_EQ, false); } +"+=" { LEXER_DEBUG ("+="); XBIN_OP_RETURN (ADD_EQ, false, false); } +"-=" { LEXER_DEBUG ("-="); XBIN_OP_RETURN (SUB_EQ, false, false); } +"*=" { LEXER_DEBUG ("*="); XBIN_OP_RETURN (MUL_EQ, false, false); } +"/=" { LEXER_DEBUG ("/="); XBIN_OP_RETURN (DIV_EQ, false, false); } +"\\=" { LEXER_DEBUG ("\\="); XBIN_OP_RETURN (LEFTDIV_EQ, false, false); } +".+=" { LEXER_DEBUG (".+="); XBIN_OP_RETURN (ADD_EQ, false, false); } +".-=" { LEXER_DEBUG (".-="); XBIN_OP_RETURN (SUB_EQ, false, false); } +".*=" { LEXER_DEBUG (".*="); XBIN_OP_RETURN (EMUL_EQ, false, false); } +"./=" { LEXER_DEBUG ("./="); XBIN_OP_RETURN (EDIV_EQ, false, false); } +".\\=" { LEXER_DEBUG (".\\="); XBIN_OP_RETURN (ELEFTDIV_EQ, false, false); } +{POW}= { LEXER_DEBUG ("{POW}="); XBIN_OP_RETURN (POW_EQ, false, false); } +{EPOW}= { LEXER_DEBUG ("{EPOW}="); XBIN_OP_RETURN (EPOW_EQ, false, false); } +"&=" { LEXER_DEBUG ("&="); XBIN_OP_RETURN (AND_EQ, false, false); } +"|=" { LEXER_DEBUG ("|="); XBIN_OP_RETURN (OR_EQ, false, false); } +"<<=" { LEXER_DEBUG ("<<="); XBIN_OP_RETURN (LSHIFT_EQ, false, false); } +">>=" { LEXER_DEBUG (">>="); XBIN_OP_RETURN (RSHIFT_EQ, false, false); } \{{S}* { LEXER_DEBUG ("\\{{S}*"); @@ -948,6 +976,7 @@ lexer_flags.quote_is_transpose = false; lexer_flags.convert_spaces_to_comma = true; lexer_flags.looking_for_object_index = false; + lexer_flags.at_beginning_of_statement = false; promptflag--; eat_whitespace (); @@ -963,6 +992,7 @@ lexer_flags.looking_at_object_index.pop_front (); lexer_flags.looking_for_object_index = true; + lexer_flags.at_beginning_of_statement = false; nesting_level.remove (); @@ -1416,18 +1446,21 @@ switch (kw->kw_id) { case break_kw: - case case_kw: case catch_kw: case continue_kw: case else_kw: - case elseif_kw: - case global_kw: case otherwise_kw: case return_kw: + case unwind_protect_cleanup_kw: + lexer_flags.at_beginning_of_statement = true; + break; + + case case_kw: + case elseif_kw: + case global_kw: case static_kw: case until_kw: - case unwind_protect_cleanup_kw: - break; + break; case end_kw: if (inside_any_object_index () @@ -1442,24 +1475,28 @@ else { yylval.tok_val = new token (token::simple_end, l, c); + lexer_flags.at_beginning_of_statement = true; end_tokens_expected--; } } break; case end_try_catch_kw: + yylval.tok_val = new token (token::try_catch_end, l, c); + lexer_flags.at_beginning_of_statement = true; end_tokens_expected--; - yylval.tok_val = new token (token::try_catch_end, l, c); break; case end_unwind_protect_kw: + yylval.tok_val = new token (token::unwind_protect_end, l, c); + lexer_flags.at_beginning_of_statement = true; end_tokens_expected--; - yylval.tok_val = new token (token::unwind_protect_end, l, c); break; case endfor_kw: + yylval.tok_val = new token (token::for_end, l, c); + lexer_flags.at_beginning_of_statement = true; end_tokens_expected--; - yylval.tok_val = new token (token::for_end, l, c); break; case endfunction_kw: @@ -1469,40 +1506,52 @@ else { yylval.tok_val = new token (token::function_end, l, c); + lexer_flags.at_beginning_of_statement = true; end_tokens_expected--; } } break; case endif_kw: + yylval.tok_val = new token (token::if_end, l, c); + lexer_flags.at_beginning_of_statement = true; end_tokens_expected--; - yylval.tok_val = new token (token::if_end, l, c); break; case endswitch_kw: + yylval.tok_val = new token (token::switch_end, l, c); + lexer_flags.at_beginning_of_statement = true; end_tokens_expected--; - yylval.tok_val = new token (token::switch_end, l, c); break; case endwhile_kw: + yylval.tok_val = new token (token::while_end, l, c); + lexer_flags.at_beginning_of_statement = true; end_tokens_expected--; - yylval.tok_val = new token (token::while_end, l, c); break; case for_kw: case while_kw: end_tokens_expected++; - // Fall through... + promptflag--; + lexer_flags.looping++; + break; case do_kw: + lexer_flags.at_beginning_of_statement = true; promptflag--; lexer_flags.looping++; break; + case try_kw: + case unwind_protect_kw: + lexer_flags.at_beginning_of_statement = true; + end_tokens_expected++; + promptflag--; + break; + case if_kw: - case try_kw: case switch_kw: - case unwind_protect_kw: end_tokens_expected++; promptflag--; break; @@ -1520,6 +1569,8 @@ yylval.tok_val = new token (token::function_end, l, c); token_stack.push (yylval.tok_val); + lexer_flags.at_beginning_of_statement = true; + return END; } else @@ -1888,15 +1939,13 @@ current_input_column = 1; lexer_flags.quote_is_transpose = false; lexer_flags.convert_spaces_to_comma = true; + lexer_flags.at_beginning_of_statement = true; if (YY_START == COMMAND_START) BEGIN (INITIAL); if (nesting_level.none ()) - { - lexer_flags.doing_rawcommand = false; - return '\n'; - } + return '\n'; else if (nesting_level.is_bracket_or_brace ()) return ';'; else @@ -2332,6 +2381,7 @@ lexer_flags.quote_is_transpose = true; lexer_flags.convert_spaces_to_comma = true; lexer_flags.looking_for_object_index = true; + lexer_flags.at_beginning_of_statement = false; yylval.tok_val = new token (value, yytext, input_line_number, current_input_column); @@ -2485,7 +2535,7 @@ } static int -handle_string (char delim, int text_style) +handle_string (char delim) { std::ostringstream buf; @@ -2538,26 +2588,19 @@ if (c == delim) { buf << static_cast (c); - if (lexer_flags.doing_rawcommand) - buf << static_cast (c); } else { std::string s; xunput (c, yytext); - if (lexer_flags.doing_rawcommand || delim == '\'') + if (delim == '\'') s = buf.str (); else s = do_string_escapes (buf.str ()); - if (text_style && lexer_flags.doing_rawcommand) - s = std::string (1, delim) + s + std::string (1, delim); - else - { - lexer_flags.quote_is_transpose = true; - lexer_flags.convert_spaces_to_comma = true; - } + lexer_flags.quote_is_transpose = true; + lexer_flags.convert_spaces_to_comma = true; yylval.tok_val = new token (s, bos_line, bos_col); token_stack.push (yylval.tok_val); @@ -2568,6 +2611,7 @@ gripe_single_quote_string (); lexer_flags.looking_for_object_index = true; + lexer_flags.at_beginning_of_statement = false; return delim == '"' ? DQ_STRING : SQ_STRING; } @@ -2781,6 +2825,257 @@ } } +static bool +next_token_can_follow_bin_op (void) +{ + std::stack buf; + + int c = EOF; + + // Skip whitespace in current statement on current line + while (true) + { + c = text_yyinput (); + + if (! match_any (c, ",;\n") && (c == ' ' || c == '\t')) + buf.push (c); + else + break; + } + + // Restore input. + while (! buf.empty ()) + { + xunput (buf.top (), yytext); + + buf.pop (); + } + + return (isalnum (c) || match_any (c, "!\"'(-[_{~")); +} + +static bool +looks_like_command_arg (void) +{ + bool retval = true; + + int c0 = text_yyinput (); + + switch (c0) + { + // = == + case '=': + { + int c1 = text_yyinput (); + + if (c1 == '=') + { + int c2 = text_yyinput (); + + if (! match_any (c2, ",;\n") && (c2 == ' ' || c2 == '\t') + && next_token_can_follow_bin_op ()) + retval = false; + + xunput (c2, yytext); + } + else + retval = false; + + xunput (c1, yytext); + } + break; + + case '(': + case '{': + // Indexing. + retval = false; + break; + + case '\n': + // EOL. + break; + + case '\'': + case '"': + // Beginning of a character string. + break; + + // + - ++ -- += -= + case '+': + case '-': + { + int c1 = text_yyinput (); + + switch (c1) + { + case '\n': + // EOL. + case '+': + case '-': + // Unary ops, spacing doesn't matter. + break; + + case '\t': + case ' ': + { + if (next_token_can_follow_bin_op ()) + retval = false; + } + break; + + case '=': + { + int c2 = text_yyinput (); + + if (! match_any (c2, ",;\n") && (c2 == ' ' || c2 == '\t') + && next_token_can_follow_bin_op ()) + retval = false; + + xunput (c2, yytext); + } + break; + } + + xunput (c1, yytext); + } + break; + + case ':': + case '/': + case '\\': + case '^': + { + int c1 = text_yyinput (); + + if (! match_any (c1, ",;\n") && (c1 == ' ' || c1 == '\t') + && next_token_can_follow_bin_op ()) + retval = false; + + xunput (c1, yytext); + } + break; + + // .+ .- ./ .\ .^ .* .** + case '.': + { + int c1 = text_yyinput (); + + if (match_any (c1, "+-/\\^*")) + { + int c2 = text_yyinput (); + + if (c2 == '=') + { + int c3 = text_yyinput (); + + if (! match_any (c3, ",;\n") && (c3 == ' ' || c3 == '\t') + && next_token_can_follow_bin_op ()) + retval = false; + + xunput (c3, yytext); + } + else if (! match_any (c2, ",;\n") && (c2 == ' ' || c2 == '\t') + && next_token_can_follow_bin_op ()) + retval = false; + + xunput (c2, yytext); + } + else if (! match_any (c1, ",;\n") + && (! isdigit (c1) && c1 != ' ' && c1 != '\t' + && c1 != '.')) + { + // Structure reference. FIXME -- is this a complete check? + + retval = false; + } + + xunput (c1, yytext); + } + break; + + // & && | || * ** + case '&': + case '|': + case '*': + { + int c1 = text_yyinput (); + + if (c1 == c0) + { + int c2 = text_yyinput (); + + if (! match_any (c2, ",;\n") && (c2 == ' ' || c2 == '\t') + && next_token_can_follow_bin_op ()) + retval = false; + + xunput (c2, yytext); + } + else if (! match_any (c1, ",;\n") && (c1 == ' ' || c1 == '\t') + && next_token_can_follow_bin_op ()) + retval = false; + + xunput (c1, yytext); + } + break; + + // < <= > >= + case '<': + case '>': + { + int c1 = text_yyinput (); + + if (c1 == '=') + { + int c2 = text_yyinput (); + + if (! match_any (c2, ",;\n") && (c2 == ' ' || c2 == '\t') + && next_token_can_follow_bin_op ()) + retval = false; + + xunput (c2, yytext); + } + else if (! match_any (c1, ",;\n") && (c1 == ' ' || c1 == '\t') + && next_token_can_follow_bin_op ()) + retval = false; + + xunput (c1, yytext); + } + break; + + // ~= != + case '~': + case '!': + { + int c1 = text_yyinput (); + + // ~ and ! can be unary ops, so require following =. + if (c1 == '=') + { + int c2 = text_yyinput (); + + if (! match_any (c2, ",;\n") && (c2 == ' ' || c2 == '\t') + && next_token_can_follow_bin_op ()) + retval = false; + + xunput (c2, yytext); + } + else if (! match_any (c1, ",;\n") && (c1 == ' ' || c1 == '\t') + && next_token_can_follow_bin_op ()) + retval = false; + + xunput (c1, yytext); + } + break; + + default: + break; + } + + xunput (c0, yytext); + + return retval; +} + // Figure out exactly what kind of token to return when we have seen // an identifier. Handles keywords. Return -1 if the identifier // should be ignored. @@ -2788,6 +3083,8 @@ static int handle_identifier (void) { + bool at_bos = lexer_flags.at_beginning_of_statement; + std::string tok = strip_trailing_whitespace (yytext); int c = yytext[yyleng-1]; @@ -2820,8 +3117,19 @@ return STRUCT_ELT; } + lexer_flags.at_beginning_of_statement = false; + + // The is_keyword_token may reset + // lexer_flags.at_beginning_of_statement. For example, if it sees + // an else token, then the next token is at the beginning of a + // statement. + int kw_token = is_keyword_token (tok); + // If we found a keyword token, then the beginning_of_statement flag + // is already set. Otherwise, we won't be at the beginning of a + // statement. + if (lexer_flags.looking_at_function_handle) { if (kw_token) @@ -2864,8 +3172,6 @@ int c1 = text_yyinput (); - bool next_tok_is_paren = (c1 == '('); - bool next_tok_is_eq = false; if (c1 == '=') { @@ -2888,13 +3194,17 @@ // something like [ab,cd] = foo (), force the symbol to be inserted // as a variable in the current symbol table. - if (is_command_name (tok) && ! is_variable (tok)) + if (! is_variable (tok)) { - if (next_tok_is_eq - || lexer_flags.looking_at_decl_list - || lexer_flags.looking_at_return_list - || (lexer_flags.looking_at_parameter_list - && ! lexer_flags.looking_at_initializer_expression)) + if (at_bos && spc_gobbled && looks_like_command_arg ()) + { + BEGIN (COMMAND_START); + } + else if (next_tok_is_eq + || lexer_flags.looking_at_decl_list + || lexer_flags.looking_at_return_list + || (lexer_flags.looking_at_parameter_list + && ! lexer_flags.looking_at_initializer_expression)) { force_local_variable (tok); } @@ -2902,18 +3212,6 @@ { lexer_flags.pending_local_variables.insert (tok); } - else if (! (next_tok_is_paren - || lexer_flags.looking_at_object_index.front ())) - { - BEGIN (COMMAND_START); - } - - if (is_rawcommand_name (tok) - && ! lexer_flags.looking_at_object_index.front ()) - { - lexer_flags.doing_rawcommand = true; - BEGIN (COMMAND_START); - } } // Find the token in the symbol table. Beware the magic @@ -2932,7 +3230,7 @@ lexer_flags.convert_spaces_to_comma = true; - if (! next_tok_is_eq) + if (! (next_tok_is_eq || YY_START == COMMAND_START)) { lexer_flags.quote_is_transpose = true; @@ -2988,14 +3286,14 @@ // Object index not possible until we've seen something. looking_for_object_index = false; + // Yes, we are at the beginning of a statement. + at_beginning_of_statement = true; + // No need to do comma insert or convert spaces to comma at // beginning of input. convert_spaces_to_comma = true; do_comma_insert = false; - // Not initially doing any plotting or setting of plot attributes. - doing_rawcommand = false; - // Not initially looking at indirect references. looking_at_indirect_ref = false; @@ -3012,7 +3310,7 @@ return octave_kw_hash::in_word_set (s.c_str (), s.length ()) != 0; } -DEFCMD (iskeyword, args, , +DEFUN (iskeyword, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} iskeyword (@var{name})\n\ Return true if @var{name} is an Octave keyword. If @var{name}\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/load-path.cc --- a/src/load-path.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/load-path.cc Sun Feb 15 23:49:15 2009 -0500 @@ -1897,7 +1897,7 @@ return retval; } -DEFCMD (addpath, args, nargout, +DEFUN (addpath, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} addpath (@var{dir1}, @dots{})\n\ @deftypefnx {Built-in Function} {} addpath (@var{dir1}, @dots{}, @var{option})\n\ @@ -1993,7 +1993,7 @@ return retval; } -DEFCMD (rmpath, args, nargout, +DEFUN (rmpath, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} rmpath (@var{dir1}, @dots{})\n\ Remove @var{dir1}, @dots{} from the current function search path.\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/load-save.cc --- a/src/load-save.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/load-save.cc Sun Feb 15 23:49:15 2009 -0500 @@ -542,7 +542,7 @@ not linked with the HDF5 library." #endif /* ! HAVE HDF5 */ -DEFCMD (load, args, nargout, +DEFUN (load, args, nargout, "-*- texinfo -*-\n\ @deffn {Command} load options file v1 v2 @dots{}\n\ Load the named variables @var{v1}, @var{v2}, @dots{}, from the file\n\ @@ -1446,7 +1446,7 @@ the zlib library." #endif /* ! HAVE ZLIB */ -DEFCMD (save, args, , +DEFUN (save, args, , "-*- texinfo -*-\n\ @deffn {Command} save options file @var{v1} @var{v2} @dots{}\n\ @deffnx {Command} save options file -struct @var{STR} @var{f1} @var{f2} @dots{}\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/mkbuiltins --- a/src/mkbuiltins Sun Feb 15 16:31:16 2009 -0500 +++ b/src/mkbuiltins Sun Feb 15 23:49:15 2009 -0500 @@ -51,35 +51,31 @@ #if defined (ENABLE_DYNAMIC_LINKING) -#define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) +#define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) -#define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, \ - is_text_fcn, doc) +#define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) #else -#define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ - XDEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) +#define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) \ + XDEFUN_INTERNAL(name, args_name, nargout_name, doc) -#define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, \ - is_text_fcn, doc) \ - XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, is_text_fcn, doc) +#define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) \ + XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) #endif -#define XDEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ +#define XDEFUN_INTERNAL(name, args_name, nargout_name, doc) \ extern DECLARE_FUN (name, args_name, nargout_name); \ - install_builtin_function (F ## name, #name, doc, is_text_fcn); \ + install_builtin_function (F ## name, #name, doc); \ -#define XDEFCONSTFUN_INTERNAL(name, args_name, nargout_name, \ - is_text_fcn, doc) \ +#define XDEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \ extern DECLARE_FUN (name, args_name, nargout_name); \ - install_builtin_function (F ## name, #name, doc, is_text_fcn, false); \ + install_builtin_function (F ## name, #name, doc, false); \ -#define XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, \ - is_text_fcn, doc) \ +#define XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \ extern DECLARE_FUNX (fname, args_name, nargout_name); \ - install_builtin_function (fname, name, doc, is_text_fcn); \ + install_builtin_function (fname, name, doc); \ #define XDEFALIAS_INTERNAL(alias, name) \ alias_builtin (#alias, #name); diff -r 6dc61981d18b -r 5dd06f19e9be src/mkgendoc --- a/src/mkgendoc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/mkgendoc Sun Feb 15 23:49:15 2009 -0500 @@ -42,22 +42,19 @@ #include #include -#define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ +#define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) \ print_doc_string (#name, doc); -#define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, \ - is_text_fcn, doc) \ +#define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) \ print_doc_string (name, doc); -#define XDEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \ +#define XDEFUN_INTERNAL(name, args_name, nargout_name, doc) \ print_doc_string (#name, doc); -#define XDEFCONSTFUN_INTERNAL(name, args_name, nargout_name, \ - is_text_fcn, doc) \ +#define XDEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \ print_doc_string (#name, doc); -#define XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, \ - is_text_fcn, doc) \ +#define XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \ print_doc_string (name, doc); #define XDEFALIAS_INTERNAL(alias, name) diff -r 6dc61981d18b -r 5dd06f19e9be src/oct-hist.cc --- a/src/oct-hist.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/oct-hist.cc Sun Feb 15 23:49:15 2009 -0500 @@ -549,7 +549,7 @@ command_history::add (timestamp); } -DEFCMD (edit_history, args, , +DEFUN (edit_history, args, , "-*- texinfo -*-\n\ @deffn {Command} edit_history options\n\ If invoked with no arguments, @code{edit_history} allows you to edit the\n\ @@ -599,7 +599,7 @@ return retval; } -DEFCMD (history, args, , +DEFUN (history, args, , "-*- texinfo -*-\n\ @deffn {Command} history options\n\ If invoked with no arguments, @code{history} displays a list of commands\n\ @@ -642,7 +642,7 @@ return retval; } -DEFCMD (run_history, args, , +DEFUN (run_history, args, , "-*- texinfo -*-\n\ @deffn {Command} run_history [first] [last]\n\ Similar to @code{edit_history}, except that the editor is not invoked,\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/ov-class.cc --- a/src/ov-class.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/ov-class.cc Sun Feb 15 23:49:15 2009 -0500 @@ -1266,7 +1266,7 @@ return retval; } -DEFCMD (methods, args, nargout, +DEFUN (methods, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} methods (@var{x})\n\ @deftypefnx {Built-in Function} {} methods (\"classname\")\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/pager.cc --- a/src/pager.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/pager.cc Sun Feb 15 23:49:15 2009 -0500 @@ -418,7 +418,7 @@ error ("diary: can't open diary file `%s'", diary_file.c_str ()); } -DEFCMD (diary, args, , +DEFUN (diary, args, , "-*- texinfo -*-\n\ @deffn {Command} diary options\n\ Create a list of all commands @emph{and} the output they produce, mixed\n\ @@ -489,7 +489,7 @@ return retval; } -DEFCMD (more, args, , +DEFUN (more, args, , "-*- texinfo -*-\n\ @deffn {Command} more\n\ @deffnx {Command} more on\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/parse.y --- a/src/parse.y Sun Feb 15 16:31:16 2009 -0500 +++ b/src/parse.y Sun Feb 15 23:49:15 2009 -0500 @@ -1,7 +1,7 @@ /* Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006, 2007, 2008 John W. Eaton + 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 John W. Eaton This file is part of Octave. @@ -544,6 +544,29 @@ { $$ = make_statement ($1); } | command { $$ = make_statement ($1); } + | word_list_cmd + { $$ = make_statement ($1); } + ; + +// ================= +// Word-list command +// ================= + +// These are not really like expressions since they can't appear on +// the RHS of an assignment. But they are also not like commands (IF, +// WHILE, etc. + +word_list_cmd : identifier word_list + { $$ = make_index_expression ($1, $2, '('); } + ; + +word_list : string + { $$ = new tree_argument_list ($1); } + | word_list string + { + $1->append ($2); + $$ = $1; + } ; // =========== @@ -855,23 +878,8 @@ { $$ = make_assign_op (OR_EQ, $1, $2, $3); } ; -word_list_cmd : identifier word_list - { $$ = make_index_expression ($1, $2, '('); } - ; - -word_list : string - { $$ = new tree_argument_list ($1); } - | word_list string - { - $1->append ($2); - $$ = $1; - } - ; - expression : simple_expr { $$ = $1; } - | word_list_cmd - { $$ = $1; } | assign_expr { $$ = $1; } | anon_fcn_handle @@ -3376,7 +3384,7 @@ return retval; } -DEFCMD (autoload, args, , +DEFUN (autoload, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} autoload (@var{function}, @var{file})\n\ Define @var{function} to autoload from @var{file}.\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/pr-output.cc --- a/src/pr-output.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/pr-output.cc Sun Feb 15 23:49:15 2009 -0500 @@ -3398,7 +3398,7 @@ } } -DEFCMD (format, args, , +DEFUN (format, args, , "-*- texinfo -*-\n\ @deffn {Command} format options\n\ Control the format of the output produced by @code{disp} and Octave's\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/sysdep.cc --- a/src/sysdep.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/sysdep.cc Sun Feb 15 23:49:15 2009 -0500 @@ -905,7 +905,7 @@ #if defined (__EMX__) && defined (OS2) -DEFCMD (extproc, , , +DEFUN (extproc, , , "extproc: ignored by Octave") { return octave_value_list (); diff -r 6dc61981d18b -r 5dd06f19e9be src/utils.cc --- a/src/utils.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/utils.cc Sun Feb 15 23:49:15 2009 -0500 @@ -90,7 +90,7 @@ return valid_identifier (s.c_str ()); } -DEFCMD (isvarname, args, , +DEFUN (isvarname, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} isvarname (@var{name})\n\ Return true if @var{name} is a valid variable name\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/variables.cc --- a/src/variables.cc Sun Feb 15 16:31:16 2009 -0500 +++ b/src/variables.cc Sun Feb 15 23:49:15 2009 -0500 @@ -91,278 +91,6 @@ // Attributes of variables and functions. -// Is this a command-style function? - -static std::set command_set; - -void -mark_as_command (const std::string& s) -{ - command_set.insert (s); -} - -static inline void -unmark_command (const std::string& s) -{ - command_set.erase (s); -} - -DEFCMD (mark_as_command, args, , - "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} mark_as_command (@var{name})\n\ -Enter @var{name} into the list of commands.\n\ -@seealso{unmark_command, iscommand}\n\ -@end deftypefn") -{ - octave_value_list retval; - - if (symbol_table::at_top_level ()) - { - int nargin = args.length (); - - if (nargin > 0) - { - int argc = nargin + 1; - - string_vector argv = args.make_argv ("mark_as_command"); - - if (! error_state) - { - for (int i = 1; i < argc; i++) - mark_as_command (argv[i]); - } - } - else - print_usage (); - } - else - warning ("mark_as_command: invalid use inside function body"); - - return retval; -} - -DEFCMD (unmark_command, args, , - "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} unmark_command (@var{name})\n\ -Remove @var{name} from the list of commands.\n\ -@seealso{mark_as_command, iscommand}\n\ -@end deftypefn") -{ - octave_value_list retval; - - if (symbol_table::at_top_level ()) - { - int nargin = args.length (); - - if (nargin > 0) - { - int argc = nargin + 1; - - string_vector argv = args.make_argv ("unmark_command"); - - if (! error_state) - { - for (int i = 1; i < argc; i++) - unmark_command (argv[i]); - } - } - else - print_usage (); - } - else - warning ("mark_as_command: invalid use inside function body"); - - return retval; -} - -bool -is_command_name (const std::string& s) -{ - return command_set.find (s) != command_set.end (); -} - - -DEFCMD (iscommand, args, , -"-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} iscommand (@var{name})\n\ -Return true if @var{name} is a command style function. If @var{name}\n\ -is omitted, return a list of identifiers which are marked as commands with\n\ -@code{mark_as_command}.\n\ -@seealso{mark_as_command, unmark_command}\n\ -@end deftypefn") -{ - octave_value retval; - - int nargin = args.length (); - - if (nargin == 0) - { - string_vector lst (command_set.size ()); - - int i = 0; - for (std::set::const_iterator p = command_set.begin (); - p != command_set.end (); p++) - lst[i++] = *p; - - retval = Cell (lst.sort ()); - } - else if (nargin == 1) - { - string_vector argv = args.make_argv ("iscommand"); - - if (! error_state) - { - std::string s = argv[1]; - retval = is_command_name(s); - } - } - else - print_usage (); - - return retval; -} - -// Is this a raw input command? - -static std::set rawcommand_set; - -void -mark_as_rawcommand (const std::string& s) -{ - command_set.insert (s); - rawcommand_set.insert (s); -} - -void -unmark_rawcommand (const std::string& s) -{ - rawcommand_set.erase (s); -} - -DEFCMD (mark_as_rawcommand, args, , -"-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} mark_as_rawcommand (@var{name})\n\ -Enter @var{name} into the list of raw input commands and to the list of\n\ -command style functions.\n\ -Raw input commands are like normal command style functions, but they\n\ -receive their input unprocessed (ie. strings still contain the quotes\n\ -and escapes they had when input). However, comments and continuations\n\ -are handled as usual, you cannot pass a token starting with a comment\n\ -character ('#' or '%') to your function, and the last token cannot be\n\ -a continuation token ('\\' or '...').\n\ -@seealso{unmark_rawcommand, israwcommand, iscommand, mark_as_command}\n\ -@end deftypefn") -{ - octave_value_list retval; - - if (symbol_table::at_top_level ()) - { - int nargin = args.length (); - - if (nargin > 0) - { - int argc = nargin + 1; - - string_vector argv = args.make_argv ("mark_as_rawcommand"); - - if (! error_state) - { - for (int i = 1; i < argc; i++) - mark_as_rawcommand (argv[i]); - } - } - else - print_usage (); - } - else - warning ("mark_as_rawcommand: invalid use inside function body"); - - return retval; -} - -DEFCMD (unmark_rawcommand, args, , - "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} unmark_rawcommand (@var{name})\n\ -Remove @var{name} from the list of raw input commands.\n\ -Note that this does not remove @var{name} from the list of command style\n\ -functions.\n\ -@seealso{mark_as_rawcommand, israwcommand, iscommand, unmark_command}\n\ -@end deftypefn") -{ - octave_value_list retval; - - if (symbol_table::at_top_level ()) - { - int nargin = args.length (); - - if (nargin > 0) - { - int argc = nargin + 1; - - string_vector argv = args.make_argv ("unmark_rawcommand"); - - if (! error_state) - { - for (int i = 1; i < argc; i++) - unmark_rawcommand (argv[i]); - } - } - else - print_usage (); - } - else - warning ("unmark_rawcommand: invalid use inside function body"); - - return retval; -} - -bool -is_rawcommand_name (const std::string& s) -{ - return rawcommand_set.find (s) != rawcommand_set.end (); -} - -DEFCMD (israwcommand, args, , - "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} israwcommand (@var{name})\n\ -Return true if @var{name} is a raw input command function.\n\ -If @var{name} is omitted, return a list of identifiers which are marked as\n\ -raw input commands with mark_as_rawcommand.\n\ -@seealso{mark_as_rawcommand, unmark_rawcommand}\n\ -@end deftypefn") -{ - octave_value retval; - - int nargin = args.length (); - - if (nargin == 0) - { - string_vector lst (rawcommand_set.size()); - - int i = 0; - for (std::set::const_iterator p = rawcommand_set.begin (); - p != rawcommand_set.end (); - p++) - lst[i++] = *p; - - retval = Cell (lst.sort ()); - } - else if (nargin == 1) - { - string_vector argv = args.make_argv ("israwcommand"); - - if (! error_state) - { - std::string s = argv[1]; - retval = is_rawcommand_name(s); - } - } - else - print_usage (); - - return retval; -} - // Is this octave_value a valid function? octave_function * @@ -1823,7 +1551,7 @@ return retval; } -DEFCMD (who, args, nargout, +DEFUN (who, args, nargout, "-*- texinfo -*-\n\ @deffn {Command} who options pattern @dots{}\n\ @deffnx {Command} whos options pattern @dots{}\n\ @@ -1869,7 +1597,7 @@ return retval; } -DEFCMD (whos, args, nargout, +DEFUN (whos, args, nargout, "-*- texinfo -*-\n\ @deffn {Command} whos options pattern @dots{}\n\ See who.\n\ @@ -1971,7 +1699,7 @@ return retval; } -DEFCMD (mlock, args, , +DEFUN (mlock, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} mlock ()\n\ Lock the current function into memory so that it can't be cleared.\n\ @@ -1995,7 +1723,7 @@ return retval; } -DEFCMD (munlock, args, , +DEFUN (munlock, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} munlock (@var{fcn})\n\ Unlock the named function. If no function is named\n\ @@ -2030,7 +1758,7 @@ } -DEFCMD (mislocked, args, , +DEFUN (mislocked, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} mislocked (@var{fcn})\n\ Return true if the named function is locked. If no function is named\n\ @@ -2282,7 +2010,7 @@ } \ while (0) -DEFCMD (clear, args, , +DEFUN (clear, args, , "-*- texinfo -*-\n\ @deffn {Command} clear [options] pattern @dots{}\n\ Delete the names matching the given patterns from the symbol table. The\n\ diff -r 6dc61981d18b -r 5dd06f19e9be src/variables.h --- a/src/variables.h Sun Feb 15 16:31:16 2009 -0500 +++ b/src/variables.h Sun Feb 15 23:49:15 2009 -0500 @@ -44,16 +44,6 @@ extern OCTINTERP_API void clear_mex_functions (void); -extern OCTINTERP_API void mark_as_command (const std::string&); -extern OCTINTERP_API bool is_command_name (const std::string&); - -// The next three are here temporarily... -extern OCTINTERP_API bool is_marked_as_rawcommand (const std::string& s); -extern OCTINTERP_API void mark_as_rawcommand (const std::string& s); -extern OCTINTERP_API void unmark_rawcommand (const std::string& s); - -extern OCTINTERP_API bool is_rawcommand_name (const std::string&); - extern OCTINTERP_API octave_function * is_valid_function (const octave_value&, const std::string& = std::string (), bool warn = false); diff -r 6dc61981d18b -r 5dd06f19e9be test/ChangeLog --- a/test/ChangeLog Sun Feb 15 16:31:16 2009 -0500 +++ b/test/ChangeLog Sun Feb 15 23:49:15 2009 -0500 @@ -1,3 +1,8 @@ +2009-02-15 John W. Eaton + + * test_io.m, test_prefer.m: Avoid command-style function call + syntax when assigning results. + 2009-02-09 John W. Eaton * fntests.m (hastests): Error if fopen fails. diff -r 6dc61981d18b -r 5dd06f19e9be test/test_io.m --- a/test/test_io.m Sun Feb 15 16:31:16 2009 -0500 +++ b/test/test_io.m Sun Feb 15 23:49:15 2009 -0500 @@ -196,7 +196,7 @@ %! STR.struct_fld.y = 1; %! %! save struct.dat -struct STR; -%! STR = load struct.dat ; +%! STR = load ("struct.dat"); %! %! assert(STR.scalar_fld == 1 && ... %! STR.matrix_fld == [1.1,2;3,4] && ... @@ -206,7 +206,7 @@ %! %! %! save -binary struct.dat -struct STR matrix_fld str*_fld; -%! STR = load struct.dat ; +%! STR = load ("struct.dat"); %! %! assert(!isfield(STR,"scalar_fld") && ... %! STR.matrix_fld == [1.1,2;3,4] && ... diff -r 6dc61981d18b -r 5dd06f19e9be test/test_prefer.m --- a/test/test_prefer.m Sun Feb 15 16:31:16 2009 -0500 +++ b/test/test_prefer.m Sun Feb 15 23:49:15 2009 -0500 @@ -134,7 +134,7 @@ %! ped = print_empty_dimensions (); %! print_empty_dimensions (0); %! a = cell (1, 1); -%! b = type -q a; +%! b = type ("-q", "a"); %! assert (!isempty (findstr (b{1}, "[]"))); %! assert (isempty (findstr (b{1} ,"[](0x0)"))); %! print_empty_dimensions (ped); @@ -144,7 +144,7 @@ %! ped = print_empty_dimensions (); %! print_empty_dimensions (1); %! a = cell (1, 1); -%! b = type -q a; +%! b = type ("-q", "a"); %! assert (!isempty (findstr (b{1}, "[](0x0)"))); %! print_empty_dimensions (ped);