Mercurial > octave
annotate libinterp/parse-tree/oct-parse.in.yy @ 22755:3a2b891d0b33
maint: Standardize Copyright formatting.
* Makefile.am, README, build-aux/check-subst-vars.in.sh,
build-aux/find-files-with-tests.sh, build-aux/mk-builtins.sh,
build-aux/mk-default-qt-settings.in.sh, build-aux/mk-f77-def.in.sh,
build-aux/mk-hg-id.sh, build-aux/mk-mxarray-h.in.sh,
build-aux/mk-octave-config-h.sh, build-aux/mk-opts.pl,
build-aux/mk-version-h.in.sh, build-aux/subst-config-vals.in.sh,
build-aux/subst-cross-config-vals.in.sh, build-aux/subst-default-vals.in.sh,
build-aux/subst-f77-isnan-macro.in.sh, build-aux/subst-script-vals.in.sh,
configure.ac, doc/interpreter/arith.txi, doc/interpreter/audio.txi,
doc/interpreter/basics.txi, doc/interpreter/bugs.txi,
doc/interpreter/container.txi, doc/interpreter/cp-idx.txi,
doc/interpreter/data.txi, doc/interpreter/debug.txi,
doc/interpreter/diagperm.txi, doc/interpreter/diffeq.txi,
doc/interpreter/errors.txi, doc/interpreter/eval.txi, doc/interpreter/expr.txi,
doc/interpreter/external.txi, doc/interpreter/fn-idx.txi,
doc/interpreter/func.txi, doc/interpreter/genpropdoc.m,
doc/interpreter/geometry.txi, doc/interpreter/geometryimages.m,
doc/interpreter/grammar.txi, doc/interpreter/gui.txi,
doc/interpreter/image.txi, doc/interpreter/install.txi,
doc/interpreter/interp.txi, doc/interpreter/interpimages.m,
doc/interpreter/intro.txi, doc/interpreter/io.txi, doc/interpreter/linalg.txi,
doc/interpreter/macros.texi, doc/interpreter/matrix.txi,
doc/interpreter/mk-doc-cache.pl, doc/interpreter/mkoctfile.1,
doc/interpreter/nonlin.txi, doc/interpreter/numbers.txi,
doc/interpreter/obsolete.txi, doc/interpreter/octave-cli.1,
doc/interpreter/octave-config.1, doc/interpreter/octave.1,
doc/interpreter/octave.css, doc/interpreter/octave.texi,
doc/interpreter/oop.txi, doc/interpreter/op-idx.txi, doc/interpreter/optim.txi,
doc/interpreter/package.txi, doc/interpreter/plot.txi,
doc/interpreter/plotimages.m, doc/interpreter/poly.txi,
doc/interpreter/preface.txi, doc/interpreter/quad.txi, doc/interpreter/set.txi,
doc/interpreter/signal.txi, doc/interpreter/sparse.txi,
doc/interpreter/sparseimages.m, doc/interpreter/splineimages.m,
doc/interpreter/stats.txi, doc/interpreter/stmt.txi,
doc/interpreter/strings.txi, doc/interpreter/system.txi,
doc/interpreter/testfun.txi, doc/interpreter/var.txi,
doc/interpreter/vectorize.txi, doc/liboctave/array.texi,
doc/liboctave/bugs.texi, doc/liboctave/cp-idx.texi, doc/liboctave/dae.texi,
doc/liboctave/diffeq.texi, doc/liboctave/error.texi, doc/liboctave/factor.texi,
doc/liboctave/fn-idx.texi, doc/liboctave/gpl.texi, doc/liboctave/install.texi,
doc/liboctave/intro.texi, doc/liboctave/liboctave.texi,
doc/liboctave/matvec.texi, doc/liboctave/nleqn.texi, doc/liboctave/nlfunc.texi,
doc/liboctave/ode.texi, doc/liboctave/optim.texi, doc/liboctave/preface.texi,
doc/liboctave/quad.texi, doc/liboctave/range.texi, doc/refcard/refcard-a4.tex,
doc/refcard/refcard-legal.tex, doc/refcard/refcard-letter.tex,
doc/refcard/refcard.tex, etc/HACKING, etc/icons/octave.appdata.xml.in,
libgui/graphics/Backend.cc, libgui/graphics/Backend.h,
libgui/graphics/BaseControl.cc, libgui/graphics/BaseControl.h,
libgui/graphics/ButtonControl.cc, libgui/graphics/ButtonControl.h,
libgui/graphics/ButtonGroup.cc, libgui/graphics/ButtonGroup.h,
libgui/graphics/Canvas.cc, libgui/graphics/Canvas.h,
libgui/graphics/CheckBoxControl.cc, libgui/graphics/CheckBoxControl.h,
libgui/graphics/Container.cc, libgui/graphics/Container.h,
libgui/graphics/ContextMenu.cc, libgui/graphics/ContextMenu.h,
libgui/graphics/EditControl.cc, libgui/graphics/EditControl.h,
libgui/graphics/Figure.cc, libgui/graphics/Figure.h,
libgui/graphics/FigureWindow.cc, libgui/graphics/FigureWindow.h,
libgui/graphics/GLCanvas.cc, libgui/graphics/GLCanvas.h,
libgui/graphics/GenericEventNotify.h, libgui/graphics/KeyMap.cc,
libgui/graphics/KeyMap.h, libgui/graphics/ListBoxControl.cc,
libgui/graphics/ListBoxControl.h, libgui/graphics/Logger.cc,
libgui/graphics/Logger.h, libgui/graphics/Menu.cc, libgui/graphics/Menu.h,
libgui/graphics/MenuContainer.h, libgui/graphics/MouseModeActionGroup.cc,
libgui/graphics/MouseModeActionGroup.h, libgui/graphics/Object.cc,
libgui/graphics/Object.h, libgui/graphics/ObjectFactory.cc,
libgui/graphics/ObjectFactory.h, libgui/graphics/ObjectProxy.cc,
libgui/graphics/ObjectProxy.h, libgui/graphics/Panel.cc,
libgui/graphics/Panel.h, libgui/graphics/PopupMenuControl.cc,
libgui/graphics/PopupMenuControl.h, libgui/graphics/PushButtonControl.cc,
libgui/graphics/PushButtonControl.h, libgui/graphics/PushTool.cc,
libgui/graphics/PushTool.h, libgui/graphics/QtHandlesUtils.cc,
libgui/graphics/QtHandlesUtils.h, libgui/graphics/RadioButtonControl.cc,
libgui/graphics/RadioButtonControl.h, libgui/graphics/SliderControl.cc,
libgui/graphics/SliderControl.h, libgui/graphics/TextControl.cc,
libgui/graphics/TextControl.h, libgui/graphics/TextEdit.cc,
libgui/graphics/TextEdit.h, libgui/graphics/ToggleButtonControl.cc,
libgui/graphics/ToggleButtonControl.h, libgui/graphics/ToggleTool.cc,
libgui/graphics/ToggleTool.h, libgui/graphics/ToolBar.cc,
libgui/graphics/ToolBar.h, libgui/graphics/ToolBarButton.cc,
libgui/graphics/ToolBarButton.h, libgui/graphics/__init_qt__.cc,
libgui/graphics/__init_qt__.h, libgui/graphics/annotation-dialog.cc,
libgui/graphics/annotation-dialog.h, libgui/graphics/gl-select.cc,
libgui/graphics/gl-select.h, libgui/src/color-picker.cc,
libgui/src/color-picker.h, libgui/src/dialog.cc, libgui/src/dialog.h,
libgui/src/documentation-dock-widget.cc,
libgui/src/documentation-dock-widget.h, libgui/src/files-dock-widget.cc,
libgui/src/files-dock-widget.h, libgui/src/find-files-dialog.cc,
libgui/src/find-files-dialog.h, libgui/src/find-files-model.cc,
libgui/src/find-files-model.h, libgui/src/history-dock-widget.cc,
libgui/src/history-dock-widget.h, libgui/src/liboctgui-build-info.h,
libgui/src/liboctgui-build-info.in.cc,
libgui/src/m-editor/file-editor-interface.h,
libgui/src/m-editor/file-editor-tab.cc, libgui/src/m-editor/file-editor-tab.h,
libgui/src/m-editor/file-editor.cc, libgui/src/m-editor/file-editor.h,
libgui/src/m-editor/find-dialog.cc, libgui/src/m-editor/find-dialog.h,
libgui/src/m-editor/marker.cc, libgui/src/m-editor/marker.h,
libgui/src/m-editor/octave-qscintilla.cc,
libgui/src/m-editor/octave-qscintilla.h,
libgui/src/m-editor/octave-txt-lexer.cc,
libgui/src/m-editor/octave-txt-lexer.h, libgui/src/main-window.cc,
libgui/src/main-window.h, libgui/src/octave-cmd.cc, libgui/src/octave-cmd.h,
libgui/src/octave-dock-widget.cc, libgui/src/octave-dock-widget.h,
libgui/src/octave-gui.cc, libgui/src/octave-gui.h,
libgui/src/octave-interpreter.cc, libgui/src/octave-interpreter.h,
libgui/src/octave-qt-link.cc, libgui/src/octave-qt-link.h,
libgui/src/qtinfo/parser.cc, libgui/src/qtinfo/parser.h,
libgui/src/qtinfo/webinfo.cc, libgui/src/qtinfo/webinfo.h,
libgui/src/resource-manager.cc, libgui/src/resource-manager.h,
libgui/src/settings-dialog.cc, libgui/src/settings-dialog.h,
libgui/src/shortcut-manager.cc, libgui/src/shortcut-manager.h,
libgui/src/terminal-dock-widget.cc, libgui/src/terminal-dock-widget.h,
libgui/src/thread-manager.cc, libgui/src/thread-manager.h,
libgui/src/welcome-wizard.cc, libgui/src/welcome-wizard.h,
libgui/src/workspace-model.cc, libgui/src/workspace-model.h,
libgui/src/workspace-view.cc, libgui/src/workspace-view.h,
libinterp/build-env.h, libinterp/build-env.in.cc, libinterp/builtins.h,
libinterp/corefcn/Cell.cc, libinterp/corefcn/Cell.h,
libinterp/corefcn/__contourc__.cc, libinterp/corefcn/__dsearchn__.cc,
libinterp/corefcn/__ichol__.cc, libinterp/corefcn/__ilu__.cc,
libinterp/corefcn/__lin_interpn__.cc, libinterp/corefcn/__luinc__.cc,
libinterp/corefcn/__magick_read__.cc, libinterp/corefcn/__pchip_deriv__.cc,
libinterp/corefcn/__qp__.cc, libinterp/corefcn/balance.cc,
libinterp/corefcn/base-text-renderer.h, libinterp/corefcn/besselj.cc,
libinterp/corefcn/betainc.cc, libinterp/corefcn/bitfcns.cc,
libinterp/corefcn/bsxfun.cc, libinterp/corefcn/c-file-ptr-stream.cc,
libinterp/corefcn/c-file-ptr-stream.h, libinterp/corefcn/call-stack.cc,
libinterp/corefcn/call-stack.h, libinterp/corefcn/cdisplay.c,
libinterp/corefcn/cdisplay.h, libinterp/corefcn/cellfun.cc,
libinterp/corefcn/coct-hdf5-types.c, libinterp/corefcn/colloc.cc,
libinterp/corefcn/comment-list.cc, libinterp/corefcn/comment-list.h,
libinterp/corefcn/conv2.cc, libinterp/corefcn/daspk.cc,
libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc,
libinterp/corefcn/data.cc, libinterp/corefcn/data.h,
libinterp/corefcn/debug.cc, libinterp/corefcn/debug.h,
libinterp/corefcn/defaults.cc, libinterp/corefcn/defaults.in.h,
libinterp/corefcn/defun-dld.h, libinterp/corefcn/defun-int.h,
libinterp/corefcn/defun.cc, libinterp/corefcn/defun.h,
libinterp/corefcn/det.cc, libinterp/corefcn/dirfns.cc,
libinterp/corefcn/dirfns.h, libinterp/corefcn/display.cc,
libinterp/corefcn/display.h, libinterp/corefcn/dlmread.cc,
libinterp/corefcn/dot.cc, libinterp/corefcn/dynamic-ld.cc,
libinterp/corefcn/dynamic-ld.h, libinterp/corefcn/eig.cc,
libinterp/corefcn/ellipj.cc, libinterp/corefcn/error.cc,
libinterp/corefcn/error.h, libinterp/corefcn/errwarn.cc,
libinterp/corefcn/errwarn.h, libinterp/corefcn/event-queue.cc,
libinterp/corefcn/event-queue.h, libinterp/corefcn/fft.cc,
libinterp/corefcn/fft2.cc, libinterp/corefcn/fftn.cc,
libinterp/corefcn/file-io.cc, libinterp/corefcn/file-io.h,
libinterp/corefcn/filter.cc, libinterp/corefcn/find.cc,
libinterp/corefcn/ft-text-renderer.cc, libinterp/corefcn/ft-text-renderer.h,
libinterp/corefcn/gammainc.cc, libinterp/corefcn/gcd.cc,
libinterp/corefcn/getgrent.cc, libinterp/corefcn/getpwent.cc,
libinterp/corefcn/getrusage.cc, libinterp/corefcn/givens.cc,
libinterp/corefcn/gl-render.cc, libinterp/corefcn/gl-render.h,
libinterp/corefcn/gl2ps-print.cc, libinterp/corefcn/gl2ps-print.h,
libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h,
libinterp/corefcn/gripes.cc, libinterp/corefcn/gripes.h,
libinterp/corefcn/gsvd.cc, libinterp/corefcn/hash.cc,
libinterp/corefcn/help.cc, libinterp/corefcn/help.h, libinterp/corefcn/hess.cc,
libinterp/corefcn/hex2num.cc, libinterp/corefcn/hook-fcn.cc,
libinterp/corefcn/hook-fcn.h, libinterp/corefcn/input.cc,
libinterp/corefcn/input.h, libinterp/corefcn/interpreter.cc,
libinterp/corefcn/interpreter.h, libinterp/corefcn/inv.cc,
libinterp/corefcn/jit-ir.cc, libinterp/corefcn/jit-ir.h,
libinterp/corefcn/jit-typeinfo.cc, libinterp/corefcn/jit-typeinfo.h,
libinterp/corefcn/jit-util.cc, libinterp/corefcn/jit-util.h,
libinterp/corefcn/kron.cc, libinterp/corefcn/load-path.cc,
libinterp/corefcn/load-path.h, libinterp/corefcn/load-save.cc,
libinterp/corefcn/load-save.h, libinterp/corefcn/lookup.cc,
libinterp/corefcn/ls-ascii-helper.cc, libinterp/corefcn/ls-ascii-helper.h,
libinterp/corefcn/ls-hdf5.cc, libinterp/corefcn/ls-hdf5.h,
libinterp/corefcn/ls-mat-ascii.cc, libinterp/corefcn/ls-mat-ascii.h,
libinterp/corefcn/ls-mat4.cc, libinterp/corefcn/ls-mat4.h,
libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/ls-mat5.h,
libinterp/corefcn/ls-oct-binary.cc, libinterp/corefcn/ls-oct-binary.h,
libinterp/corefcn/ls-oct-text.cc, libinterp/corefcn/ls-oct-text.h,
libinterp/corefcn/ls-utils.cc, libinterp/corefcn/ls-utils.h,
libinterp/corefcn/lsode.cc, libinterp/corefcn/lu.cc,
libinterp/corefcn/mappers.cc, libinterp/corefcn/matrix_type.cc,
libinterp/corefcn/max.cc, libinterp/corefcn/mex.cc, libinterp/corefcn/mex.h,
libinterp/corefcn/mexproto.h, libinterp/corefcn/mgorth.cc,
libinterp/corefcn/mxarray.in.h, libinterp/corefcn/nproc.cc,
libinterp/corefcn/oct-errno.h, libinterp/corefcn/oct-errno.in.cc,
libinterp/corefcn/oct-fstrm.cc, libinterp/corefcn/oct-fstrm.h,
libinterp/corefcn/oct-handle.h, libinterp/corefcn/oct-hdf5-types.cc,
libinterp/corefcn/oct-hdf5-types.h, libinterp/corefcn/oct-hdf5.h,
libinterp/corefcn/oct-hist.cc, libinterp/corefcn/oct-hist.h,
libinterp/corefcn/oct-iostrm.cc, libinterp/corefcn/oct-iostrm.h,
libinterp/corefcn/oct-lvalue.cc, libinterp/corefcn/oct-lvalue.h,
libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-map.h,
libinterp/corefcn/oct-obj.h, libinterp/corefcn/oct-opengl.h,
libinterp/corefcn/oct-prcstrm.cc, libinterp/corefcn/oct-prcstrm.h,
libinterp/corefcn/oct-procbuf.cc, libinterp/corefcn/oct-procbuf.h,
libinterp/corefcn/oct-stdstrm.h, libinterp/corefcn/oct-stream.cc,
libinterp/corefcn/oct-stream.h, libinterp/corefcn/oct-strstrm.cc,
libinterp/corefcn/oct-strstrm.h, libinterp/corefcn/oct-tex-lexer.in.ll,
libinterp/corefcn/oct-tex-parser.in.yy, libinterp/corefcn/oct.h,
libinterp/corefcn/octave-default-image.h, libinterp/corefcn/octave-link.cc,
libinterp/corefcn/octave-link.h,
libinterp/corefcn/octave-preserve-stream-state.h,
libinterp/corefcn/ordschur.cc, libinterp/corefcn/pager.cc,
libinterp/corefcn/pager.h, libinterp/corefcn/pinv.cc,
libinterp/corefcn/pr-output.cc, libinterp/corefcn/pr-output.h,
libinterp/corefcn/procstream.cc, libinterp/corefcn/procstream.h,
libinterp/corefcn/profiler.cc, libinterp/corefcn/profiler.h,
libinterp/corefcn/psi.cc, libinterp/corefcn/pt-jit.cc,
libinterp/corefcn/pt-jit.h, libinterp/corefcn/quad.cc,
libinterp/corefcn/quadcc.cc, libinterp/corefcn/qz.cc,
libinterp/corefcn/rand.cc, libinterp/corefcn/rcond.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc,
libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sighandlers.h,
libinterp/corefcn/sparse-xdiv.cc, libinterp/corefcn/sparse-xdiv.h,
libinterp/corefcn/sparse-xpow.cc, libinterp/corefcn/sparse-xpow.h,
libinterp/corefcn/sparse.cc, libinterp/corefcn/spparms.cc,
libinterp/corefcn/sqrtm.cc, libinterp/corefcn/str2double.cc,
libinterp/corefcn/strfind.cc, libinterp/corefcn/strfns.cc,
libinterp/corefcn/sub2ind.cc, libinterp/corefcn/svd.cc,
libinterp/corefcn/sylvester.cc, libinterp/corefcn/symtab.cc,
libinterp/corefcn/symtab.h, libinterp/corefcn/syscalls.cc,
libinterp/corefcn/sysdep.cc, libinterp/corefcn/sysdep.h,
libinterp/corefcn/text-renderer.cc, libinterp/corefcn/text-renderer.h,
libinterp/corefcn/time.cc, libinterp/corefcn/toplev.cc,
libinterp/corefcn/toplev.h, libinterp/corefcn/tril.cc,
libinterp/corefcn/tsearch.cc, libinterp/corefcn/txt-eng.cc,
libinterp/corefcn/txt-eng.h, libinterp/corefcn/typecast.cc,
libinterp/corefcn/urlwrite.cc, libinterp/corefcn/utils.cc,
libinterp/corefcn/utils.h, libinterp/corefcn/variables.cc,
libinterp/corefcn/variables.h, libinterp/corefcn/workspace-element.h,
libinterp/corefcn/xdiv.cc, libinterp/corefcn/xdiv.h,
libinterp/corefcn/xnorm.cc, libinterp/corefcn/xnorm.h,
libinterp/corefcn/xpow.cc, libinterp/corefcn/xpow.h,
libinterp/corefcn/zfstream.cc, libinterp/corefcn/zfstream.h,
libinterp/deprecated-config.h, libinterp/dldfcn/__delaunayn__.cc,
libinterp/dldfcn/__eigs__.cc, libinterp/dldfcn/__fltk_uigetfile__.cc,
libinterp/dldfcn/__glpk__.cc, libinterp/dldfcn/__init_fltk__.cc,
libinterp/dldfcn/__init_gnuplot__.cc, libinterp/dldfcn/__osmesa_print__.cc,
libinterp/dldfcn/__voronoi__.cc, libinterp/dldfcn/amd.cc,
libinterp/dldfcn/audiodevinfo.cc, libinterp/dldfcn/audioread.cc,
libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/chol.cc,
libinterp/dldfcn/colamd.cc, libinterp/dldfcn/convhulln.cc,
libinterp/dldfcn/dmperm.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/gzip.cc,
libinterp/dldfcn/oct-qhull.h, libinterp/dldfcn/qr.cc,
libinterp/dldfcn/symbfact.cc, libinterp/dldfcn/symrcm.cc, libinterp/gendoc.pl,
libinterp/genprops.awk, libinterp/liboctinterp-build-info.h,
libinterp/liboctinterp-build-info.in.cc, libinterp/mk-errno-list,
libinterp/mk-pkg-add, libinterp/mkops, libinterp/octave-value/ov-base-diag.cc,
libinterp/octave-value/ov-base-diag.h, libinterp/octave-value/ov-base-int.cc,
libinterp/octave-value/ov-base-int.h, libinterp/octave-value/ov-base-mat.cc,
libinterp/octave-value/ov-base-mat.h, libinterp/octave-value/ov-base-scalar.cc,
libinterp/octave-value/ov-base-scalar.h,
libinterp/octave-value/ov-base-sparse.cc,
libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.cc,
libinterp/octave-value/ov-base.h, libinterp/octave-value/ov-bool-mat.cc,
libinterp/octave-value/ov-bool-mat.h, libinterp/octave-value/ov-bool-sparse.cc,
libinterp/octave-value/ov-bool-sparse.h, libinterp/octave-value/ov-bool.cc,
libinterp/octave-value/ov-bool.h, libinterp/octave-value/ov-builtin.cc,
libinterp/octave-value/ov-builtin.h, libinterp/octave-value/ov-cell.cc,
libinterp/octave-value/ov-cell.h, libinterp/octave-value/ov-ch-mat.cc,
libinterp/octave-value/ov-ch-mat.h, libinterp/octave-value/ov-class.cc,
libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-classdef.cc,
libinterp/octave-value/ov-classdef.h, libinterp/octave-value/ov-colon.cc,
libinterp/octave-value/ov-colon.h, libinterp/octave-value/ov-complex.cc,
libinterp/octave-value/ov-complex.h, libinterp/octave-value/ov-cs-list.cc,
libinterp/octave-value/ov-cs-list.h, libinterp/octave-value/ov-cx-diag.cc,
libinterp/octave-value/ov-cx-diag.h, libinterp/octave-value/ov-cx-mat.cc,
libinterp/octave-value/ov-cx-mat.h, libinterp/octave-value/ov-cx-sparse.cc,
libinterp/octave-value/ov-cx-sparse.h, libinterp/octave-value/ov-dld-fcn.cc,
libinterp/octave-value/ov-dld-fcn.h, libinterp/octave-value/ov-fcn-handle.cc,
libinterp/octave-value/ov-fcn-handle.h,
libinterp/octave-value/ov-fcn-inline.cc,
libinterp/octave-value/ov-fcn-inline.h, libinterp/octave-value/ov-fcn.cc,
libinterp/octave-value/ov-fcn.h, libinterp/octave-value/ov-float.cc,
libinterp/octave-value/ov-float.h, libinterp/octave-value/ov-flt-complex.cc,
libinterp/octave-value/ov-flt-complex.h,
libinterp/octave-value/ov-flt-cx-diag.cc,
libinterp/octave-value/ov-flt-cx-diag.h,
libinterp/octave-value/ov-flt-cx-mat.cc,
libinterp/octave-value/ov-flt-cx-mat.h,
libinterp/octave-value/ov-flt-re-diag.cc,
libinterp/octave-value/ov-flt-re-diag.h,
libinterp/octave-value/ov-flt-re-mat.cc,
libinterp/octave-value/ov-flt-re-mat.h, libinterp/octave-value/ov-int-traits.h,
libinterp/octave-value/ov-int16.cc, libinterp/octave-value/ov-int16.h,
libinterp/octave-value/ov-int32.cc, libinterp/octave-value/ov-int32.h,
libinterp/octave-value/ov-int64.cc, libinterp/octave-value/ov-int64.h,
libinterp/octave-value/ov-int8.cc, libinterp/octave-value/ov-int8.h,
libinterp/octave-value/ov-intx.h, libinterp/octave-value/ov-java.cc,
libinterp/octave-value/ov-java.h, libinterp/octave-value/ov-lazy-idx.cc,
libinterp/octave-value/ov-lazy-idx.h, libinterp/octave-value/ov-mex-fcn.cc,
libinterp/octave-value/ov-mex-fcn.h, libinterp/octave-value/ov-null-mat.cc,
libinterp/octave-value/ov-null-mat.h, libinterp/octave-value/ov-oncleanup.cc,
libinterp/octave-value/ov-oncleanup.h, libinterp/octave-value/ov-perm.cc,
libinterp/octave-value/ov-perm.h, libinterp/octave-value/ov-range.cc,
libinterp/octave-value/ov-range.h, libinterp/octave-value/ov-re-diag.cc,
libinterp/octave-value/ov-re-diag.h, libinterp/octave-value/ov-re-mat.cc,
libinterp/octave-value/ov-re-mat.h, libinterp/octave-value/ov-re-sparse.cc,
libinterp/octave-value/ov-re-sparse.h, libinterp/octave-value/ov-scalar.cc,
libinterp/octave-value/ov-scalar.h, libinterp/octave-value/ov-str-mat.cc,
libinterp/octave-value/ov-str-mat.h, libinterp/octave-value/ov-struct.cc,
libinterp/octave-value/ov-struct.h, libinterp/octave-value/ov-typeinfo.cc,
libinterp/octave-value/ov-typeinfo.h, libinterp/octave-value/ov-uint16.cc,
libinterp/octave-value/ov-uint16.h, libinterp/octave-value/ov-uint32.cc,
libinterp/octave-value/ov-uint32.h, libinterp/octave-value/ov-uint64.cc,
libinterp/octave-value/ov-uint64.h, libinterp/octave-value/ov-uint8.cc,
libinterp/octave-value/ov-uint8.h, libinterp/octave-value/ov-usr-fcn.cc,
libinterp/octave-value/ov-usr-fcn.h, libinterp/octave-value/ov.cc,
libinterp/octave-value/ov.h, libinterp/octave-value/ovl.cc,
libinterp/octave-value/ovl.h, libinterp/octave.cc, libinterp/octave.h,
libinterp/op-kw-docs, libinterp/operators/op-b-b.cc,
libinterp/operators/op-b-bm.cc, libinterp/operators/op-b-sbm.cc,
libinterp/operators/op-bm-b.cc, libinterp/operators/op-bm-bm.cc,
libinterp/operators/op-bm-sbm.cc, libinterp/operators/op-cdm-cdm.cc,
libinterp/operators/op-cdm-cm.cc, libinterp/operators/op-cdm-cs.cc,
libinterp/operators/op-cdm-dm.cc, libinterp/operators/op-cdm-m.cc,
libinterp/operators/op-cdm-s.cc, libinterp/operators/op-cell.cc,
libinterp/operators/op-chm.cc, libinterp/operators/op-class.cc,
libinterp/operators/op-cm-cdm.cc, libinterp/operators/op-cm-cm.cc,
libinterp/operators/op-cm-cs.cc, libinterp/operators/op-cm-dm.cc,
libinterp/operators/op-cm-m.cc, libinterp/operators/op-cm-pm.cc,
libinterp/operators/op-cm-s.cc, libinterp/operators/op-cm-scm.cc,
libinterp/operators/op-cm-sm.cc, libinterp/operators/op-cs-cm.cc,
libinterp/operators/op-cs-cs.cc, libinterp/operators/op-cs-m.cc,
libinterp/operators/op-cs-s.cc, libinterp/operators/op-cs-scm.cc,
libinterp/operators/op-cs-sm.cc, libinterp/operators/op-dm-cdm.cc,
libinterp/operators/op-dm-cm.cc, libinterp/operators/op-dm-cs.cc,
libinterp/operators/op-dm-dm.cc, libinterp/operators/op-dm-m.cc,
libinterp/operators/op-dm-s.cc, libinterp/operators/op-dm-scm.cc,
libinterp/operators/op-dm-sm.cc, libinterp/operators/op-dm-template.cc,
libinterp/operators/op-dms-template.cc, libinterp/operators/op-fcdm-fcdm.cc,
libinterp/operators/op-fcdm-fcm.cc, libinterp/operators/op-fcdm-fcs.cc,
libinterp/operators/op-fcdm-fdm.cc, libinterp/operators/op-fcdm-fm.cc,
libinterp/operators/op-fcdm-fs.cc, libinterp/operators/op-fcm-fcdm.cc,
libinterp/operators/op-fcm-fcm.cc, libinterp/operators/op-fcm-fcs.cc,
libinterp/operators/op-fcm-fdm.cc, libinterp/operators/op-fcm-fm.cc,
libinterp/operators/op-fcm-fs.cc, libinterp/operators/op-fcm-pm.cc,
libinterp/operators/op-fcn.cc, libinterp/operators/op-fcs-fcm.cc,
libinterp/operators/op-fcs-fcs.cc, libinterp/operators/op-fcs-fm.cc,
libinterp/operators/op-fcs-fs.cc, libinterp/operators/op-fdm-fcdm.cc,
libinterp/operators/op-fdm-fcm.cc, libinterp/operators/op-fdm-fcs.cc,
libinterp/operators/op-fdm-fdm.cc, libinterp/operators/op-fdm-fm.cc,
libinterp/operators/op-fdm-fs.cc, libinterp/operators/op-fm-fcdm.cc,
libinterp/operators/op-fm-fcm.cc, libinterp/operators/op-fm-fcs.cc,
libinterp/operators/op-fm-fdm.cc, libinterp/operators/op-fm-fm.cc,
libinterp/operators/op-fm-fs.cc, libinterp/operators/op-fm-pm.cc,
libinterp/operators/op-fs-fcm.cc, libinterp/operators/op-fs-fcs.cc,
libinterp/operators/op-fs-fm.cc, libinterp/operators/op-fs-fs.cc,
libinterp/operators/op-i16-i16.cc, libinterp/operators/op-i32-i32.cc,
libinterp/operators/op-i64-i64.cc, libinterp/operators/op-i8-i8.cc,
libinterp/operators/op-int-concat.cc, libinterp/operators/op-int.h,
libinterp/operators/op-m-cdm.cc, libinterp/operators/op-m-cm.cc,
libinterp/operators/op-m-cs.cc, libinterp/operators/op-m-dm.cc,
libinterp/operators/op-m-m.cc, libinterp/operators/op-m-pm.cc,
libinterp/operators/op-m-s.cc, libinterp/operators/op-m-scm.cc,
libinterp/operators/op-m-sm.cc, libinterp/operators/op-pm-cm.cc,
libinterp/operators/op-pm-fcm.cc, libinterp/operators/op-pm-fm.cc,
libinterp/operators/op-pm-m.cc, libinterp/operators/op-pm-pm.cc,
libinterp/operators/op-pm-scm.cc, libinterp/operators/op-pm-sm.cc,
libinterp/operators/op-pm-template.cc, libinterp/operators/op-range.cc,
libinterp/operators/op-s-cm.cc, libinterp/operators/op-s-cs.cc,
libinterp/operators/op-s-m.cc, libinterp/operators/op-s-s.cc,
libinterp/operators/op-s-scm.cc, libinterp/operators/op-s-sm.cc,
libinterp/operators/op-sbm-b.cc, libinterp/operators/op-sbm-bm.cc,
libinterp/operators/op-sbm-sbm.cc, libinterp/operators/op-scm-cm.cc,
libinterp/operators/op-scm-cs.cc, libinterp/operators/op-scm-m.cc,
libinterp/operators/op-scm-s.cc, libinterp/operators/op-scm-scm.cc,
libinterp/operators/op-scm-sm.cc, libinterp/operators/op-sm-cm.cc,
libinterp/operators/op-sm-cs.cc, libinterp/operators/op-sm-m.cc,
libinterp/operators/op-sm-s.cc, libinterp/operators/op-sm-scm.cc,
libinterp/operators/op-sm-sm.cc, libinterp/operators/op-str-m.cc,
libinterp/operators/op-str-s.cc, libinterp/operators/op-str-str.cc,
libinterp/operators/op-struct.cc, libinterp/operators/op-ui16-ui16.cc,
libinterp/operators/op-ui32-ui32.cc, libinterp/operators/op-ui64-ui64.cc,
libinterp/operators/op-ui8-ui8.cc, libinterp/operators/ops.h,
libinterp/options-usage.h, libinterp/parse-tree/lex.h,
libinterp/parse-tree/lex.ll, libinterp/parse-tree/oct-parse.in.yy,
libinterp/parse-tree/octave.gperf, libinterp/parse-tree/parse.h,
libinterp/parse-tree/pt-all.h, libinterp/parse-tree/pt-arg-list.cc,
libinterp/parse-tree/pt-arg-list.h, libinterp/parse-tree/pt-array-list.cc,
libinterp/parse-tree/pt-array-list.h, libinterp/parse-tree/pt-assign.cc,
libinterp/parse-tree/pt-assign.h, libinterp/parse-tree/pt-binop.cc,
libinterp/parse-tree/pt-binop.h, libinterp/parse-tree/pt-bp.cc,
libinterp/parse-tree/pt-bp.h, libinterp/parse-tree/pt-cbinop.cc,
libinterp/parse-tree/pt-cbinop.h, libinterp/parse-tree/pt-cell.cc,
libinterp/parse-tree/pt-cell.h, libinterp/parse-tree/pt-check.cc,
libinterp/parse-tree/pt-check.h, libinterp/parse-tree/pt-classdef.cc,
libinterp/parse-tree/pt-classdef.h, libinterp/parse-tree/pt-cmd.cc,
libinterp/parse-tree/pt-cmd.h, libinterp/parse-tree/pt-colon.cc,
libinterp/parse-tree/pt-colon.h, libinterp/parse-tree/pt-const.cc,
libinterp/parse-tree/pt-const.h, libinterp/parse-tree/pt-decl.cc,
libinterp/parse-tree/pt-decl.h, libinterp/parse-tree/pt-eval.cc,
libinterp/parse-tree/pt-eval.h, libinterp/parse-tree/pt-except.cc,
libinterp/parse-tree/pt-except.h, libinterp/parse-tree/pt-exp.cc,
libinterp/parse-tree/pt-exp.h, libinterp/parse-tree/pt-fcn-handle.cc,
libinterp/parse-tree/pt-fcn-handle.h, libinterp/parse-tree/pt-funcall.cc,
libinterp/parse-tree/pt-funcall.h, libinterp/parse-tree/pt-id.cc,
libinterp/parse-tree/pt-id.h, libinterp/parse-tree/pt-idx.cc,
libinterp/parse-tree/pt-idx.h, libinterp/parse-tree/pt-jump.cc,
libinterp/parse-tree/pt-jump.h, libinterp/parse-tree/pt-loop.cc,
libinterp/parse-tree/pt-loop.h, libinterp/parse-tree/pt-mat.cc,
libinterp/parse-tree/pt-mat.h, libinterp/parse-tree/pt-misc.cc,
libinterp/parse-tree/pt-misc.h, libinterp/parse-tree/pt-pr-code.cc,
libinterp/parse-tree/pt-pr-code.h, libinterp/parse-tree/pt-select.cc,
libinterp/parse-tree/pt-select.h, libinterp/parse-tree/pt-stmt.cc,
libinterp/parse-tree/pt-stmt.h, libinterp/parse-tree/pt-unop.cc,
libinterp/parse-tree/pt-unop.h, libinterp/parse-tree/pt-walk.h,
libinterp/parse-tree/pt.cc, libinterp/parse-tree/pt.h,
libinterp/parse-tree/token.cc, libinterp/parse-tree/token.h,
libinterp/template-inst/Array-jit.cc, libinterp/template-inst/Array-tc.cc,
libinterp/version.cc, libinterp/version.in.h, liboctave/array/Array-C.cc,
liboctave/array/Array-b.cc, liboctave/array/Array-ch.cc,
liboctave/array/Array-d.cc, liboctave/array/Array-f.cc,
liboctave/array/Array-fC.cc, liboctave/array/Array-i.cc,
liboctave/array/Array-idx-vec.cc, liboctave/array/Array-s.cc,
liboctave/array/Array-str.cc, liboctave/array/Array-util.cc,
liboctave/array/Array-util.h, liboctave/array/Array-voidp.cc,
liboctave/array/Array.cc, liboctave/array/Array.h,
liboctave/array/CColVector.cc, liboctave/array/CColVector.h,
liboctave/array/CDiagMatrix.cc, liboctave/array/CDiagMatrix.h,
liboctave/array/CMatrix.cc, liboctave/array/CMatrix.h,
liboctave/array/CNDArray.cc, liboctave/array/CNDArray.h,
liboctave/array/CRowVector.cc, liboctave/array/CRowVector.h,
liboctave/array/CSparse.cc, liboctave/array/CSparse.h,
liboctave/array/DiagArray2.cc, liboctave/array/DiagArray2.h,
liboctave/array/MArray-C.cc, liboctave/array/MArray-d.cc,
liboctave/array/MArray-f.cc, liboctave/array/MArray-fC.cc,
liboctave/array/MArray-i.cc, liboctave/array/MArray-s.cc,
liboctave/array/MArray.cc, liboctave/array/MArray.h,
liboctave/array/MDiagArray2.cc, liboctave/array/MDiagArray2.h,
liboctave/array/MSparse-C.cc, liboctave/array/MSparse-d.cc,
liboctave/array/MSparse.cc, liboctave/array/MSparse.h,
liboctave/array/Matrix.h, liboctave/array/MatrixType.cc,
liboctave/array/MatrixType.h, liboctave/array/PermMatrix.cc,
liboctave/array/PermMatrix.h, liboctave/array/Range.cc,
liboctave/array/Range.h, liboctave/array/Sparse-C.cc,
liboctave/array/Sparse-b.cc, liboctave/array/Sparse-d.cc,
liboctave/array/Sparse.cc, liboctave/array/Sparse.h,
liboctave/array/boolMatrix.cc, liboctave/array/boolMatrix.h,
liboctave/array/boolNDArray.cc, liboctave/array/boolNDArray.h,
liboctave/array/boolSparse.cc, liboctave/array/boolSparse.h,
liboctave/array/chMatrix.cc, liboctave/array/chMatrix.h,
liboctave/array/chNDArray.cc, liboctave/array/chNDArray.h,
liboctave/array/dColVector.cc, liboctave/array/dColVector.h,
liboctave/array/dDiagMatrix.cc, liboctave/array/dDiagMatrix.h,
liboctave/array/dMatrix.cc, liboctave/array/dMatrix.h,
liboctave/array/dNDArray.cc, liboctave/array/dNDArray.h,
liboctave/array/dRowVector.cc, liboctave/array/dRowVector.h,
liboctave/array/dSparse.cc, liboctave/array/dSparse.h,
liboctave/array/dim-vector.cc, liboctave/array/dim-vector.h,
liboctave/array/fCColVector.cc, liboctave/array/fCColVector.h,
liboctave/array/fCDiagMatrix.cc, liboctave/array/fCDiagMatrix.h,
liboctave/array/fCMatrix.cc, liboctave/array/fCMatrix.h,
liboctave/array/fCNDArray.cc, liboctave/array/fCNDArray.h,
liboctave/array/fCRowVector.cc, liboctave/array/fCRowVector.h,
liboctave/array/fColVector.cc, liboctave/array/fColVector.h,
liboctave/array/fDiagMatrix.cc, liboctave/array/fDiagMatrix.h,
liboctave/array/fMatrix.cc, liboctave/array/fMatrix.h,
liboctave/array/fNDArray.cc, liboctave/array/fNDArray.h,
liboctave/array/fRowVector.cc, liboctave/array/fRowVector.h,
liboctave/array/idx-vector.cc, liboctave/array/idx-vector.h,
liboctave/array/int16NDArray.cc, liboctave/array/int16NDArray.h,
liboctave/array/int32NDArray.cc, liboctave/array/int32NDArray.h,
liboctave/array/int64NDArray.cc, liboctave/array/int64NDArray.h,
liboctave/array/int8NDArray.cc, liboctave/array/int8NDArray.h,
liboctave/array/intNDArray.cc, liboctave/array/intNDArray.h,
liboctave/array/uint16NDArray.cc, liboctave/array/uint16NDArray.h,
liboctave/array/uint32NDArray.cc, liboctave/array/uint32NDArray.h,
liboctave/array/uint64NDArray.cc, liboctave/array/uint64NDArray.h,
liboctave/array/uint8NDArray.cc, liboctave/array/uint8NDArray.h,
liboctave/cruft/misc/blaswrap.c, liboctave/cruft/misc/cquit.c,
liboctave/cruft/misc/f77-extern.cc, liboctave/cruft/misc/f77-fcn.c,
liboctave/cruft/misc/f77-fcn.h, liboctave/cruft/misc/lo-error.c,
liboctave/cruft/misc/lo-error.h, liboctave/cruft/misc/quit.cc,
liboctave/cruft/misc/quit.h, liboctave/liboctave-build-info.h,
liboctave/liboctave-build-info.in.cc, liboctave/numeric/CollocWt.cc,
liboctave/numeric/CollocWt.h, liboctave/numeric/DAE.h,
liboctave/numeric/DAEFunc.h, liboctave/numeric/DAERT.h,
liboctave/numeric/DAERTFunc.h, liboctave/numeric/DASPK-opts.in,
liboctave/numeric/DASPK.cc, liboctave/numeric/DASPK.h,
liboctave/numeric/DASRT-opts.in, liboctave/numeric/DASRT.cc,
liboctave/numeric/DASRT.h, liboctave/numeric/DASSL-opts.in,
liboctave/numeric/DASSL.cc, liboctave/numeric/DASSL.h, liboctave/numeric/DET.h,
liboctave/numeric/EIG.cc, liboctave/numeric/EIG.h,
liboctave/numeric/LSODE-opts.in, liboctave/numeric/LSODE.cc,
liboctave/numeric/LSODE.h, liboctave/numeric/ODE.h,
liboctave/numeric/ODEFunc.h, liboctave/numeric/ODES.cc,
liboctave/numeric/ODES.h, liboctave/numeric/ODESFunc.h,
liboctave/numeric/Quad-opts.in, liboctave/numeric/Quad.cc,
liboctave/numeric/Quad.h, liboctave/numeric/aepbalance.cc,
liboctave/numeric/aepbalance.h, liboctave/numeric/base-dae.h,
liboctave/numeric/base-de.h, liboctave/numeric/base-min.h,
liboctave/numeric/bsxfun-decl.h, liboctave/numeric/bsxfun-defs.cc,
liboctave/numeric/bsxfun.h, liboctave/numeric/chol.cc,
liboctave/numeric/chol.h, liboctave/numeric/eigs-base.cc,
liboctave/numeric/eigs-base.h, liboctave/numeric/fEIG.cc,
liboctave/numeric/fEIG.h, liboctave/numeric/gepbalance.cc,
liboctave/numeric/gepbalance.h, liboctave/numeric/gsvd.cc,
liboctave/numeric/gsvd.h, liboctave/numeric/hess.cc, liboctave/numeric/hess.h,
liboctave/numeric/lo-amos-proto.h, liboctave/numeric/lo-arpack-proto.h,
liboctave/numeric/lo-blas-proto.h, liboctave/numeric/lo-fftpack-proto.h,
liboctave/numeric/lo-lapack-proto.h, liboctave/numeric/lo-mappers.cc,
liboctave/numeric/lo-mappers.h, liboctave/numeric/lo-qrupdate-proto.h,
liboctave/numeric/lo-ranlib-proto.h, liboctave/numeric/lo-slatec-proto.h,
liboctave/numeric/lo-specfun.cc, liboctave/numeric/lo-specfun.h,
liboctave/numeric/lu.cc, liboctave/numeric/lu.h,
liboctave/numeric/oct-convn.cc, liboctave/numeric/oct-convn.h,
liboctave/numeric/oct-fftw.cc, liboctave/numeric/oct-fftw.h,
liboctave/numeric/oct-norm.cc, liboctave/numeric/oct-norm.h,
liboctave/numeric/oct-rand.cc, liboctave/numeric/oct-rand.h,
liboctave/numeric/oct-spparms.cc, liboctave/numeric/oct-spparms.h,
liboctave/numeric/qr.cc, liboctave/numeric/qr.h, liboctave/numeric/qrp.cc,
liboctave/numeric/qrp.h, liboctave/numeric/randgamma.cc,
liboctave/numeric/randgamma.h, liboctave/numeric/randmtzig.cc,
liboctave/numeric/randmtzig.h, liboctave/numeric/randpoisson.cc,
liboctave/numeric/randpoisson.h, liboctave/numeric/schur.cc,
liboctave/numeric/schur.h, liboctave/numeric/sparse-chol.cc,
liboctave/numeric/sparse-chol.h, liboctave/numeric/sparse-dmsolve.cc,
liboctave/numeric/sparse-dmsolve.h, liboctave/numeric/sparse-lu.cc,
liboctave/numeric/sparse-lu.h, liboctave/numeric/sparse-qr.cc,
liboctave/numeric/sparse-qr.h, liboctave/numeric/svd.cc,
liboctave/numeric/svd.h, liboctave/operators/Sparse-diag-op-defs.h,
liboctave/operators/Sparse-op-decls.h, liboctave/operators/Sparse-op-defs.h,
liboctave/operators/Sparse-perm-op-defs.h, liboctave/operators/mk-ops.awk,
liboctave/operators/mx-base.h, liboctave/operators/mx-defs.h,
liboctave/operators/mx-ext.h, liboctave/operators/mx-inlines.cc,
liboctave/operators/mx-op-decl.h, liboctave/operators/mx-op-defs.h,
liboctave/operators/mx-ops, liboctave/operators/smx-ops,
liboctave/operators/vx-ops, liboctave/system/child-list.cc,
liboctave/system/child-list.h, liboctave/system/dir-ops.cc,
liboctave/system/dir-ops.h, liboctave/system/file-ops.cc,
liboctave/system/file-ops.h, liboctave/system/file-stat.cc,
liboctave/system/file-stat.h, liboctave/system/lo-sysdep.cc,
liboctave/system/lo-sysdep.h, liboctave/system/mach-info.cc,
liboctave/system/mach-info.h, liboctave/system/oct-env.cc,
liboctave/system/oct-env.h, liboctave/system/oct-group.cc,
liboctave/system/oct-group.h, liboctave/system/oct-passwd.cc,
liboctave/system/oct-passwd.h, liboctave/system/oct-syscalls.cc,
liboctave/system/oct-syscalls.h, liboctave/system/oct-time.cc,
liboctave/system/oct-time.h, liboctave/system/oct-uname.cc,
liboctave/system/oct-uname.h, liboctave/util/action-container.h,
liboctave/util/base-list.h, liboctave/util/byte-swap.h,
liboctave/util/caseless-str.h, liboctave/util/cmd-edit.cc,
liboctave/util/cmd-edit.h, liboctave/util/cmd-hist.cc,
liboctave/util/cmd-hist.h, liboctave/util/data-conv.cc,
liboctave/util/data-conv.h, liboctave/util/f2c-main.c,
liboctave/util/functor.h, liboctave/util/glob-match.cc,
liboctave/util/glob-match.h, liboctave/util/kpse.cc, liboctave/util/kpse.h,
liboctave/util/lo-array-errwarn.cc, liboctave/util/lo-array-errwarn.h,
liboctave/util/lo-array-gripes.cc, liboctave/util/lo-array-gripes.h,
liboctave/util/lo-cutils.c, liboctave/util/lo-cutils.h,
liboctave/util/lo-hash.cc, liboctave/util/lo-hash.h, liboctave/util/lo-ieee.cc,
liboctave/util/lo-ieee.h, liboctave/util/lo-macros.h, liboctave/util/lo-math.h,
liboctave/util/lo-regexp.cc, liboctave/util/lo-regexp.h,
liboctave/util/lo-traits.h, liboctave/util/lo-utils.cc,
liboctave/util/lo-utils.h, liboctave/util/oct-alloc.h,
liboctave/util/oct-base64.cc, liboctave/util/oct-base64.h,
liboctave/util/oct-binmap.h, liboctave/util/oct-cmplx.h,
liboctave/util/oct-glob.cc, liboctave/util/oct-glob.h,
liboctave/util/oct-inttypes-fwd.h, liboctave/util/oct-inttypes.cc,
liboctave/util/oct-inttypes.h, liboctave/util/oct-locbuf.cc,
liboctave/util/oct-locbuf.h, liboctave/util/oct-mutex.cc,
liboctave/util/oct-mutex.h, liboctave/util/oct-refcount.h,
liboctave/util/oct-rl-edit.c, liboctave/util/oct-rl-edit.h,
liboctave/util/oct-rl-hist.c, liboctave/util/oct-rl-hist.h,
liboctave/util/oct-shlib.cc, liboctave/util/oct-shlib.h,
liboctave/util/oct-sort.cc, liboctave/util/oct-sort.h,
liboctave/util/oct-sparse.h, liboctave/util/oct-string.cc,
liboctave/util/oct-string.h, liboctave/util/pathsearch.cc,
liboctave/util/pathsearch.h, liboctave/util/singleton-cleanup.cc,
liboctave/util/sparse-sort.cc, liboctave/util/sparse-sort.h,
liboctave/util/sparse-util.cc, liboctave/util/sparse-util.h,
liboctave/util/str-vec.cc, liboctave/util/str-vec.h,
liboctave/util/sun-utils.h, liboctave/util/unwind-prot.cc,
liboctave/util/unwind-prot.h, liboctave/util/url-transfer.cc,
liboctave/util/url-transfer.h, liboctave/wrappers/areadlink-wrapper.c,
liboctave/wrappers/areadlink-wrapper.h,
liboctave/wrappers/async-system-wrapper.c,
liboctave/wrappers/async-system-wrapper.h,
liboctave/wrappers/base64-wrappers.c, liboctave/wrappers/base64-wrappers.h,
liboctave/wrappers/canonicalize-file-name-wrapper.c,
liboctave/wrappers/canonicalize-file-name-wrapper.h,
liboctave/wrappers/dirent-wrappers.c, liboctave/wrappers/dirent-wrappers.h,
liboctave/wrappers/fcntl-wrappers.c, liboctave/wrappers/fcntl-wrappers.h,
liboctave/wrappers/filepos-wrappers.c, liboctave/wrappers/filepos-wrappers.h,
liboctave/wrappers/fpucw-wrappers.c, liboctave/wrappers/fpucw-wrappers.h,
liboctave/wrappers/gen-tempname-wrapper.c,
liboctave/wrappers/gen-tempname-wrapper.h, liboctave/wrappers/getopt-wrapper.c,
liboctave/wrappers/getopt-wrapper.h, liboctave/wrappers/glob-wrappers.c,
liboctave/wrappers/glob-wrappers.h, liboctave/wrappers/hash-wrappers.c,
liboctave/wrappers/hash-wrappers.h, liboctave/wrappers/math-wrappers.c,
liboctave/wrappers/math-wrappers.h, liboctave/wrappers/mkostemp-wrapper.c,
liboctave/wrappers/mkostemp-wrapper.h, liboctave/wrappers/nanosleep-wrapper.c,
liboctave/wrappers/nanosleep-wrapper.h, liboctave/wrappers/nproc-wrapper.c,
liboctave/wrappers/nproc-wrapper.h, liboctave/wrappers/octave-popen2.c,
liboctave/wrappers/octave-popen2.h, liboctave/wrappers/putenv-wrapper.c,
liboctave/wrappers/putenv-wrapper.h,
liboctave/wrappers/set-program-name-wrapper.c,
liboctave/wrappers/set-program-name-wrapper.h,
liboctave/wrappers/signal-wrappers.c, liboctave/wrappers/signal-wrappers.h,
liboctave/wrappers/stat-wrappers.c, liboctave/wrappers/stat-wrappers.h,
liboctave/wrappers/strdup-wrapper.c, liboctave/wrappers/strdup-wrapper.h,
liboctave/wrappers/strftime-wrapper.c, liboctave/wrappers/strftime-wrapper.h,
liboctave/wrappers/strmode-wrapper.c, liboctave/wrappers/strmode-wrapper.h,
liboctave/wrappers/strptime-wrapper.c, liboctave/wrappers/strptime-wrapper.h,
liboctave/wrappers/time-wrappers.c, liboctave/wrappers/time-wrappers.h,
liboctave/wrappers/tmpfile-wrapper.c, liboctave/wrappers/tmpfile-wrapper.h,
liboctave/wrappers/uname-wrapper.c, liboctave/wrappers/uname-wrapper.h,
liboctave/wrappers/unistd-wrappers.c, liboctave/wrappers/unistd-wrappers.h,
liboctave/wrappers/unsetenv-wrapper.c, liboctave/wrappers/unsetenv-wrapper.h,
liboctave/wrappers/vasprintf-wrapper.c, liboctave/wrappers/vasprintf-wrapper.h,
liboctave/wrappers/wait-for-input.c, liboctave/wrappers/wait-for-input.h,
liboctave/wrappers/wait-wrappers.c, liboctave/wrappers/wait-wrappers.h,
m4/acinclude.m4, oct-conf-post.in.h, run-octave.in, scripts/@ftp/ascii.m,
scripts/@ftp/binary.m, scripts/@ftp/cd.m, scripts/@ftp/close.m,
scripts/@ftp/delete.m, scripts/@ftp/dir.m, scripts/@ftp/display.m,
scripts/@ftp/ftp.m, scripts/@ftp/loadobj.m, scripts/@ftp/mget.m,
scripts/@ftp/mkdir.m, scripts/@ftp/mput.m, scripts/@ftp/rename.m,
scripts/@ftp/rmdir.m, scripts/@ftp/saveobj.m,
scripts/audio/@audioplayer/__get_properties__.m,
scripts/audio/@audioplayer/audioplayer.m, scripts/audio/@audioplayer/display.m,
scripts/audio/@audioplayer/get.m, scripts/audio/@audioplayer/isplaying.m,
scripts/audio/@audioplayer/pause.m, scripts/audio/@audioplayer/play.m,
scripts/audio/@audioplayer/playblocking.m, scripts/audio/@audioplayer/resume.m,
scripts/audio/@audioplayer/set.m, scripts/audio/@audioplayer/stop.m,
scripts/audio/@audioplayer/subsasgn.m, scripts/audio/@audioplayer/subsref.m,
scripts/audio/@audiorecorder/__get_properties__.m,
scripts/audio/@audiorecorder/audiorecorder.m,
scripts/audio/@audiorecorder/display.m, scripts/audio/@audiorecorder/get.m,
scripts/audio/@audiorecorder/getaudiodata.m,
scripts/audio/@audiorecorder/getplayer.m,
scripts/audio/@audiorecorder/isrecording.m,
scripts/audio/@audiorecorder/pause.m, scripts/audio/@audiorecorder/play.m,
scripts/audio/@audiorecorder/record.m,
scripts/audio/@audiorecorder/recordblocking.m,
scripts/audio/@audiorecorder/resume.m, scripts/audio/@audiorecorder/set.m,
scripts/audio/@audiorecorder/stop.m, scripts/audio/@audiorecorder/subsasgn.m,
scripts/audio/@audiorecorder/subsref.m, scripts/audio/lin2mu.m,
scripts/audio/mu2lin.m, scripts/audio/record.m, scripts/audio/sound.m,
scripts/audio/soundsc.m, scripts/deprecated/bitmax.m,
scripts/deprecated/comma.m, scripts/deprecated/isstr.m,
scripts/deprecated/mahalanobis.m, scripts/deprecated/md5sum.m,
scripts/deprecated/octave_config_info.m, scripts/deprecated/onenormest.m,
scripts/deprecated/paren.m, scripts/deprecated/semicolon.m,
scripts/deprecated/sleep.m, scripts/deprecated/usleep.m,
scripts/deprecated/wavread.m, scripts/deprecated/wavwrite.m,
scripts/elfun/acosd.m, scripts/elfun/acot.m, scripts/elfun/acotd.m,
scripts/elfun/acoth.m, scripts/elfun/acsc.m, scripts/elfun/acscd.m,
scripts/elfun/acsch.m, scripts/elfun/asec.m, scripts/elfun/asecd.m,
scripts/elfun/asech.m, scripts/elfun/asind.m, scripts/elfun/atan2d.m,
scripts/elfun/atand.m, scripts/elfun/cosd.m, scripts/elfun/cot.m,
scripts/elfun/cotd.m, scripts/elfun/coth.m, scripts/elfun/csc.m,
scripts/elfun/cscd.m, scripts/elfun/csch.m, scripts/elfun/sec.m,
scripts/elfun/secd.m, scripts/elfun/sech.m, scripts/elfun/sind.m,
scripts/elfun/tand.m, scripts/general/accumarray.m, scripts/general/accumdim.m,
scripts/general/bincoeff.m, scripts/general/bitcmp.m, scripts/general/bitget.m,
scripts/general/bitset.m, scripts/general/blkdiag.m,
scripts/general/cart2pol.m, scripts/general/cart2sph.m,
scripts/general/cell2mat.m, scripts/general/celldisp.m, scripts/general/chop.m,
scripts/general/circshift.m, scripts/general/common_size.m,
scripts/general/cplxpair.m, scripts/general/cumtrapz.m, scripts/general/curl.m,
scripts/general/dblquad.m, scripts/general/deal.m, scripts/general/deg2rad.m,
scripts/general/del2.m, scripts/general/display.m,
scripts/general/divergence.m, scripts/general/fieldnames.m,
scripts/general/flip.m, scripts/general/flipdim.m, scripts/general/fliplr.m,
scripts/general/flipud.m, scripts/general/grabcode.m,
scripts/general/gradient.m, scripts/general/idivide.m,
scripts/general/inputParser.m, scripts/general/int2str.m,
scripts/general/interp1.m, scripts/general/interp2.m,
scripts/general/interp3.m, scripts/general/interpft.m,
scripts/general/interpn.m, scripts/general/isdir.m, scripts/general/isequal.m,
scripts/general/isequaln.m, scripts/general/loadobj.m,
scripts/general/logspace.m, scripts/general/methods.m,
scripts/general/nargchk.m, scripts/general/narginchk.m,
scripts/general/nargoutchk.m, scripts/general/nextpow2.m,
scripts/general/nthargout.m, scripts/general/num2str.m,
scripts/general/pol2cart.m, scripts/general/polyarea.m,
scripts/general/postpad.m, scripts/general/prepad.m,
scripts/general/private/__isequal__.m, scripts/general/private/__splinen__.m,
scripts/general/publish.m, scripts/general/quadgk.m, scripts/general/quadl.m,
scripts/general/quadv.m, scripts/general/rad2deg.m, scripts/general/randi.m,
scripts/general/rat.m, scripts/general/repmat.m, scripts/general/rot90.m,
scripts/general/rotdim.m, scripts/general/saveobj.m, scripts/general/shift.m,
scripts/general/shiftdim.m, scripts/general/sortrows.m,
scripts/general/sph2cart.m, scripts/general/structfun.m,
scripts/general/subsindex.m, scripts/general/trapz.m,
scripts/general/triplequad.m, scripts/general/validateattributes.m,
scripts/geometry/convhull.m, scripts/geometry/delaunay.m,
scripts/geometry/delaunayn.m, scripts/geometry/dsearch.m,
scripts/geometry/dsearchn.m, scripts/geometry/griddata.m,
scripts/geometry/griddata3.m, scripts/geometry/griddatan.m,
scripts/geometry/inpolygon.m, scripts/geometry/rectint.m,
scripts/geometry/tsearchn.m, scripts/geometry/voronoi.m,
scripts/geometry/voronoin.m, scripts/gui/dialog.m, scripts/gui/errordlg.m,
scripts/gui/guidata.m, scripts/gui/guihandles.m, scripts/gui/helpdlg.m,
scripts/gui/inputdlg.m, scripts/gui/listdlg.m, scripts/gui/msgbox.m,
scripts/gui/private/__file_filter__.m,
scripts/gui/private/__fltk_file_filter__.m,
scripts/gui/private/__get_funcname__.m, scripts/gui/private/__is_function__.m,
scripts/gui/private/__uigetdir_fltk__.m,
scripts/gui/private/__uigetfile_fltk__.m,
scripts/gui/private/__uiobject_split_args__.m,
scripts/gui/private/__uiputfile_fltk__.m, scripts/gui/questdlg.m,
scripts/gui/uibuttongroup.m, scripts/gui/uicontextmenu.m,
scripts/gui/uicontrol.m, scripts/gui/uigetdir.m, scripts/gui/uigetfile.m,
scripts/gui/uimenu.m, scripts/gui/uipanel.m, scripts/gui/uipushtool.m,
scripts/gui/uiputfile.m, scripts/gui/uiresume.m, scripts/gui/uitoggletool.m,
scripts/gui/uitoolbar.m, scripts/gui/uiwait.m, scripts/gui/waitbar.m,
scripts/gui/waitforbuttonpress.m, scripts/gui/warndlg.m,
scripts/help/__gripe_missing_component__.m, scripts/help/__makeinfo__.m,
scripts/help/__unimplemented__.m, scripts/help/ans.m, scripts/help/doc.m,
scripts/help/doc_cache_create.m, scripts/help/error_ids.m,
scripts/help/get_first_help_sentence.m, scripts/help/help.m,
scripts/help/lookfor.m, scripts/help/print_usage.m,
scripts/help/private/__additional_help_message__.m,
scripts/help/private/__strip_html_tags__.m, scripts/help/type.m,
scripts/help/warning_ids.m, scripts/help/which.m, scripts/image/autumn.m,
scripts/image/bone.m, scripts/image/brighten.m, scripts/image/cmpermute.m,
scripts/image/cmunique.m, scripts/image/colorcube.m, scripts/image/colormap.m,
scripts/image/contrast.m, scripts/image/cool.m, scripts/image/copper.m,
scripts/image/cubehelix.m, scripts/image/flag.m, scripts/image/gray.m,
scripts/image/gray2ind.m, scripts/image/hot.m, scripts/image/hsv.m,
scripts/image/hsv2rgb.m, scripts/image/im2double.m, scripts/image/image.m,
scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m,
scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m,
scripts/image/ind2gray.m, scripts/image/ind2rgb.m, scripts/image/iscolormap.m,
scripts/image/jet.m, scripts/image/lines.m, scripts/image/ntsc2rgb.m,
scripts/image/ocean.m, scripts/image/pink.m, scripts/image/prism.m,
scripts/image/private/__imfinfo__.m, scripts/image/private/__imread__.m,
scripts/image/private/__imwrite__.m,
scripts/image/private/colorspace_conversion_input_check.m,
scripts/image/private/colorspace_conversion_revert.m,
scripts/image/private/imageIO.m, scripts/image/private/imwrite_filename.m,
scripts/image/private/ind2x.m, scripts/image/rainbow.m,
scripts/image/rgb2hsv.m, scripts/image/rgb2ind.m, scripts/image/rgb2ntsc.m,
scripts/image/rgbplot.m, scripts/image/spinmap.m, scripts/image/spring.m,
scripts/image/summer.m, scripts/image/viridis.m, scripts/image/white.m,
scripts/image/winter.m, scripts/io/beep.m, scripts/io/csvread.m,
scripts/io/csvwrite.m, scripts/io/dlmwrite.m, scripts/io/fileread.m,
scripts/io/importdata.m, scripts/io/is_valid_file_id.m, scripts/io/strread.m,
scripts/io/textread.m, scripts/java/javaArray.m, scripts/java/java_get.m,
scripts/java/java_set.m, scripts/java/javaaddpath.m, scripts/java/javachk.m,
scripts/java/javaclasspath.m, scripts/java/javamem.m,
scripts/java/javarmpath.m, scripts/java/org/octave/ClassHelper.java,
scripts/java/org/octave/Matrix.java,
scripts/java/org/octave/OctClassLoader.java,
scripts/java/org/octave/Octave.java,
scripts/java/org/octave/OctaveReference.java, scripts/java/usejava.m,
scripts/linear-algebra/bandwidth.m,
scripts/linear-algebra/commutation_matrix.m, scripts/linear-algebra/cond.m,
scripts/linear-algebra/condeig.m, scripts/linear-algebra/condest.m,
scripts/linear-algebra/cross.m, scripts/linear-algebra/duplication_matrix.m,
scripts/linear-algebra/expm.m, scripts/linear-algebra/housh.m,
scripts/linear-algebra/isbanded.m, scripts/linear-algebra/isdefinite.m,
scripts/linear-algebra/isdiag.m, scripts/linear-algebra/ishermitian.m,
scripts/linear-algebra/issymmetric.m, scripts/linear-algebra/istril.m,
scripts/linear-algebra/istriu.m, scripts/linear-algebra/krylov.m,
scripts/linear-algebra/linsolve.m, scripts/linear-algebra/logm.m,
scripts/linear-algebra/normest.m, scripts/linear-algebra/normest1.m,
scripts/linear-algebra/null.m, scripts/linear-algebra/orth.m,
scripts/linear-algebra/planerot.m, scripts/linear-algebra/qzhess.m,
scripts/linear-algebra/rank.m, scripts/linear-algebra/rref.m,
scripts/linear-algebra/subspace.m, scripts/linear-algebra/trace.m,
scripts/linear-algebra/vech.m, scripts/miscellaneous/bug_report.m,
scripts/miscellaneous/bunzip2.m, scripts/miscellaneous/cast.m,
scripts/miscellaneous/citation.m, scripts/miscellaneous/compare_versions.m,
scripts/miscellaneous/computer.m, scripts/miscellaneous/copyfile.m,
scripts/miscellaneous/debug.m, scripts/miscellaneous/delete.m,
scripts/miscellaneous/desktop.m, scripts/miscellaneous/dir.m,
scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m,
scripts/miscellaneous/fact.m, scripts/miscellaneous/fileattrib.m,
scripts/miscellaneous/fileparts.m, scripts/miscellaneous/fullfile.m,
scripts/miscellaneous/genvarname.m, scripts/miscellaneous/getappdata.m,
scripts/miscellaneous/getfield.m, scripts/miscellaneous/gunzip.m,
scripts/miscellaneous/info.m, scripts/miscellaneous/inputname.m,
scripts/miscellaneous/isappdata.m, scripts/miscellaneous/isdeployed.m,
scripts/miscellaneous/ismac.m, scripts/miscellaneous/ispc.m,
scripts/miscellaneous/isunix.m, scripts/miscellaneous/license.m,
scripts/miscellaneous/list_primes.m, scripts/miscellaneous/ls.m,
scripts/miscellaneous/ls_command.m, scripts/miscellaneous/menu.m,
scripts/miscellaneous/mex.m, scripts/miscellaneous/mexext.m,
scripts/miscellaneous/mkdir.m, scripts/miscellaneous/mkoctfile.m,
scripts/miscellaneous/movefile.m, scripts/miscellaneous/namelengthmax.m,
scripts/miscellaneous/news.m, scripts/miscellaneous/open.m,
scripts/miscellaneous/orderfields.m, scripts/miscellaneous/pack.m,
scripts/miscellaneous/parseparams.m, scripts/miscellaneous/perl.m,
scripts/miscellaneous/private/__w2mpth__.m,
scripts/miscellaneous/private/display_info_file.m,
scripts/miscellaneous/python.m, scripts/miscellaneous/recycle.m,
scripts/miscellaneous/rmappdata.m, scripts/miscellaneous/run.m,
scripts/miscellaneous/setappdata.m, scripts/miscellaneous/setfield.m,
scripts/miscellaneous/substruct.m, scripts/miscellaneous/swapbytes.m,
scripts/miscellaneous/symvar.m, scripts/miscellaneous/tar.m,
scripts/miscellaneous/tempdir.m, scripts/miscellaneous/tmpnam.m,
scripts/miscellaneous/unix.m, scripts/miscellaneous/unpack.m,
scripts/miscellaneous/untar.m, scripts/miscellaneous/unzip.m,
scripts/miscellaneous/ver.m, scripts/miscellaneous/version.m,
scripts/miscellaneous/what.m, scripts/miscellaneous/xor.m,
scripts/miscellaneous/zip.m, scripts/mk-pkg-add, scripts/mkdoc.pl,
scripts/ode/ode23.m, scripts/ode/ode45.m, scripts/ode/odeget.m,
scripts/ode/odeplot.m, scripts/ode/odeset.m, scripts/ode/private/AbsRel_norm.m,
scripts/ode/private/integrate_adaptive.m, scripts/ode/private/kahan.m,
scripts/ode/private/ode_event_handler.m, scripts/ode/private/odedefaults.m,
scripts/ode/private/odemergeopts.m, scripts/ode/private/runge_kutta_23.m,
scripts/ode/private/runge_kutta_45_dorpri.m,
scripts/ode/private/runge_kutta_interpolate.m,
scripts/ode/private/starting_stepsize.m, scripts/optimization/__all_opts__.m,
scripts/optimization/fminbnd.m, scripts/optimization/fminsearch.m,
scripts/optimization/fminunc.m, scripts/optimization/fsolve.m,
scripts/optimization/fzero.m, scripts/optimization/glpk.m,
scripts/optimization/lsqnonneg.m, scripts/optimization/optimget.m,
scripts/optimization/optimset.m, scripts/optimization/pqpnonneg.m,
scripts/optimization/private/__fdjac__.m, scripts/optimization/qp.m,
scripts/optimization/sqp.m, scripts/path/matlabroot.m, scripts/path/pathdef.m,
scripts/path/private/getsavepath.m, scripts/path/savepath.m, scripts/pkg/pkg.m,
scripts/pkg/private/build.m, scripts/pkg/private/configure_make.m,
scripts/pkg/private/default_prefix.m, scripts/pkg/private/describe.m,
scripts/pkg/private/dirempty.m, scripts/pkg/private/get_description.m,
scripts/pkg/private/get_forge_download.m, scripts/pkg/private/get_forge_pkg.m,
scripts/pkg/private/get_unsatisfied_deps.m, scripts/pkg/private/getarch.m,
scripts/pkg/private/getarchdir.m, scripts/pkg/private/install.m,
scripts/pkg/private/installed_packages.m,
scripts/pkg/private/list_forge_packages.m, scripts/pkg/private/load_packages.m,
scripts/pkg/private/load_packages_and_dependencies.m,
scripts/pkg/private/rebuild.m, scripts/pkg/private/save_order.m,
scripts/pkg/private/uninstall.m, scripts/pkg/private/unload_packages.m,
scripts/plot/appearance/__clabel__.m,
scripts/plot/appearance/__getlegenddata__.m,
scripts/plot/appearance/annotation.m, scripts/plot/appearance/axis.m,
scripts/plot/appearance/box.m, scripts/plot/appearance/caxis.m,
scripts/plot/appearance/clabel.m, scripts/plot/appearance/daspect.m,
scripts/plot/appearance/datetick.m, scripts/plot/appearance/diffuse.m,
scripts/plot/appearance/grid.m, scripts/plot/appearance/gtext.m,
scripts/plot/appearance/hidden.m, scripts/plot/appearance/legend.m,
scripts/plot/appearance/lighting.m, scripts/plot/appearance/material.m,
scripts/plot/appearance/orient.m, scripts/plot/appearance/pbaspect.m,
scripts/plot/appearance/private/__axis_label__.m,
scripts/plot/appearance/private/__axis_limits__.m,
scripts/plot/appearance/shading.m, scripts/plot/appearance/specular.m,
scripts/plot/appearance/text.m, scripts/plot/appearance/title.m,
scripts/plot/appearance/view.m, scripts/plot/appearance/whitebg.m,
scripts/plot/appearance/xlabel.m, scripts/plot/appearance/xlim.m,
scripts/plot/appearance/ylabel.m, scripts/plot/appearance/ylim.m,
scripts/plot/appearance/zlabel.m, scripts/plot/appearance/zlim.m,
scripts/plot/draw/area.m, scripts/plot/draw/bar.m, scripts/plot/draw/barh.m,
scripts/plot/draw/camlight.m, scripts/plot/draw/colorbar.m,
scripts/plot/draw/comet.m, scripts/plot/draw/comet3.m,
scripts/plot/draw/compass.m, scripts/plot/draw/contour.m,
scripts/plot/draw/contour3.m, scripts/plot/draw/contourc.m,
scripts/plot/draw/contourf.m, scripts/plot/draw/cylinder.m,
scripts/plot/draw/ellipsoid.m, scripts/plot/draw/errorbar.m,
scripts/plot/draw/ezcontour.m, scripts/plot/draw/ezcontourf.m,
scripts/plot/draw/ezmesh.m, scripts/plot/draw/ezmeshc.m,
scripts/plot/draw/ezplot.m, scripts/plot/draw/ezplot3.m,
scripts/plot/draw/ezpolar.m, scripts/plot/draw/ezsurf.m,
scripts/plot/draw/ezsurfc.m, scripts/plot/draw/feather.m,
scripts/plot/draw/fill.m, scripts/plot/draw/fplot.m, scripts/plot/draw/hist.m,
scripts/plot/draw/isocaps.m, scripts/plot/draw/isocolors.m,
scripts/plot/draw/isonormals.m, scripts/plot/draw/isosurface.m,
scripts/plot/draw/light.m, scripts/plot/draw/line.m,
scripts/plot/draw/loglog.m, scripts/plot/draw/loglogerr.m,
scripts/plot/draw/mesh.m, scripts/plot/draw/meshc.m, scripts/plot/draw/meshz.m,
scripts/plot/draw/pareto.m, scripts/plot/draw/patch.m,
scripts/plot/draw/pcolor.m, scripts/plot/draw/peaks.m, scripts/plot/draw/pie.m,
scripts/plot/draw/pie3.m, scripts/plot/draw/plot.m, scripts/plot/draw/plot3.m,
scripts/plot/draw/plotmatrix.m, scripts/plot/draw/plotyy.m,
scripts/plot/draw/polar.m, scripts/plot/draw/private/__add_datasource__.m,
scripts/plot/draw/private/__bar__.m,
scripts/plot/draw/private/__calc_isovalue_from_data__.m,
scripts/plot/draw/private/__contour__.m,
scripts/plot/draw/private/__errplot__.m,
scripts/plot/draw/private/__ezplot__.m,
scripts/plot/draw/private/__interp_cube__.m,
scripts/plot/draw/private/__line__.m,
scripts/plot/draw/private/__marching_cube__.m,
scripts/plot/draw/private/__patch__.m, scripts/plot/draw/private/__pie__.m,
scripts/plot/draw/private/__plt__.m, scripts/plot/draw/private/__quiver__.m,
scripts/plot/draw/private/__rotate_around_axis__.m,
scripts/plot/draw/private/__scatter__.m, scripts/plot/draw/private/__stem__.m,
scripts/plot/draw/private/__unite_shared_vertices__.m,
scripts/plot/draw/quiver.m, scripts/plot/draw/quiver3.m,
scripts/plot/draw/rectangle.m, scripts/plot/draw/reducepatch.m,
scripts/plot/draw/reducevolume.m, scripts/plot/draw/ribbon.m,
scripts/plot/draw/rose.m, scripts/plot/draw/scatter.m,
scripts/plot/draw/scatter3.m, scripts/plot/draw/semilogx.m,
scripts/plot/draw/semilogxerr.m, scripts/plot/draw/semilogy.m,
scripts/plot/draw/semilogyerr.m, scripts/plot/draw/shrinkfaces.m,
scripts/plot/draw/slice.m, scripts/plot/draw/smooth3.m,
scripts/plot/draw/sombrero.m, scripts/plot/draw/sphere.m,
scripts/plot/draw/stairs.m, scripts/plot/draw/stem.m,
scripts/plot/draw/stem3.m, scripts/plot/draw/stemleaf.m,
scripts/plot/draw/surf.m, scripts/plot/draw/surface.m,
scripts/plot/draw/surfc.m, scripts/plot/draw/surfl.m,
scripts/plot/draw/surfnorm.m, scripts/plot/draw/tetramesh.m,
scripts/plot/draw/trimesh.m, scripts/plot/draw/triplot.m,
scripts/plot/draw/trisurf.m, scripts/plot/draw/waterfall.m,
scripts/plot/util/__actual_axis_position__.m,
scripts/plot/util/__default_plot_options__.m,
scripts/plot/util/__gnuplot_drawnow__.m,
scripts/plot/util/__next_line_color__.m,
scripts/plot/util/__next_line_style__.m, scripts/plot/util/__opengl_info__.m,
scripts/plot/util/__plt_get_axis_arg__.m, scripts/plot/util/__pltopt__.m,
scripts/plot/util/allchild.m, scripts/plot/util/ancestor.m,
scripts/plot/util/axes.m, scripts/plot/util/cla.m, scripts/plot/util/clf.m,
scripts/plot/util/close.m, scripts/plot/util/closereq.m,
scripts/plot/util/colstyle.m, scripts/plot/util/copyobj.m,
scripts/plot/util/figure.m, scripts/plot/util/findall.m,
scripts/plot/util/findfigs.m, scripts/plot/util/findobj.m,
scripts/plot/util/frame2im.m, scripts/plot/util/gca.m,
scripts/plot/util/gcbf.m, scripts/plot/util/gcbo.m, scripts/plot/util/gcf.m,
scripts/plot/util/gco.m, scripts/plot/util/ginput.m,
scripts/plot/util/gnuplot_binary.in.m, scripts/plot/util/graphics_toolkit.m,
scripts/plot/util/hdl2struct.m, scripts/plot/util/hggroup.m,
scripts/plot/util/hgload.m, scripts/plot/util/hgsave.m,
scripts/plot/util/hold.m, scripts/plot/util/im2frame.m,
scripts/plot/util/isaxes.m, scripts/plot/util/isfigure.m,
scripts/plot/util/ishghandle.m, scripts/plot/util/ishold.m,
scripts/plot/util/isprop.m, scripts/plot/util/linkaxes.m,
scripts/plot/util/linkprop.m, scripts/plot/util/meshgrid.m,
scripts/plot/util/ndgrid.m, scripts/plot/util/newplot.m,
scripts/plot/util/pan.m, scripts/plot/util/print.m, scripts/plot/util/printd.m,
scripts/plot/util/private/__add_default_menu__.m,
scripts/plot/util/private/__ghostscript__.m,
scripts/plot/util/private/__gnuplot_draw_axes__.m,
scripts/plot/util/private/__gnuplot_draw_figure__.m,
scripts/plot/util/private/__gnuplot_get_var__.m,
scripts/plot/util/private/__gnuplot_ginput__.m,
scripts/plot/util/private/__gnuplot_has_feature__.m,
scripts/plot/util/private/__gnuplot_has_terminal__.m,
scripts/plot/util/private/__gnuplot_open_stream__.m,
scripts/plot/util/private/__gnuplot_print__.m,
scripts/plot/util/private/__gnuplot_version__.m,
scripts/plot/util/private/__opengl_print__.m,
scripts/plot/util/private/__print_parse_opts__.m, scripts/plot/util/refresh.m,
scripts/plot/util/refreshdata.m, scripts/plot/util/rotate.m,
scripts/plot/util/rotate3d.m, scripts/plot/util/saveas.m,
scripts/plot/util/shg.m, scripts/plot/util/struct2hdl.m,
scripts/plot/util/subplot.m, scripts/plot/util/zoom.m,
scripts/polynomial/compan.m, scripts/polynomial/conv.m,
scripts/polynomial/deconv.m, scripts/polynomial/mkpp.m,
scripts/polynomial/mpoles.m, scripts/polynomial/padecoef.m,
scripts/polynomial/pchip.m, scripts/polynomial/poly.m,
scripts/polynomial/polyaffine.m, scripts/polynomial/polyder.m,
scripts/polynomial/polyeig.m, scripts/polynomial/polyfit.m,
scripts/polynomial/polygcd.m, scripts/polynomial/polyint.m,
scripts/polynomial/polyout.m, scripts/polynomial/polyreduce.m,
scripts/polynomial/polyval.m, scripts/polynomial/polyvalm.m,
scripts/polynomial/ppder.m, scripts/polynomial/ppint.m,
scripts/polynomial/ppjumps.m, scripts/polynomial/ppval.m,
scripts/polynomial/residue.m, scripts/polynomial/roots.m,
scripts/polynomial/spline.m, scripts/polynomial/splinefit.m,
scripts/polynomial/unmkpp.m, scripts/prefs/addpref.m, scripts/prefs/getpref.m,
scripts/prefs/ispref.m, scripts/prefs/prefdir.m, scripts/prefs/preferences.m,
scripts/prefs/private/loadprefs.m, scripts/prefs/private/prefsfile.m,
scripts/prefs/private/saveprefs.m, scripts/prefs/rmpref.m,
scripts/prefs/setpref.m, scripts/profiler/html/style.css,
scripts/profiler/profexplore.m, scripts/profiler/profexport.m,
scripts/profiler/profile.m, scripts/profiler/profshow.m,
scripts/set/intersect.m, scripts/set/ismember.m, scripts/set/powerset.m,
scripts/set/private/validsetargs.m, scripts/set/setdiff.m,
scripts/set/setxor.m, scripts/set/union.m, scripts/set/unique.m,
scripts/signal/arch_fit.m, scripts/signal/arch_rnd.m,
scripts/signal/arch_test.m, scripts/signal/arma_rnd.m,
scripts/signal/autoreg_matrix.m, scripts/signal/bartlett.m,
scripts/signal/blackman.m, scripts/signal/detrend.m, scripts/signal/diffpara.m,
scripts/signal/durbinlevinson.m, scripts/signal/fftconv.m,
scripts/signal/fftfilt.m, scripts/signal/fftshift.m, scripts/signal/filter2.m,
scripts/signal/fractdiff.m, scripts/signal/freqz.m,
scripts/signal/freqz_plot.m, scripts/signal/hamming.m,
scripts/signal/hanning.m, scripts/signal/hurst.m, scripts/signal/ifftshift.m,
scripts/signal/periodogram.m, scripts/signal/private/rectangle_lw.m,
scripts/signal/private/rectangle_sw.m, scripts/signal/private/triangle_lw.m,
scripts/signal/private/triangle_sw.m, scripts/signal/sinc.m,
scripts/signal/sinetone.m, scripts/signal/sinewave.m,
scripts/signal/spectral_adf.m, scripts/signal/spectral_xdf.m,
scripts/signal/spencer.m, scripts/signal/stft.m, scripts/signal/synthesis.m,
scripts/signal/unwrap.m, scripts/signal/yulewalker.m, scripts/sparse/bicg.m,
scripts/sparse/bicgstab.m, scripts/sparse/cgs.m, scripts/sparse/colperm.m,
scripts/sparse/eigs.m, scripts/sparse/etreeplot.m, scripts/sparse/gmres.m,
scripts/sparse/gplot.m, scripts/sparse/ichol.m, scripts/sparse/ilu.m,
scripts/sparse/nonzeros.m, scripts/sparse/pcg.m, scripts/sparse/pcr.m,
scripts/sparse/private/__sprand__.m, scripts/sparse/qmr.m,
scripts/sparse/spaugment.m, scripts/sparse/spconvert.m,
scripts/sparse/spdiags.m, scripts/sparse/speye.m, scripts/sparse/spfun.m,
scripts/sparse/spones.m, scripts/sparse/sprand.m, scripts/sparse/sprandn.m,
scripts/sparse/sprandsym.m, scripts/sparse/spstats.m, scripts/sparse/spy.m,
scripts/sparse/svds.m, scripts/sparse/treelayout.m, scripts/sparse/treeplot.m,
scripts/specfun/bessel.m, scripts/specfun/beta.m, scripts/specfun/betaln.m,
scripts/specfun/ellipke.m, scripts/specfun/expint.m, scripts/specfun/factor.m,
scripts/specfun/factorial.m, scripts/specfun/isprime.m, scripts/specfun/lcm.m,
scripts/specfun/legendre.m, scripts/specfun/nchoosek.m,
scripts/specfun/nthroot.m, scripts/specfun/perms.m, scripts/specfun/pow2.m,
scripts/specfun/primes.m, scripts/specfun/reallog.m, scripts/specfun/realpow.m,
scripts/specfun/realsqrt.m, scripts/special-matrix/gallery.m,
scripts/special-matrix/hadamard.m, scripts/special-matrix/hankel.m,
scripts/special-matrix/hilb.m, scripts/special-matrix/invhilb.m,
scripts/special-matrix/magic.m, scripts/special-matrix/pascal.m,
scripts/special-matrix/rosser.m, scripts/special-matrix/toeplitz.m,
scripts/special-matrix/vander.m, scripts/special-matrix/wilkinson.m,
scripts/startup/__finish__.m, scripts/statistics/base/center.m,
scripts/statistics/base/cloglog.m, scripts/statistics/base/corr.m,
scripts/statistics/base/cov.m, scripts/statistics/base/gls.m,
scripts/statistics/base/histc.m, scripts/statistics/base/iqr.m,
scripts/statistics/base/kendall.m, scripts/statistics/base/kurtosis.m,
scripts/statistics/base/logit.m, scripts/statistics/base/lscov.m,
scripts/statistics/base/mean.m, scripts/statistics/base/meansq.m,
scripts/statistics/base/median.m, scripts/statistics/base/mode.m,
scripts/statistics/base/moment.m, scripts/statistics/base/ols.m,
scripts/statistics/base/ppplot.m, scripts/statistics/base/prctile.m,
scripts/statistics/base/probit.m, scripts/statistics/base/qqplot.m,
scripts/statistics/base/quantile.m, scripts/statistics/base/range.m,
scripts/statistics/base/ranks.m, scripts/statistics/base/run_count.m,
scripts/statistics/base/runlength.m, scripts/statistics/base/skewness.m,
scripts/statistics/base/spearman.m, scripts/statistics/base/statistics.m,
scripts/statistics/base/std.m, scripts/statistics/base/table.m,
scripts/statistics/base/var.m, scripts/statistics/base/zscore.m,
scripts/statistics/distributions/betacdf.m,
scripts/statistics/distributions/betainv.m,
scripts/statistics/distributions/betapdf.m,
scripts/statistics/distributions/betarnd.m,
scripts/statistics/distributions/binocdf.m,
scripts/statistics/distributions/binoinv.m,
scripts/statistics/distributions/binopdf.m,
scripts/statistics/distributions/binornd.m,
scripts/statistics/distributions/cauchy_cdf.m,
scripts/statistics/distributions/cauchy_inv.m,
scripts/statistics/distributions/cauchy_pdf.m,
scripts/statistics/distributions/cauchy_rnd.m,
scripts/statistics/distributions/chi2cdf.m,
scripts/statistics/distributions/chi2inv.m,
scripts/statistics/distributions/chi2pdf.m,
scripts/statistics/distributions/chi2rnd.m,
scripts/statistics/distributions/discrete_cdf.m,
scripts/statistics/distributions/discrete_inv.m,
scripts/statistics/distributions/discrete_pdf.m,
scripts/statistics/distributions/discrete_rnd.m,
scripts/statistics/distributions/empirical_cdf.m,
scripts/statistics/distributions/empirical_inv.m,
scripts/statistics/distributions/empirical_pdf.m,
scripts/statistics/distributions/empirical_rnd.m,
scripts/statistics/distributions/expcdf.m,
scripts/statistics/distributions/expinv.m,
scripts/statistics/distributions/exppdf.m,
scripts/statistics/distributions/exprnd.m,
scripts/statistics/distributions/fcdf.m,
scripts/statistics/distributions/finv.m,
scripts/statistics/distributions/fpdf.m,
scripts/statistics/distributions/frnd.m,
scripts/statistics/distributions/gamcdf.m,
scripts/statistics/distributions/gaminv.m,
scripts/statistics/distributions/gampdf.m,
scripts/statistics/distributions/gamrnd.m,
scripts/statistics/distributions/geocdf.m,
scripts/statistics/distributions/geoinv.m,
scripts/statistics/distributions/geopdf.m,
scripts/statistics/distributions/geornd.m,
scripts/statistics/distributions/hygecdf.m,
scripts/statistics/distributions/hygeinv.m,
scripts/statistics/distributions/hygepdf.m,
scripts/statistics/distributions/hygernd.m,
scripts/statistics/distributions/kolmogorov_smirnov_cdf.m,
scripts/statistics/distributions/laplace_cdf.m,
scripts/statistics/distributions/laplace_inv.m,
scripts/statistics/distributions/laplace_pdf.m,
scripts/statistics/distributions/laplace_rnd.m,
scripts/statistics/distributions/logistic_cdf.m,
scripts/statistics/distributions/logistic_inv.m,
scripts/statistics/distributions/logistic_pdf.m,
scripts/statistics/distributions/logistic_rnd.m,
scripts/statistics/distributions/logncdf.m,
scripts/statistics/distributions/logninv.m,
scripts/statistics/distributions/lognpdf.m,
scripts/statistics/distributions/lognrnd.m,
scripts/statistics/distributions/nbincdf.m,
scripts/statistics/distributions/nbininv.m,
scripts/statistics/distributions/nbinpdf.m,
scripts/statistics/distributions/nbinrnd.m,
scripts/statistics/distributions/normcdf.m,
scripts/statistics/distributions/norminv.m,
scripts/statistics/distributions/normpdf.m,
scripts/statistics/distributions/normrnd.m,
scripts/statistics/distributions/poisscdf.m,
scripts/statistics/distributions/poissinv.m,
scripts/statistics/distributions/poisspdf.m,
scripts/statistics/distributions/poissrnd.m,
scripts/statistics/distributions/stdnormal_cdf.m,
scripts/statistics/distributions/stdnormal_inv.m,
scripts/statistics/distributions/stdnormal_pdf.m,
scripts/statistics/distributions/stdnormal_rnd.m,
scripts/statistics/distributions/tcdf.m,
scripts/statistics/distributions/tinv.m,
scripts/statistics/distributions/tpdf.m,
scripts/statistics/distributions/trnd.m,
scripts/statistics/distributions/unidcdf.m,
scripts/statistics/distributions/unidinv.m,
scripts/statistics/distributions/unidpdf.m,
scripts/statistics/distributions/unidrnd.m,
scripts/statistics/distributions/unifcdf.m,
scripts/statistics/distributions/unifinv.m,
scripts/statistics/distributions/unifpdf.m,
scripts/statistics/distributions/unifrnd.m,
scripts/statistics/distributions/wblcdf.m,
scripts/statistics/distributions/wblinv.m,
scripts/statistics/distributions/wblpdf.m,
scripts/statistics/distributions/wblrnd.m,
scripts/statistics/distributions/wienrnd.m,
scripts/statistics/models/logistic_regression.m,
scripts/statistics/models/private/logistic_regression_derivatives.m,
scripts/statistics/models/private/logistic_regression_likelihood.m,
scripts/statistics/tests/anova.m, scripts/statistics/tests/bartlett_test.m,
scripts/statistics/tests/chisquare_test_homogeneity.m,
scripts/statistics/tests/chisquare_test_independence.m,
scripts/statistics/tests/cor_test.m,
scripts/statistics/tests/f_test_regression.m,
scripts/statistics/tests/hotelling_test.m,
scripts/statistics/tests/hotelling_test_2.m,
scripts/statistics/tests/kolmogorov_smirnov_test.m,
scripts/statistics/tests/kolmogorov_smirnov_test_2.m,
scripts/statistics/tests/kruskal_wallis_test.m,
scripts/statistics/tests/manova.m, scripts/statistics/tests/mcnemar_test.m,
scripts/statistics/tests/prop_test_2.m, scripts/statistics/tests/run_test.m,
scripts/statistics/tests/sign_test.m, scripts/statistics/tests/t_test.m,
scripts/statistics/tests/t_test_2.m,
scripts/statistics/tests/t_test_regression.m,
scripts/statistics/tests/u_test.m, scripts/statistics/tests/var_test.m,
scripts/statistics/tests/welch_test.m,
scripts/statistics/tests/wilcoxon_test.m, scripts/statistics/tests/z_test.m,
scripts/statistics/tests/z_test_2.m, scripts/strings/base2dec.m,
scripts/strings/bin2dec.m, scripts/strings/blanks.m, scripts/strings/cstrcat.m,
scripts/strings/deblank.m, scripts/strings/dec2base.m,
scripts/strings/dec2bin.m, scripts/strings/dec2hex.m,
scripts/strings/findstr.m, scripts/strings/hex2dec.m, scripts/strings/index.m,
scripts/strings/isletter.m, scripts/strings/isstrprop.m,
scripts/strings/mat2str.m, scripts/strings/ostrsplit.m,
scripts/strings/regexptranslate.m, scripts/strings/rindex.m,
scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strchr.m,
scripts/strings/strjoin.m, scripts/strings/strjust.m,
scripts/strings/strmatch.m, scripts/strings/strsplit.m,
scripts/strings/strtok.m, scripts/strings/strtrim.m,
scripts/strings/strtrunc.m, scripts/strings/substr.m,
scripts/strings/untabify.m, scripts/strings/validatestring.m,
scripts/testfun/__have_feature__.m, scripts/testfun/__printf_assert__.m,
scripts/testfun/__prog_output_assert__.m, scripts/testfun/__run_test_suite__.m,
scripts/testfun/assert.m, scripts/testfun/demo.m, scripts/testfun/example.m,
scripts/testfun/fail.m, scripts/testfun/private/compare_plot_demos.m,
scripts/testfun/private/dump_demos.m,
scripts/testfun/private/html_compare_plot_demos.m, scripts/testfun/rundemos.m,
scripts/testfun/runtests.m, scripts/testfun/speed.m, scripts/testfun/test.m,
scripts/time/addtodate.m, scripts/time/asctime.m, scripts/time/calendar.m,
scripts/time/clock.m, scripts/time/ctime.m, scripts/time/date.m,
scripts/time/datenum.m, scripts/time/datestr.m, scripts/time/datevec.m,
scripts/time/eomday.m, scripts/time/etime.m, scripts/time/is_leap_year.m,
scripts/time/now.m, scripts/time/weekday.m, src/display-available.c,
src/display-available.h, src/main-cli.cc, src/main-gui.cc, src/main.in.cc,
src/mkoctfile.in.cc, src/octave-build-info.h, src/octave-build-info.in.cc,
src/octave-config.in.cc, src/shared-fcns.h, test/args.tst,
test/classdef/classdef.tst, test/classes/classes.tst, test/colormaps.tst,
test/complex.tst, test/ctor-vs-method/ctor-vs-method.tst, test/diag-perm.tst,
test/error.tst, test/eval-catch.tst,
test/fcn-handle-derived-resolution/fcn-handle-derived-resolution.tst,
test/fntests.m, test/for.tst, test/func.tst, test/global.tst, test/if.tst,
test/index.tst, test/io.tst, test/jit.tst, test/line-continue.tst,
test/logical-index.tst, test/nest/nest.tst, test/null-assign.tst,
test/parser.tst, test/prefer.tst, test/range.tst, test/recursion.tst,
test/return.tst, test/slice.tst, test/struct.tst, test/switch.tst,
test/system.tst, test/transpose.tst, test/try.tst, test/unwind.tst,
test/while.tst:
Use the same Copyright formatting throughout Octave.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 13 Nov 2016 20:33:47 -0800 |
parents | e07fa946f763 |
children | 9c6661004167 |
rev | line source |
---|---|
1829 | 1 /* |
1 | 2 |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
22300
diff
changeset
|
3 Copyright (C) 1993-2016 John W. Eaton |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
4 Copyright (C) 2009 David Grundberg |
11523 | 5 Copyright (C) 2009-2010 VZLU Prague |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6 Copyright (C) 2016 Oliver Heimlich |
1 | 7 |
8 This file is part of Octave. | |
9 | |
10 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22712
diff
changeset
|
11 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22712
diff
changeset
|
12 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22712
diff
changeset
|
13 (at your option) any later version. |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22712
diff
changeset
|
14 |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22712
diff
changeset
|
15 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22712
diff
changeset
|
16 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22712
diff
changeset
|
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22712
diff
changeset
|
18 GNU General Public License for more details. |
1 | 19 |
20 You should have received a copy of the GNU General Public License | |
7016 | 21 along with Octave; see the file COPYING. If not, see |
22 <http://www.gnu.org/licenses/>. | |
1 | 23 |
24 */ | |
25 | |
26 // Parser for Octave. | |
27 | |
767 | 28 // C decarations. |
29 | |
1 | 30 %{ |
21023
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
31 |
1 | 32 #define YYDEBUG 1 |
33 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21707
diff
changeset
|
34 #if defined (HAVE_CONFIG_H) |
22003
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
35 # include "config.h" |
240 | 36 #endif |
37 | |
3178 | 38 #include <cassert> |
10463
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
39 #include <cstdio> |
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
40 #include <cstdlib> |
2427 | 41 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
42 #include <iostream> |
5484 | 43 #include <map> |
5765 | 44 #include <sstream> |
5484 | 45 |
1 | 46 #include "Matrix.h" |
3021 | 47 #include "cmd-edit.h" |
48 #include "cmd-hist.h" | |
49 #include "file-ops.h" | |
50 #include "file-stat.h" | |
4243 | 51 #include "oct-env.h" |
3712 | 52 #include "oct-time.h" |
4171 | 53 #include "quit.h" |
1 | 54 |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
22003
diff
changeset
|
55 #include "Cell.h" |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
22003
diff
changeset
|
56 #include "call-stack.h" |
3665 | 57 #include "comment-list.h" |
4243 | 58 #include "defaults.h" |
2166 | 59 #include "defun.h" |
4243 | 60 #include "dirfns.h" |
3021 | 61 #include "dynamic-ld.h" |
1351 | 62 #include "error.h" |
63 #include "input.h" | |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
64 #include "interpreter.h" |
1351 | 65 #include "lex.h" |
5832 | 66 #include "load-path.h" |
1743 | 67 #include "oct-hist.h" |
5626 | 68 #include "oct-map.h" |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
69 #include "ov-classdef.h" |
4935 | 70 #include "ov-fcn-handle.h" |
2970 | 71 #include "ov-usr-fcn.h" |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
72 #include "ov-null-mat.h" |
1351 | 73 #include "pager.h" |
74 #include "parse.h" | |
2987 | 75 #include "pt-all.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
76 #include "pt-eval.h" |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
77 #include "pt-funcall.h" |
1351 | 78 #include "symtab.h" |
79 #include "token.h" | |
3021 | 80 #include "unwind-prot.h" |
1 | 81 #include "utils.h" |
1351 | 82 #include "variables.h" |
1 | 83 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
84 // oct-parse.h must be included after pt-all.h |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
85 #include <oct-parse.h> |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
86 |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
87 extern int octave_lex (YYSTYPE *, void *); |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
88 |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
89 // Global access to currently active lexer. |
21066
258c787cd9ce
maint: Use "FIXME:" consistently in code base.
Rik <rik@octave.org>
parents:
21065
diff
changeset
|
90 // FIXME: to be removed after more parser+lexer refactoring. |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
91 octave::base_lexer *LEXER = 0; |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
92 |
3021 | 93 // TRUE means we printed messages about reading startup files. |
94 bool reading_startup_message_printed = false; | |
95 | |
5484 | 96 // List of autoloads (function -> file mapping). |
97 static std::map<std::string, std::string> autoload_map; | |
98 | |
496 | 99 // Forward declarations for some functions defined at the bottom of |
100 // the file. | |
101 | |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
102 static void yyerror (octave::base_parser& parser, const char *s); |
1 | 103 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
104 #define lexer parser.lexer |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
105 #define scanner lexer.scanner |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
106 |
21023
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
107 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
108 // Disable this warning for code that is generated by Bison, including |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
109 // grammar rules. Push the current state so we can restore the warning |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
110 // state prior to functions we define at the bottom of the file. |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
111 #pragma GCC diagnostic push |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
112 #pragma GCC diagnostic ignored "-Wold-style-cast" |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
113 #endif |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
114 |
1 | 115 %} |
116 | |
666 | 117 // Bison declarations. |
118 | |
17743
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
119 // The grammar currently has 14 shift/reduce conflicts. Ensure that |
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
120 // we notice if that number changes. |
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
121 |
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
122 %expect 14 |
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
123 |
18974
d8abf813c69f
handle changes in bison 3.x
John W. Eaton <jwe@octave.org>
parents:
18531
diff
changeset
|
124 %API_PREFIX_DECL% |
4753 | 125 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
126 // We are using the pure parser interface and the reentrant lexer |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
127 // interface but the Octave parser and lexer are NOT properly |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
128 // reentrant because both still use many global variables. It should be |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
129 // safe to create a parser object and call it while anotehr parser |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
130 // object is active (to parse a callback function while the main |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
131 // interactive parser is waiting for input, for example) if you take |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
132 // care to properly save and restore (typically with an unwind_protect |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
133 // object) relevant global values before and after the nested call. |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
134 |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
135 %define api.pure |
16174
39096b290a2f
check syntax used to enable bison push/pull parser
John W. Eaton <jwe@octave.org>
parents:
16167
diff
changeset
|
136 %PUSH_PULL_DECL% |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
137 %parse-param { octave::base_parser& parser } |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
138 %lex-param { void *scanner } |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
139 |
1 | 140 %union |
141 { | |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
142 int dummy_type; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
143 |
2891 | 144 // The type of the basic tokens returned by the lexer. |
143 | 145 token *tok_val; |
146 | |
3665 | 147 // Comment strings that we need to deal with mid-rule. |
148 octave_comment_list *comment_type; | |
149 | |
2891 | 150 // Types for the nonterminals we generate. |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
151 char punct_type; |
1 | 152 tree *tree_type; |
1829 | 153 tree_matrix *tree_matrix_type; |
3351 | 154 tree_cell *tree_cell_type; |
496 | 155 tree_expression *tree_expression_type; |
2375 | 156 tree_constant *tree_constant_type; |
4342 | 157 tree_fcn_handle *tree_fcn_handle_type; |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
158 tree_funcall *tree_funcall_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
159 tree_function_def *tree_function_def_type; |
5861 | 160 tree_anon_fcn_handle *tree_anon_fcn_handle_type; |
1 | 161 tree_identifier *tree_identifier_type; |
162 tree_index_expression *tree_index_expression_type; | |
163 tree_colon_expression *tree_colon_expression_type; | |
164 tree_argument_list *tree_argument_list_type; | |
165 tree_parameter_list *tree_parameter_list_type; | |
166 tree_command *tree_command_type; | |
167 tree_if_command *tree_if_command_type; | |
578 | 168 tree_if_clause *tree_if_clause_type; |
169 tree_if_command_list *tree_if_command_list_type; | |
2764 | 170 tree_switch_command *tree_switch_command_type; |
171 tree_switch_case *tree_switch_case_type; | |
172 tree_switch_case_list *tree_switch_case_list_type; | |
2846 | 173 tree_decl_elt *tree_decl_elt_type; |
174 tree_decl_init_list *tree_decl_init_list_type; | |
175 tree_decl_command *tree_decl_command_type; | |
578 | 176 tree_statement *tree_statement_type; |
177 tree_statement_list *tree_statement_list_type; | |
2891 | 178 octave_user_function *octave_user_function_type; |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
179 |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
180 tree_classdef *tree_classdef_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
181 tree_classdef_attribute* tree_classdef_attribute_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
182 tree_classdef_attribute_list* tree_classdef_attribute_list_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
183 tree_classdef_superclass* tree_classdef_superclass_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
184 tree_classdef_superclass_list* tree_classdef_superclass_list_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
185 tree_classdef_body* tree_classdef_body_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
186 tree_classdef_property* tree_classdef_property_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
187 tree_classdef_property_list* tree_classdef_property_list_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
188 tree_classdef_properties_block* tree_classdef_properties_block_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
189 tree_classdef_methods_list* tree_classdef_methods_list_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
190 tree_classdef_methods_block* tree_classdef_methods_block_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
191 tree_classdef_event* tree_classdef_event_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
192 tree_classdef_events_list* tree_classdef_events_list_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
193 tree_classdef_events_block* tree_classdef_events_block_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
194 tree_classdef_enum* tree_classdef_enum_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
195 tree_classdef_enum_list* tree_classdef_enum_list_type; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
196 tree_classdef_enum_block* tree_classdef_enum_block_type; |
1 | 197 } |
198 | |
143 | 199 // Tokens with line and column information. |
200 %token <tok_val> '=' ':' '-' '+' '*' '/' | |
4018 | 201 %token <tok_val> ADD_EQ SUB_EQ MUL_EQ DIV_EQ LEFTDIV_EQ POW_EQ |
202 %token <tok_val> EMUL_EQ EDIV_EQ ELEFTDIV_EQ EPOW_EQ AND_EQ OR_EQ | |
428 | 203 %token <tok_val> EXPR_AND_AND EXPR_OR_OR |
143 | 204 %token <tok_val> EXPR_AND EXPR_OR EXPR_NOT |
205 %token <tok_val> EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT | |
1276 | 206 %token <tok_val> LEFTDIV EMUL EDIV ELEFTDIV EPLUS EMINUS |
16284
09881dab3aaf
* lex.ll, oct-parse.in.yy (HERMITIAN): Rename token from QUOTE.
John W. Eaton <jwe@octave.org>
parents:
16279
diff
changeset
|
207 %token <tok_val> HERMITIAN TRANSPOSE |
143 | 208 %token <tok_val> PLUS_PLUS MINUS_MINUS POW EPOW |
209 %token <tok_val> NUM IMAG_NUM | |
2970 | 210 %token <tok_val> STRUCT_ELT |
2883 | 211 %token <tok_val> NAME |
143 | 212 %token <tok_val> END |
5279 | 213 %token <tok_val> DQ_STRING SQ_STRING |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
214 %token <tok_val> FOR PARFOR WHILE DO UNTIL |
1491 | 215 %token <tok_val> IF ELSEIF ELSE |
2764 | 216 %token <tok_val> SWITCH CASE OTHERWISE |
1491 | 217 %token <tok_val> BREAK CONTINUE FUNC_RET |
924 | 218 %token <tok_val> UNWIND CLEANUP |
1489 | 219 %token <tok_val> TRY CATCH |
14294
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14293
diff
changeset
|
220 %token <tok_val> GLOBAL PERSISTENT |
4342 | 221 %token <tok_val> FCN_HANDLE |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
222 %token <tok_val> CLASSDEF |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
223 %token <tok_val> PROPERTIES METHODS EVENTS ENUMERATION |
9476 | 224 %token <tok_val> METAQUERY |
225 %token <tok_val> SUPERCLASSREF | |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
226 %token <tok_val> FQ_IDENT |
9476 | 227 %token <tok_val> GET SET |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
228 %token <tok_val> FCN |
21064
a9f2c2d72892
handle lexical errors as parser errors (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21063
diff
changeset
|
229 %token <tok_val> LEXICAL_ERROR |
1 | 230 |
143 | 231 // Other tokens. |
21064
a9f2c2d72892
handle lexical errors as parser errors (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21063
diff
changeset
|
232 %token<dummy_type> END_OF_INPUT |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
233 %token<dummy_type> INPUT_FILE |
7587
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7562
diff
changeset
|
234 // %token VARARGIN VARARGOUT |
1 | 235 |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
236 %token<dummy_type> '(' ')' '[' ']' '{' '}' '.' ',' ';' '@' '\n' |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
237 |
143 | 238 // Nonterminals we construct. |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
239 %type <dummy_type> indirect_ref_op decl_param_init push_fcn_symtab |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
240 %type <dummy_type> param_list_beg param_list_end stmt_begin parse_error |
16644
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
241 %type <comment_type> stash_comment |
17657
df266c923b83
delete unnecessary tok_type semantic value in parser
John W. Eaton <jwe@octave.org>
parents:
17656
diff
changeset
|
242 %type <tok_val> function_beg classdef_beg |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
243 %type <punct_type> sep_no_nl opt_sep_no_nl nl opt_nl sep opt_sep |
578 | 244 %type <tree_type> input |
5861 | 245 %type <tree_constant_type> string constant magic_colon |
246 %type <tree_anon_fcn_handle_type> anon_fcn_handle | |
4342 | 247 %type <tree_fcn_handle_type> fcn_handle |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
248 %type <tree_matrix_type> matrix_rows |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
249 %type <tree_cell_type> cell_rows |
5102 | 250 %type <tree_expression_type> matrix cell |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
251 %type <tree_expression_type> primary_expr oper_expr power_expr |
4207 | 252 %type <tree_expression_type> simple_expr colon_expr assign_expr expression |
17283
e6c0ac8ce5b6
eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
253 %type <tree_identifier_type> identifier fcn_name magic_tilde |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
254 %type <tree_funcall_type> superclass_identifier meta_identifier |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
255 %type <octave_user_function_type> function1 function2 |
2970 | 256 %type <tree_index_expression_type> word_list_cmd |
257 %type <tree_colon_expression_type> colon_expr1 | |
3351 | 258 %type <tree_argument_list_type> arg_list word_list assign_lhs |
259 %type <tree_argument_list_type> cell_or_matrix_row | |
4935 | 260 %type <tree_parameter_list_type> param_list param_list1 param_list2 |
723 | 261 %type <tree_parameter_list_type> return_list return_list1 |
2970 | 262 %type <tree_command_type> command select_command loop_command |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
263 %type <tree_command_type> jump_command except_command |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
264 %type <tree_function_def_type> function |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
265 %type <tree_classdef_type> classdef |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
266 %type <tree_command_type> file |
578 | 267 %type <tree_if_command_type> if_command |
268 %type <tree_if_clause_type> elseif_clause else_clause | |
269 %type <tree_if_command_list_type> if_cmd_list1 if_cmd_list | |
2764 | 270 %type <tree_switch_command_type> switch_command |
271 %type <tree_switch_case_type> switch_case default_case | |
272 %type <tree_switch_case_list_type> case_list1 case_list | |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
273 %type <tree_decl_elt_type> decl2 param_list_elt |
2846 | 274 %type <tree_decl_init_list_type> decl1 |
275 %type <tree_decl_command_type> declaration | |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
276 %type <tree_statement_type> statement function_end |
627 | 277 %type <tree_statement_list_type> simple_list simple_list1 list list1 |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
278 %type <tree_statement_list_type> opt_list |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
279 %type <tree_classdef_attribute_type> attr |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
280 %type <tree_classdef_attribute_list_type> attr_list opt_attr_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
281 %type <tree_classdef_superclass_type> superclass |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
282 %type <tree_classdef_superclass_list_type> superclass_list opt_superclass_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
283 %type <tree_classdef_body_type> class_body |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
284 %type <tree_classdef_property_type> class_property |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
285 %type <tree_classdef_property_list_type> property_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
286 %type <tree_classdef_properties_block_type> properties_block |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
287 %type <tree_classdef_methods_list_type> methods_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
288 %type <tree_classdef_methods_block_type> methods_block |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
289 %type <tree_classdef_event_type> class_event |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
290 %type <tree_classdef_events_list_type> events_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
291 %type <tree_classdef_events_block_type> events_block |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
292 %type <tree_classdef_enum_type> class_enum |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
293 %type <tree_classdef_enum_list_type> enum_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
294 %type <tree_classdef_enum_block_type> enum_block |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
295 %type <tree_function_def_type> method_decl method |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
296 %type <octave_user_function_type> method_decl1 |
1 | 297 |
143 | 298 // Precedence and associativity. |
21294
3d375b0905a0
eliminate unused << and >> operators from Octave scripting language
John W. Eaton <jwe@octave.org>
parents:
21159
diff
changeset
|
299 %right '=' ADD_EQ SUB_EQ MUL_EQ DIV_EQ LEFTDIV_EQ POW_EQ EMUL_EQ EDIV_EQ ELEFTDIV_EQ EPOW_EQ OR_EQ AND_EQ |
4023 | 300 %left EXPR_OR_OR |
301 %left EXPR_AND_AND | |
302 %left EXPR_OR | |
303 %left EXPR_AND | |
1 | 304 %left EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT |
305 %left ':' | |
1276 | 306 %left '-' '+' EPLUS EMINUS |
1 | 307 %left '*' '/' LEFTDIV EMUL EDIV ELEFTDIV |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
308 %right UNARY EXPR_NOT |
16284
09881dab3aaf
* lex.ll, oct-parse.in.yy (HERMITIAN): Rename token from QUOTE.
John W. Eaton <jwe@octave.org>
parents:
16279
diff
changeset
|
309 %left POW EPOW HERMITIAN TRANSPOSE |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
310 %right PLUS_PLUS MINUS_MINUS |
3351 | 311 %left '(' '.' '{' |
1 | 312 |
17629
1e8f8900a041
clean up partially constructed parse tree objects on parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17622
diff
changeset
|
313 // How to clean up if there is a parse error. We handle deleting tokens |
1e8f8900a041
clean up partially constructed parse tree objects on parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17622
diff
changeset
|
314 // and comments seperately and separators are just characters. The |
1e8f8900a041
clean up partially constructed parse tree objects on parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17622
diff
changeset
|
315 // remaining items are dynamically allocated parse tree objects that |
17658
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
316 // must be deleted. Use the wildcard case (<*>) to detect unhandled |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
317 // cases (for example, a new semantic type is added but not handled |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
318 // here). |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
319 |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
320 %destructor { } <tok_val> |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
321 %destructor { } <punct_type> |
17658
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
322 %destructor { } <comment_type> |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
323 %destructor { } <> |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
324 |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
325 %destructor { delete $$; } <tree_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
326 %destructor { delete $$; } <tree_matrix_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
327 %destructor { delete $$; } <tree_cell_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
328 %destructor { delete $$; } <tree_expression_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
329 %destructor { delete $$; } <tree_constant_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
330 %destructor { delete $$; } <tree_fcn_handle_type> |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
331 %destructor { delete $$; } <tree_funcall_type> |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
332 %destructor { delete $$; } <tree_function_def_type> |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
333 %destructor { delete $$; } <tree_anon_fcn_handle_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
334 %destructor { delete $$; } <tree_identifier_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
335 %destructor { delete $$; } <tree_index_expression_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
336 %destructor { delete $$; } <tree_colon_expression_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
337 %destructor { delete $$; } <tree_argument_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
338 %destructor { delete $$; } <tree_parameter_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
339 %destructor { delete $$; } <tree_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
340 %destructor { delete $$; } <tree_if_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
341 %destructor { delete $$; } <tree_if_clause_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
342 %destructor { delete $$; } <tree_if_command_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
343 %destructor { delete $$; } <tree_switch_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
344 %destructor { delete $$; } <tree_switch_case_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
345 %destructor { delete $$; } <tree_switch_case_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
346 %destructor { delete $$; } <tree_decl_elt_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
347 %destructor { delete $$; } <tree_decl_init_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
348 %destructor { delete $$; } <tree_decl_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
349 %destructor { delete $$; } <tree_statement_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
350 %destructor { delete $$; } <tree_statement_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
351 %destructor { delete $$; } <octave_user_function_type> |
17658
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
352 |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
353 %destructor { delete $$; } <tree_classdef_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
354 %destructor { delete $$; } <tree_classdef_attribute_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
355 %destructor { delete $$; } <tree_classdef_attribute_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
356 %destructor { delete $$; } <tree_classdef_superclass_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
357 %destructor { delete $$; } <tree_classdef_superclass_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
358 %destructor { delete $$; } <tree_classdef_body_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
359 %destructor { delete $$; } <tree_classdef_property_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
360 %destructor { delete $$; } <tree_classdef_property_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
361 %destructor { delete $$; } <tree_classdef_properties_block_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
362 %destructor { delete $$; } <tree_classdef_methods_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
363 %destructor { delete $$; } <tree_classdef_methods_block_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
364 %destructor { delete $$; } <tree_classdef_event_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
365 %destructor { delete $$; } <tree_classdef_events_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
366 %destructor { delete $$; } <tree_classdef_events_block_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
367 %destructor { delete $$; } <tree_classdef_enum_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
368 %destructor { delete $$; } <tree_classdef_enum_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
369 %destructor { delete $$; } <tree_classdef_enum_block_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
370 |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
371 // Defining a generic destructor generates a warning if destructors are |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
372 // already explicitly declared for all types. |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
373 // |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
374 // %destructor { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
375 // warning_with_id |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
376 // ("Octave:parser-destructor", |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
377 // "possible memory leak in cleanup following parse error"); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
378 // } <*> |
17629
1e8f8900a041
clean up partially constructed parse tree objects on parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17622
diff
changeset
|
379 |
143 | 380 // Where to start. |
1 | 381 %start input |
382 | |
383 %% | |
384 | |
2970 | 385 // ============================== |
386 // Statements and statement lists | |
387 // ============================== | |
388 | |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
389 input : simple_list '\n' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
390 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
391 $$ = 0; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
392 parser.stmt_list = $1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
393 YYACCEPT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
394 } |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
395 | simple_list END_OF_INPUT |
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
396 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
397 $$ = 0; |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
398 lexer.end_of_input = true; |
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
399 parser.stmt_list = $1; |
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
400 YYACCEPT; |
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
401 } |
17326
f444e4cef9b9
avoid exiting Octave on parse error (bug #39862)
John W. Eaton <jwe@octave.org>
parents:
17322
diff
changeset
|
402 | parse_error |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
403 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
404 $$ = 0; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
405 YYABORT; |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
406 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
407 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
408 |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
409 simple_list : opt_sep_no_nl |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
410 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
411 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
412 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
413 $$ = 0; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
414 } |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
415 | simple_list1 opt_sep_no_nl |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
416 { $$ = parser.set_stmt_print_flag ($1, $2, false); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
417 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
418 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
419 simple_list1 : statement |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
420 { $$ = parser.make_statement_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
421 | simple_list1 sep_no_nl statement |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
422 { $$ = parser.append_statement_list ($1, $2, $3, false); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
423 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
424 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
425 opt_list : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
426 { $$ = new tree_statement_list (); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
427 | list |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
428 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
429 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
430 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
431 list : list1 opt_sep |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
432 { $$ = parser.set_stmt_print_flag ($1, $2, true); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
433 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
434 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
435 list1 : statement |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
436 { $$ = parser.make_statement_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
437 | list1 sep statement |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
438 { $$ = parser.append_statement_list ($1, $2, $3, true); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
439 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
440 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
441 statement : expression |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
442 { $$ = parser.make_statement ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
443 | command |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
444 { $$ = parser.make_statement ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
445 | word_list_cmd |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
446 { $$ = parser.make_statement ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
447 ; |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
448 |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
449 // ================= |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
450 // Word-list command |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
451 // ================= |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
452 |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
453 // These are not really like expressions since they can't appear on |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
454 // the RHS of an assignment. But they are also not like commands (IF, |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
455 // WHILE, etc. |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
456 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
457 word_list_cmd : identifier word_list |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
458 { |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
459 $$ = parser.make_index_expression ($1, $2, '('); |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
460 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
461 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
462 // make_index_expression deleted $1 and $2. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
463 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
464 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
465 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
466 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
467 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
468 word_list : string |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
469 { $$ = new tree_argument_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
470 | word_list string |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
471 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
472 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
473 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
474 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
475 ; |
1 | 476 |
2970 | 477 // =========== |
478 // Expressions | |
479 // =========== | |
480 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
481 identifier : NAME |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
482 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
483 symbol_table::symbol_record *sr = $1->sym_rec (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
484 $$ = new tree_identifier (*sr, $1->line (), $1->column ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
485 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
486 ; |
2970 | 487 |
9476 | 488 superclass_identifier |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
489 : SUPERCLASSREF |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
490 { |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
491 std::string method_nm = $1->superclass_method_name (); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
492 std::string class_nm = $1->superclass_class_name (); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
493 |
18927
09eb8a2ddb02
eliminate some unused parameter warnings in parser functions
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
494 $$ = parser.make_superclass_ref (method_nm, class_nm); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
495 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
496 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
497 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
498 meta_identifier : METAQUERY |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
499 { |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
500 std::string class_nm = $1->text (); |
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
501 |
18927
09eb8a2ddb02
eliminate some unused parameter warnings in parser functions
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
502 $$ = parser.make_meta_class_query (class_nm); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
503 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
504 ; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
505 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
506 string : DQ_STRING |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
507 { $$ = parser.make_constant (DQ_STRING, $1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
508 | SQ_STRING |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
509 { $$ = parser.make_constant (SQ_STRING, $1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
510 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
511 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
512 constant : NUM |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
513 { $$ = parser.make_constant (NUM, $1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
514 | IMAG_NUM |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
515 { $$ = parser.make_constant (IMAG_NUM, $1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
516 | string |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
517 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
518 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
519 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
520 matrix : '[' matrix_rows ']' |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
521 { $$ = parser.finish_matrix ($2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
522 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
523 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
524 matrix_rows : cell_or_matrix_row |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
525 { $$ = $1 ? new tree_matrix ($1) : 0; } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
526 | matrix_rows ';' cell_or_matrix_row |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
527 { |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
528 if ($1) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
529 { |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
530 if ($3) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
531 $1->append ($3); |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
532 |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
533 $$ = $1; |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
534 } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
535 else |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
536 $$ = $3 ? new tree_matrix ($3) : 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
537 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
538 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
539 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
540 cell : '{' cell_rows '}' |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
541 { $$ = parser.finish_cell ($2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
542 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
543 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
544 cell_rows : cell_or_matrix_row |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
545 { $$ = $1 ? new tree_cell ($1) : 0; } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
546 | cell_rows ';' cell_or_matrix_row |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
547 { |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
548 if ($1) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
549 { |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
550 if ($3) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
551 $1->append ($3); |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
552 |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
553 $$ = $1; |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
554 } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
555 else |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
556 $$ = $3 ? new tree_cell ($3) : 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
557 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
558 ; |
3351 | 559 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
560 // tree_argument_list objects can't be empty or have leading or trailing |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
561 // commas, but those are all allowed in matrix and cell array rows. |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
562 |
3351 | 563 cell_or_matrix_row |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
564 : // empty |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
565 { $$ = 0; } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
566 | ',' |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
567 { $$ = 0; } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
568 | arg_list |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
569 { $$ = $1; } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
570 | arg_list ',' |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
571 { $$ = $1; } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
572 | ',' arg_list |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
573 { $$ = $2; } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
574 | ',' arg_list ',' |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
575 { $$ = $2; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
576 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
577 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
578 fcn_handle : '@' FCN_HANDLE |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
579 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
580 $$ = parser.make_fcn_handle ($2); |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
581 lexer.looking_at_function_handle--; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
582 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
583 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
584 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
585 anon_fcn_handle : '@' param_list stmt_begin statement |
13237
1bfca2bbea8b
fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents:
13125
diff
changeset
|
586 { |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
587 $$ = parser.make_anon_fcn_handle ($2, $4); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
588 lexer.nesting_level.remove (); |
13237
1bfca2bbea8b
fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents:
13125
diff
changeset
|
589 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
590 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
591 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
592 primary_expr : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
593 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
594 | constant |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
595 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
596 | fcn_handle |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
597 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
598 | matrix |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
599 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
600 lexer.looking_at_matrix_or_assign_lhs = false; |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
601 $$ = $1; |
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
602 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
603 | cell |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
604 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
605 | meta_identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
606 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
607 | superclass_identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
608 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
609 | '(' expression ')' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
610 { $$ = $2->mark_in_parens (); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
611 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
612 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
613 magic_colon : ':' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
614 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
615 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
616 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
617 octave_value tmp (octave_value::magic_colon_t); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
618 $$ = new tree_constant (tmp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
619 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
620 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
621 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
622 magic_tilde : EXPR_NOT |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
623 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
624 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
625 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
626 $$ = new tree_black_hole (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
627 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
628 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
629 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
630 arg_list : expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
631 { $$ = new tree_argument_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
632 | magic_colon |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
633 { $$ = new tree_argument_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
634 | magic_tilde |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
635 { $$ = new tree_argument_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
636 | arg_list ',' magic_colon |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
637 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
638 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
639 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
640 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
641 | arg_list ',' magic_tilde |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
642 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
643 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
644 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
645 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
646 | arg_list ',' expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
647 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
648 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
649 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
650 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
651 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
652 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
653 indirect_ref_op : '.' |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
654 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
655 $$ = 0; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
656 lexer.looking_at_indirect_ref = true; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
657 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
658 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
659 |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
660 oper_expr : primary_expr |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
661 { $$ = $1; } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
662 | oper_expr PLUS_PLUS |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
663 { $$ = parser.make_postfix_op (PLUS_PLUS, $1, $2); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
664 | oper_expr MINUS_MINUS |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
665 { $$ = parser.make_postfix_op (MINUS_MINUS, $1, $2); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
666 | oper_expr '(' ')' |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
667 { |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
668 $$ = parser.make_index_expression ($1, 0, '('); |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
669 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
670 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
671 // make_index_expression deleted $1. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
672 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
673 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
674 } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
675 | oper_expr '(' arg_list ')' |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
676 { |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
677 $$ = parser.make_index_expression ($1, $3, '('); |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
678 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
679 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
680 // make_index_expression deleted $1 and $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
681 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
682 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
683 } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
684 | oper_expr '{' '}' |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
685 { |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
686 $$ = parser.make_index_expression ($1, 0, '{'); |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
687 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
688 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
689 // make_index_expression deleted $1. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
690 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
691 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
692 } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
693 | oper_expr '{' arg_list '}' |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
694 { |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
695 $$ = parser.make_index_expression ($1, $3, '{'); |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
696 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
697 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
698 // make_index_expression deleted $1 and $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
699 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
700 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
701 } |
16284
09881dab3aaf
* lex.ll, oct-parse.in.yy (HERMITIAN): Rename token from QUOTE.
John W. Eaton <jwe@octave.org>
parents:
16279
diff
changeset
|
702 | oper_expr HERMITIAN |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
703 { $$ = parser.make_postfix_op (HERMITIAN, $1, $2); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
704 | oper_expr TRANSPOSE |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
705 { $$ = parser.make_postfix_op (TRANSPOSE, $1, $2); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
706 | oper_expr indirect_ref_op STRUCT_ELT |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
707 { $$ = parser.make_indirect_ref ($1, $3->text ()); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
708 | oper_expr indirect_ref_op '(' expression ')' |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
709 { $$ = parser.make_indirect_ref ($1, $4); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
710 | PLUS_PLUS oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
711 { $$ = parser.make_prefix_op (PLUS_PLUS, $2, $1); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
712 | MINUS_MINUS oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
713 { $$ = parser.make_prefix_op (MINUS_MINUS, $2, $1); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
714 | EXPR_NOT oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
715 { $$ = parser.make_prefix_op (EXPR_NOT, $2, $1); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
716 | '+' oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
717 { $$ = parser.make_prefix_op ('+', $2, $1); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
718 | '-' oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
719 { $$ = parser.make_prefix_op ('-', $2, $1); } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
720 | oper_expr POW power_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
721 { $$ = parser.make_binary_op (POW, $1, $2, $3); } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
722 | oper_expr EPOW power_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
723 { $$ = parser.make_binary_op (EPOW, $1, $2, $3); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
724 | oper_expr '+' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
725 { $$ = parser.make_binary_op ('+', $1, $2, $3); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
726 | oper_expr '-' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
727 { $$ = parser.make_binary_op ('-', $1, $2, $3); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
728 | oper_expr '*' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
729 { $$ = parser.make_binary_op ('*', $1, $2, $3); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
730 | oper_expr '/' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
731 { $$ = parser.make_binary_op ('/', $1, $2, $3); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
732 | oper_expr EPLUS oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
733 { $$ = parser.make_binary_op ('+', $1, $2, $3); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
734 | oper_expr EMINUS oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
735 { $$ = parser.make_binary_op ('-', $1, $2, $3); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
736 | oper_expr EMUL oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
737 { $$ = parser.make_binary_op (EMUL, $1, $2, $3); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
738 | oper_expr EDIV oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
739 { $$ = parser.make_binary_op (EDIV, $1, $2, $3); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
740 | oper_expr LEFTDIV oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
741 { $$ = parser.make_binary_op (LEFTDIV, $1, $2, $3); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
742 | oper_expr ELEFTDIV oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
743 { $$ = parser.make_binary_op (ELEFTDIV, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
744 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
745 |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
746 power_expr : primary_expr |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
747 { $$ = $1; } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
748 | power_expr PLUS_PLUS |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
749 { $$ = parser.make_postfix_op (PLUS_PLUS, $1, $2); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
750 | power_expr MINUS_MINUS |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
751 { $$ = parser.make_postfix_op (MINUS_MINUS, $1, $2); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
752 | power_expr '(' ')' |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
753 { |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
754 $$ = parser.make_index_expression ($1, 0, '('); |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
755 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
756 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
757 // make_index_expression deleted $1. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
758 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
759 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
760 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
761 | power_expr '(' arg_list ')' |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
762 { |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
763 $$ = parser.make_index_expression ($1, $3, '('); |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
764 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
765 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
766 // make_index_expression deleted $1 and $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
767 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
768 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
769 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
770 | power_expr '{' '}' |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
771 { |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
772 $$ = parser.make_index_expression ($1, 0, '{'); |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
773 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
774 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
775 // make_index_expression deleted $1. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
776 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
777 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
778 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
779 | power_expr '{' arg_list '}' |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
780 { |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
781 $$ = parser.make_index_expression ($1, $3, '{'); |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
782 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
783 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
784 // make_index_expression deleted $1 and $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
785 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
786 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
787 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
788 | power_expr indirect_ref_op STRUCT_ELT |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
789 { $$ = parser.make_indirect_ref ($1, $3->text ()); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
790 | power_expr indirect_ref_op '(' expression ')' |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
791 { $$ = parser.make_indirect_ref ($1, $4); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
792 | PLUS_PLUS power_expr %prec POW |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
793 { $$ = parser.make_prefix_op (PLUS_PLUS, $2, $1); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
794 | MINUS_MINUS power_expr %prec POW |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
795 { $$ = parser.make_prefix_op (MINUS_MINUS, $2, $1); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
796 | EXPR_NOT power_expr %prec POW |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
797 { $$ = parser.make_prefix_op (EXPR_NOT, $2, $1); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
798 | '+' power_expr %prec POW |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
799 { $$ = parser.make_prefix_op ('+', $2, $1); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
800 | '-' power_expr %prec POW |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
801 { $$ = parser.make_prefix_op ('-', $2, $1); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
802 ; |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
803 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
804 colon_expr : colon_expr1 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
805 { $$ = parser.finish_colon_expression ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
806 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
807 |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
808 colon_expr1 : oper_expr |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
809 { $$ = new tree_colon_expression ($1); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
810 | colon_expr1 ':' oper_expr |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
811 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
812 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
813 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
814 if (! ($$ = $1->append ($3))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
815 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
816 delete $1; |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
817 delete $3; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
818 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
819 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
820 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
821 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
822 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
823 simple_expr : colon_expr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
824 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
825 | simple_expr EXPR_LT simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
826 { $$ = parser.make_binary_op (EXPR_LT, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
827 | simple_expr EXPR_LE simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
828 { $$ = parser.make_binary_op (EXPR_LE, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
829 | simple_expr EXPR_EQ simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
830 { $$ = parser.make_binary_op (EXPR_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
831 | simple_expr EXPR_GE simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
832 { $$ = parser.make_binary_op (EXPR_GE, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
833 | simple_expr EXPR_GT simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
834 { $$ = parser.make_binary_op (EXPR_GT, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
835 | simple_expr EXPR_NE simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
836 { $$ = parser.make_binary_op (EXPR_NE, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
837 | simple_expr EXPR_AND simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
838 { $$ = parser.make_binary_op (EXPR_AND, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
839 | simple_expr EXPR_OR simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
840 { $$ = parser.make_binary_op (EXPR_OR, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
841 | simple_expr EXPR_AND_AND simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
842 { $$ = parser.make_boolean_op (EXPR_AND_AND, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
843 | simple_expr EXPR_OR_OR simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
844 { $$ = parser.make_boolean_op (EXPR_OR_OR, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
845 ; |
2970 | 846 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
847 assign_lhs : simple_expr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
848 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
849 $$ = parser.validate_matrix_for_assignment ($1); |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
850 |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
851 if ($$) |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
852 { lexer.looking_at_matrix_or_assign_lhs = false; } |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
853 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
854 { |
16277
8cb65fd72164
eliminate obsolete concepts of "pending local" and "forced" variables
John W. Eaton <jwe@octave.org>
parents:
16273
diff
changeset
|
855 // validate_matrix_for_assignment deleted $1. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
856 YYABORT; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
857 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
858 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
859 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
860 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
861 assign_expr : assign_lhs '=' expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
862 { $$ = parser.make_assign_op ('=', $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
863 | assign_lhs ADD_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
864 { $$ = parser.make_assign_op (ADD_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
865 | assign_lhs SUB_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
866 { $$ = parser.make_assign_op (SUB_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
867 | assign_lhs MUL_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
868 { $$ = parser.make_assign_op (MUL_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
869 | assign_lhs DIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
870 { $$ = parser.make_assign_op (DIV_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
871 | assign_lhs LEFTDIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
872 { $$ = parser.make_assign_op (LEFTDIV_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
873 | assign_lhs POW_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
874 { $$ = parser.make_assign_op (POW_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
875 | assign_lhs EMUL_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
876 { $$ = parser.make_assign_op (EMUL_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
877 | assign_lhs EDIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
878 { $$ = parser.make_assign_op (EDIV_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
879 | assign_lhs ELEFTDIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
880 { $$ = parser.make_assign_op (ELEFTDIV_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
881 | assign_lhs EPOW_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
882 { $$ = parser.make_assign_op (EPOW_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
883 | assign_lhs AND_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
884 { $$ = parser.make_assign_op (AND_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
885 | assign_lhs OR_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
886 { $$ = parser.make_assign_op (OR_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
887 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
888 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
889 expression : simple_expr |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
890 { |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
891 if ($1 && ($1->is_matrix () || $1->is_cell ())) |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
892 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
893 if (parser.validate_array_list ($1)) |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
894 $$ = $1; |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
895 else |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
896 { |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
897 delete $1; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
898 YYABORT; |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
899 } |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
900 } |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
901 else |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
902 $$ = $1; |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
903 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
904 | assign_expr |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
905 { |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
906 if (! $1) |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
907 YYABORT; |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
908 |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
909 $$ = $1; |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
910 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
911 | anon_fcn_handle |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
912 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
913 ; |
2970 | 914 |
915 // ================================================ | |
916 // Commands, declarations, and function definitions | |
917 // ================================================ | |
918 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
919 command : declaration |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
920 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
921 | select_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
922 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
923 | loop_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
924 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
925 | jump_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
926 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
927 | except_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
928 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
929 | function |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
930 { $$ = $1; } |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
931 | file |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
932 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
933 ; |
2970 | 934 |
935 // ===================== | |
936 // Declaration statemnts | |
937 // ===================== | |
938 | |
16263
9acb86e6ac90
4/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16259
diff
changeset
|
939 declaration : GLOBAL decl1 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
940 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
941 $$ = parser.make_decl_command (GLOBAL, $1, $2); |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
942 lexer.looking_at_decl_list = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
943 } |
16263
9acb86e6ac90
4/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16259
diff
changeset
|
944 | PERSISTENT decl1 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
945 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
946 $$ = parser.make_decl_command (PERSISTENT, $1, $2); |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
947 lexer.looking_at_decl_list = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
948 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
949 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
950 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
951 decl1 : decl2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
952 { $$ = new tree_decl_init_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
953 | decl1 decl2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
954 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
955 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
956 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
957 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
958 ; |
2970 | 959 |
7634
ae90e05ad299
fix parameter list initializer bug
John W. Eaton <jwe@octave.org>
parents:
7587
diff
changeset
|
960 decl_param_init : // empty |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
961 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
962 $$ = 0; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
963 lexer.looking_at_initializer_expression = true; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
964 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
965 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
966 decl2 : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
967 { $$ = new tree_decl_elt ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
968 | identifier '=' decl_param_init expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
969 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
970 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
971 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
972 lexer.looking_at_initializer_expression = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
973 $$ = new tree_decl_elt ($1, $4); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
974 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
975 ; |
2970 | 976 |
977 // ==================== | |
978 // Selection statements | |
979 // ==================== | |
980 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
981 select_command : if_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
982 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
983 | switch_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
984 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
985 ; |
2970 | 986 |
987 // ============ | |
988 // If statement | |
989 // ============ | |
990 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
991 if_command : IF stash_comment if_cmd_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
992 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
993 if (! ($$ = parser.finish_if_command ($1, $3, $4, $2))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
994 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
995 // finish_if_command deleted $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
996 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
997 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
998 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
999 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1000 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1001 if_cmd_list : if_cmd_list1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1002 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1003 | if_cmd_list1 else_clause |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1004 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1005 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1006 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1007 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1008 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1009 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1010 if_cmd_list1 : expression stmt_begin opt_sep opt_list |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
1011 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1012 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1013 |
18127
d76f790b4eec
enable do_braindead_shortcircuit_evaluation by default and deprecate
John W. Eaton <jwe@octave.org>
parents:
17796
diff
changeset
|
1014 $1->mark_braindead_shortcircuit (); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1015 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1016 $$ = parser.start_if_command ($1, $4); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
1017 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1018 | if_cmd_list1 elseif_clause |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1019 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1020 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1021 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1022 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1023 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1024 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1025 elseif_clause : ELSEIF stash_comment opt_sep expression stmt_begin opt_sep opt_list |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
1026 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1027 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1028 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1029 |
18127
d76f790b4eec
enable do_braindead_shortcircuit_evaluation by default and deprecate
John W. Eaton <jwe@octave.org>
parents:
17796
diff
changeset
|
1030 $4->mark_braindead_shortcircuit (); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1031 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1032 $$ = parser.make_elseif_clause ($1, $4, $7, $2); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
1033 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1034 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1035 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1036 else_clause : ELSE stash_comment opt_sep opt_list |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1037 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1038 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1039 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1040 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1041 $$ = new tree_if_clause ($4, $2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1042 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1043 ; |
2970 | 1044 |
1045 // ================ | |
1046 // Switch statement | |
1047 // ================ | |
1048 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1049 switch_command : SWITCH stash_comment expression opt_sep case_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1050 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1051 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1052 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1053 if (! ($$ = parser.finish_switch_command ($1, $3, $5, $6, $2))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1054 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1055 // finish_switch_command deleted $3 adn $5. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1056 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1057 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1058 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1059 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1060 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1061 case_list : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1062 { $$ = new tree_switch_case_list (); } |
11317
2da532d0f41c
accept otherwise clause in switch statement without preceding case statements
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1063 | default_case |
2da532d0f41c
accept otherwise clause in switch statement without preceding case statements
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1064 { $$ = new tree_switch_case_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1065 | case_list1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1066 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1067 | case_list1 default_case |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1068 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1069 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1070 $$ = $1; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1071 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1072 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1073 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1074 case_list1 : switch_case |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1075 { $$ = new tree_switch_case_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1076 | case_list1 switch_case |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1077 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1078 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1079 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1080 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1081 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1082 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1083 switch_case : CASE stash_comment opt_sep expression stmt_begin opt_sep opt_list |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1084 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1085 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1086 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1087 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1088 $$ = parser.make_switch_case ($1, $4, $7, $2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1089 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1090 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1091 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1092 default_case : OTHERWISE stash_comment opt_sep opt_list |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1093 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1094 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1095 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1096 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1097 $$ = new tree_switch_case ($4, $2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1098 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1099 ; |
2970 | 1100 |
1101 // ======= | |
1102 // Looping | |
1103 // ======= | |
1104 | |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1105 loop_command : WHILE stash_comment expression stmt_begin opt_sep opt_list END |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1106 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1107 YYUSE ($5); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1108 |
18127
d76f790b4eec
enable do_braindead_shortcircuit_evaluation by default and deprecate
John W. Eaton <jwe@octave.org>
parents:
17796
diff
changeset
|
1109 $3->mark_braindead_shortcircuit (); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1110 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1111 if (! ($$ = parser.make_while_command ($1, $3, $6, $7, $2))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1112 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1113 // make_while_command deleted $3 and $6. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1114 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1115 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1116 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1117 | DO stash_comment opt_sep opt_list UNTIL expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1118 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1119 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1120 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1121 |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1122 $$ = parser.make_do_until_command ($5, $4, $6, $2); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1123 } |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1124 | FOR stash_comment assign_lhs '=' expression stmt_begin opt_sep opt_list END |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1125 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1126 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1127 YYUSE ($7); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1128 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1129 if (! ($$ = parser.make_for_command (FOR, $1, $3, $5, 0, |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1130 $8, $9, $2))) |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1131 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1132 // make_for_command deleted $3, $5, and $8. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1133 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1134 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1135 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1136 | FOR stash_comment '(' assign_lhs '=' expression ')' opt_sep opt_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1137 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1138 YYUSE ($5); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1139 YYUSE ($8); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1140 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1141 if (! ($$ = parser.make_for_command (FOR, $1, $4, $6, 0, |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1142 $9, $10, $2))) |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1143 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1144 // make_for_command deleted $4, $6, and $9. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1145 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1146 } |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
1147 } |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1148 | PARFOR stash_comment assign_lhs '=' expression stmt_begin opt_sep opt_list END |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
1149 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1150 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1151 YYUSE ($7); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1152 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1153 if (! ($$ = parser.make_for_command (PARFOR, $1, $3, $5, |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1154 0, $8, $9, $2))) |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1155 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1156 // make_for_command deleted $3, $5, and $8. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1157 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1158 } |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
1159 } |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
1160 | PARFOR stash_comment '(' assign_lhs '=' expression ',' expression ')' opt_sep opt_list END |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
1161 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1162 YYUSE ($5); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1163 YYUSE ($10); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1164 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1165 if (! ($$ = parser.make_for_command (PARFOR, $1, $4, $6, |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1166 $8, $11, $12, $2))) |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1167 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1168 // make_for_command deleted $4, $6, $8, and $11. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1169 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1170 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1171 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1172 ; |
2970 | 1173 |
1174 // ======= | |
1175 // Jumping | |
1176 // ======= | |
1177 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1178 jump_command : BREAK |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1179 { $$ = parser.make_break_command ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1180 | CONTINUE |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1181 { $$ = parser.make_continue_command ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1182 | FUNC_RET |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1183 { $$ = parser.make_return_command ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1184 ; |
2970 | 1185 |
1186 // ========== | |
1187 // Exceptions | |
1188 // ========== | |
1189 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1190 except_command : UNWIND stash_comment opt_sep opt_list CLEANUP |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1191 stash_comment opt_sep opt_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1192 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1193 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1194 YYUSE ($5); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1195 YYUSE ($7); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1196 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1197 if (! ($$ = parser.make_unwind_command ($1, $4, $8, $9, $2, $6))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1198 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1199 // make_unwind_command deleted $4 and $8. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1200 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1201 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1202 } |
17283
e6c0ac8ce5b6
eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
1203 | TRY stash_comment opt_sep opt_list CATCH stash_comment |
e6c0ac8ce5b6
eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
1204 opt_sep opt_list END |
17249
923ce8b42db2
improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents:
17170
diff
changeset
|
1205 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1206 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1207 YYUSE ($5); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1208 YYUSE ($7); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1209 |
17283
e6c0ac8ce5b6
eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
1210 if (! ($$ = parser.make_try_command ($1, $4, $7, $8, $9, $2, $6))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1211 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1212 // make_try_command deleted $4 and $8. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1213 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1214 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1215 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1216 | TRY stash_comment opt_sep opt_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1217 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1218 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1219 |
17249
923ce8b42db2
improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents:
17170
diff
changeset
|
1220 if (! ($$ = parser.make_try_command ($1, $4, 0, 0, $5, $2, 0))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1221 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1222 // make_try_command deleted $4. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1223 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1224 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1225 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1226 ; |
2970 | 1227 |
1228 // =========================================== | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
1229 // Some 'subroutines' for function definitions |
2970 | 1230 // =========================================== |
1231 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1232 push_fcn_symtab : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1233 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1234 $$ = 0; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1235 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1236 parser.curr_fcn_depth++; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1237 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1238 if (parser.max_fcn_depth < parser.curr_fcn_depth) |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1239 parser.max_fcn_depth = parser.curr_fcn_depth; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1240 |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16302
diff
changeset
|
1241 lexer.symtab_context.push (symbol_table::alloc_scope ()); |
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16302
diff
changeset
|
1242 |
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16302
diff
changeset
|
1243 parser.function_scopes.push_back |
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16302
diff
changeset
|
1244 (lexer.symtab_context.curr_scope ()); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1245 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1246 if (! lexer.reading_script_file |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1247 && parser.curr_fcn_depth == 1 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1248 && ! parser.parsing_subfunctions) |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16302
diff
changeset
|
1249 parser.primary_fcn_scope |
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16302
diff
changeset
|
1250 = lexer.symtab_context.curr_scope (); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1251 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1252 if (lexer.reading_script_file |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1253 && parser.curr_fcn_depth > 1) |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1254 { |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1255 parser.bison_error ("nested functions not implemented in this context"); |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1256 YYABORT; |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1257 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1258 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1259 ; |
2970 | 1260 |
1261 // =========================== | |
1262 // List of function parameters | |
1263 // =========================== | |
1264 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1265 param_list_beg : '(' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1266 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1267 $$ = 0; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1268 lexer.looking_at_parameter_list = true; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1269 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1270 if (lexer.looking_at_function_handle) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1271 { |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16302
diff
changeset
|
1272 lexer.symtab_context.push (symbol_table::alloc_scope ()); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1273 lexer.looking_at_function_handle--; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1274 lexer.looking_at_anon_fcn_args = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1275 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1276 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1277 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1278 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1279 param_list_end : ')' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1280 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1281 $$ = 0; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1282 lexer.looking_at_parameter_list = false; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1283 lexer.looking_for_object_index = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1284 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1285 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1286 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1287 param_list : param_list_beg param_list1 param_list_end |
16360
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1288 { |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1289 if ($2) |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1290 lexer.mark_as_variables ($2->variable_names ()); |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1291 |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1292 $$ = $2; |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1293 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1294 | param_list_beg error |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1295 { |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1296 $$ = 0; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1297 parser.bison_error ("invalid parameter list"); |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1298 YYABORT; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1299 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1300 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1301 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1302 param_list1 : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1303 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1304 | param_list2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1305 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1306 $1->mark_as_formal_parameters (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1307 if ($1->validate (tree_parameter_list::in)) |
16360
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1308 { |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1309 lexer.mark_as_variables ($1->variable_names ()); |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1310 $$ = $1; |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1311 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1312 else |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1313 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1314 delete $1; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1315 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1316 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1317 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1318 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1319 |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1320 param_list2 : param_list_elt |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1321 { $$ = new tree_parameter_list ($1); } |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1322 | param_list2 ',' param_list_elt |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1323 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1324 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1325 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1326 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1327 ; |
2970 | 1328 |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1329 param_list_elt : decl2 |
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1330 { $$ = $1; } |
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1331 | magic_tilde |
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1332 { $$ = new tree_decl_elt ($1); } |
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1333 ; |
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1334 |
2970 | 1335 // =================================== |
1336 // List of function return value names | |
1337 // =================================== | |
1338 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1339 return_list : '[' ']' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1340 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1341 lexer.looking_at_return_list = false; |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1342 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1343 $$ = new tree_parameter_list (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1344 } |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1345 | identifier |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1346 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1347 lexer.looking_at_return_list = false; |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1348 |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1349 tree_parameter_list *tmp = new tree_parameter_list ($1); |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1350 |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1351 // Even though this parameter list can contain only |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1352 // a single identifier, we still need to validate it |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1353 // to check for varargin or varargout. |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1354 |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1355 if (tmp->validate (tree_parameter_list::out)) |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1356 $$ = tmp; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1357 else |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1358 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1359 delete tmp; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1360 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1361 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1362 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1363 | '[' return_list1 ']' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1364 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1365 lexer.looking_at_return_list = false; |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1366 |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1367 // Check for duplicate parameter names, varargin, |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1368 // or varargout. |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1369 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1370 if ($2->validate (tree_parameter_list::out)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1371 $$ = $2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1372 else |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1373 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1374 delete $2; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1375 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1376 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1377 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1378 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1379 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1380 return_list1 : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1381 { $$ = new tree_parameter_list (new tree_decl_elt ($1)); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1382 | return_list1 ',' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1383 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1384 $1->append (new tree_decl_elt ($3)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1385 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1386 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1387 ; |
2970 | 1388 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1389 // ======================= |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1390 // Script or function file |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1391 // ======================= |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1392 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1393 file : INPUT_FILE opt_nl opt_list END_OF_INPUT |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1394 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1395 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1396 |
17618
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1397 if (lexer.reading_fcn_file) |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1398 { |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1399 // Delete the dummy statement_list we created |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1400 // after parsing the function. Any function |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1401 // definitions found in the file have already |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1402 // been stored in the symbol table or in |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
1403 // base_parser::primary_fcn_ptr. |
17618
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1404 |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1405 delete $3; |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1406 } |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1407 else |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1408 { |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1409 tree_statement *end_of_script |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1410 = parser.make_end ("endscript", true, |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1411 lexer.input_line_number, |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1412 lexer.current_input_column); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1413 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1414 parser.make_script ($3, end_of_script); |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1415 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1416 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1417 $$ = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1418 } |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1419 | INPUT_FILE opt_nl classdef opt_sep END_OF_INPUT |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1420 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1421 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1422 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1423 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1424 if (lexer.reading_classdef_file) |
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1425 parser.classdef_object = $3; |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1426 |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1427 $$ = 0; |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1428 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1429 ; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
1430 |
2970 | 1431 // =================== |
1432 // Function definition | |
1433 // =================== | |
1434 | |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1435 function_beg : push_fcn_symtab FCN |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1436 { |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1437 $$ = $2; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1438 if (lexer.reading_classdef_file |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1439 || lexer.parsing_classdef) |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1440 lexer.maybe_classdef_get_set_method = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1441 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1442 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1443 |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1444 function : function_beg stash_comment function1 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1445 { |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1446 $$ = parser.finish_function (0, $3, $2, $1->line (), |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1447 $1->column ()); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1448 parser.recover_from_parsing_function (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1449 } |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1450 | function_beg stash_comment return_list '=' function1 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1451 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1452 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1453 |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1454 $$ = parser.finish_function ($3, $5, $2, $1->line (), |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1455 $1->column ()); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1456 parser.recover_from_parsing_function (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1457 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1458 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1459 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1460 fcn_name : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1461 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1462 std::string id_name = $1->name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1463 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1464 lexer.parsed_function_name.top () = true; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1465 lexer.maybe_classdef_get_set_method = false; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1466 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1467 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1468 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1469 | GET '.' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1470 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1471 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1472 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1473 lexer.parsed_function_name.top () = true; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1474 lexer.maybe_classdef_get_set_method = false; |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1475 lexer.parsing_classdef_get_method = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1476 $$ = $3; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1477 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1478 | SET '.' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1479 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1480 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1481 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1482 lexer.parsed_function_name.top () = true; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1483 lexer.maybe_classdef_get_set_method = false; |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1484 lexer.parsing_classdef_set_method = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1485 $$ = $3; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1486 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1487 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1488 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1489 function1 : fcn_name function2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1490 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1491 std::string fname = $1->name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1492 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1493 delete $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1494 |
16698
13b3b92ea99c
Implement property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16683
diff
changeset
|
1495 if (lexer.parsing_classdef_get_method) |
13b3b92ea99c
Implement property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16683
diff
changeset
|
1496 fname.insert (0, "get."); |
13b3b92ea99c
Implement property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16683
diff
changeset
|
1497 else if (lexer.parsing_classdef_set_method) |
13b3b92ea99c
Implement property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16683
diff
changeset
|
1498 fname.insert (0, "set."); |
13b3b92ea99c
Implement property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16683
diff
changeset
|
1499 |
18395
2319bf776fa2
Fix parsing of classdef property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18341
diff
changeset
|
1500 lexer.parsing_classdef_get_method = false; |
2319bf776fa2
Fix parsing of classdef property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18341
diff
changeset
|
1501 lexer.parsing_classdef_set_method = false; |
2319bf776fa2
Fix parsing of classdef property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18341
diff
changeset
|
1502 |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1503 $$ = parser.frob_function (fname, $2); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1504 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1505 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1506 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1507 function2 : param_list opt_sep opt_list function_end |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1508 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1509 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1510 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1511 $$ = parser.start_function ($1, $3, $4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1512 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1513 | opt_sep opt_list function_end |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1514 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1515 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1516 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1517 $$ = parser.start_function (0, $2, $3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1518 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1519 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1520 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1521 function_end : END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1522 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1523 parser.endfunction_found = true; |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
1524 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1525 if (parser.end_token_ok ($1, token::function_end)) |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1526 $$ = parser.make_end ("endfunction", false, |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1527 $1->line (), $1->column ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1528 else |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
1529 { |
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
1530 parser.end_token_error ($1, token::function_end); |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1531 YYABORT; |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
1532 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1533 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1534 | END_OF_INPUT |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1535 { |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
1536 // A lot of tests are based on the assumption that this is OK |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1537 // if (lexer.reading_script_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1538 // { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1539 // parser.bison_error ("function body open at end of script"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1540 // YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1541 // } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1542 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1543 if (parser.endfunction_found) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1544 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1545 parser.bison_error ("inconsistent function endings -- " |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1546 "if one function is explicitly ended, " |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1547 "so must all the others"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1548 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1549 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1550 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1551 if (! (lexer.reading_fcn_file || lexer.reading_script_file |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1552 || lexer.input_from_eval_string ())) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1553 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1554 parser.bison_error ("function body open at end of input"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1555 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1556 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1557 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1558 if (lexer.reading_classdef_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1559 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1560 parser.bison_error ("classdef body open at end of input"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1561 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1562 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1563 |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1564 $$ = parser.make_end ("endfunction", true, |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1565 lexer.input_line_number, |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1566 lexer.current_input_column); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1567 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1568 ; |
2970 | 1569 |
9476 | 1570 // ======== |
1571 // Classdef | |
1572 // ======== | |
1573 | |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1574 classdef_beg : CLASSDEF |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1575 { |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1576 if (! lexer.reading_classdef_file) |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1577 { |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1578 parser.bison_error ("classdef must appear inside a file containing only a class definition"); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1579 YYABORT; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1580 } |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1581 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1582 lexer.parsing_classdef = true; |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1583 $$ = $1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1584 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1585 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1586 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1587 classdef : classdef_beg stash_comment opt_attr_list identifier opt_superclass_list opt_sep class_body opt_sep END |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1588 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1589 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1590 YYUSE ($8); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1591 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1592 lexer.parsing_classdef = false; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1593 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1594 if (! ($$ = parser.make_classdef ($1, $3, $4, $5, $7, $9, $2))) |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1595 { |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1596 // make_classdef deleted $3, $4, $5, and $7. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1597 YYABORT; |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1598 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1599 } |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1600 | classdef_beg stash_comment opt_attr_list identifier opt_superclass_list opt_sep END |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1601 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1602 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1603 |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1604 lexer.parsing_classdef = false; |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1605 |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1606 if (! ($$ = parser.make_classdef ($1, $3, $4, $5, 0, $7, $2))) |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1607 { |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1608 // make_classdef deleted $3, $4, and $5. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1609 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1610 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1611 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1612 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1613 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1614 opt_attr_list : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1615 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1616 | '(' attr_list ')' |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1617 { $$ = $2; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1618 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1619 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1620 attr_list : attr |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1621 { $$ = new tree_classdef_attribute_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1622 | attr_list ',' attr |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1623 { |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1624 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1625 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1626 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1627 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1628 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1629 attr : identifier |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1630 { $$ = new tree_classdef_attribute ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1631 | identifier '=' decl_param_init expression |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1632 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1633 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1634 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1635 lexer.looking_at_initializer_expression = false; |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1636 $$ = new tree_classdef_attribute ($1, $4); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1637 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1638 | EXPR_NOT identifier |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1639 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1640 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1641 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1642 $$ = new tree_classdef_attribute ($2, false); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1643 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1644 ; |
9476 | 1645 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1646 opt_superclass_list |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1647 : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1648 { $$ = 0; } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1649 | superclass_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1650 { $$ = $1; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1651 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1652 |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1653 superclass_list : EXPR_LT |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1654 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1655 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1656 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1657 lexer.enable_fq_identifier (); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1658 } |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1659 superclass |
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1660 { $$ = new tree_classdef_superclass_list ($3); } |
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1661 | superclass_list EXPR_AND |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1662 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1663 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1664 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1665 lexer.enable_fq_identifier (); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1666 } |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1667 superclass |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1668 { |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1669 $1->append ($4); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1670 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1671 } |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1672 ; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1673 |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1674 superclass : FQ_IDENT |
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1675 { $$ = new tree_classdef_superclass ($1->text ()); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1676 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1677 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1678 class_body : properties_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1679 { $$ = new tree_classdef_body ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1680 | methods_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1681 { $$ = new tree_classdef_body ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1682 | events_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1683 { $$ = new tree_classdef_body ($1); } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1684 | enum_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1685 { $$ = new tree_classdef_body ($1); } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1686 | class_body opt_sep properties_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1687 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1688 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1689 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1690 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1691 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1692 } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1693 | class_body opt_sep methods_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1694 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1695 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1696 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1697 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1698 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1699 } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1700 | class_body opt_sep events_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1701 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1702 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1703 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1704 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1705 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1706 } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1707 | class_body opt_sep enum_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1708 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1709 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1710 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1711 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1712 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1713 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1714 ; |
9476 | 1715 |
1716 properties_block | |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1717 : PROPERTIES stash_comment opt_attr_list opt_sep property_list opt_sep END |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1718 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1719 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1720 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1721 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1722 if (! ($$ = parser.make_classdef_properties_block |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1723 ($1, $3, $5, $7, $2))) |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1724 { |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1725 // make_classdef_properties_block delete $3 and $5. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1726 YYABORT; |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1727 } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1728 } |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1729 | PROPERTIES stash_comment opt_attr_list opt_sep END |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1730 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1731 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1732 |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1733 if (! ($$ = parser.make_classdef_properties_block |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1734 ($1, $3, 0, $5, $2))) |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1735 { |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1736 // make_classdef_properties_block delete $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1737 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1738 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1739 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1740 ; |
9476 | 1741 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1742 property_list |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1743 : class_property |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1744 { $$ = new tree_classdef_property_list ($1); } |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1745 | property_list opt_sep class_property |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1746 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1747 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1748 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1749 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1750 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1751 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1752 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1753 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1754 class_property : identifier |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1755 { $$ = new tree_classdef_property ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1756 | identifier '=' decl_param_init expression ';' |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1757 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1758 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1759 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1760 lexer.looking_at_initializer_expression = false; |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1761 $$ = new tree_classdef_property ($1, $4); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1762 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1763 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1764 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1765 methods_block : METHODS stash_comment opt_attr_list opt_sep methods_list opt_sep END |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1766 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1767 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1768 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1769 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1770 if (! ($$ = parser.make_classdef_methods_block |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1771 ($1, $3, $5, $7, $2))) |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1772 { |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1773 // make_classdef_methods_block deleted $3 and $5. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1774 YYABORT; |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1775 } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1776 } |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1777 | METHODS stash_comment opt_attr_list opt_sep END |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1778 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1779 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1780 |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1781 if (! ($$ = parser.make_classdef_methods_block |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1782 ($1, $3, 0, $5, $2))) |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1783 { |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1784 // make_classdef_methods_block deleted $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1785 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1786 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1787 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1788 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1789 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1790 |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1791 method_decl1 : identifier |
18308
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
1792 { |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1793 if (! ($$ = parser.start_classdef_external_method ($1, 0))) |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1794 YYABORT; |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1795 } |
18308
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
1796 | identifier param_list |
18341
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1797 { |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1798 if (! ($$ = parser.start_classdef_external_method ($1, $2))) |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1799 YYABORT; |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1800 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1801 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1802 |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1803 method_decl : stash_comment method_decl1 |
18308
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
1804 { $$ = parser.finish_classdef_external_method ($2, 0, $1); } |
18341
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1805 | stash_comment return_list '=' |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1806 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1807 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1808 |
18341
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1809 lexer.defining_func++; |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1810 lexer.parsed_function_name.push (false); |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1811 } |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1812 method_decl1 |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1813 { |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1814 lexer.defining_func--; |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1815 lexer.parsed_function_name.pop (); |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1816 $$ = parser.finish_classdef_external_method ($5, $2, $1); |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1817 } |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1818 ; |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1819 |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1820 method : method_decl |
18308
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
1821 { $$ = $1; } |
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
1822 | function |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1823 { $$ = $1; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1824 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1825 |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1826 methods_list : method |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1827 { |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1828 octave_value fcn; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1829 if ($1) |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1830 fcn = $1->function (); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1831 delete $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1832 $$ = new tree_classdef_methods_list (fcn); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1833 } |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1834 | methods_list opt_sep method |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1835 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1836 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1837 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1838 octave_value fcn; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1839 if ($3) |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1840 fcn = $3->function (); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1841 delete $3; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1842 |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1843 $1->append (fcn); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1844 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1845 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1846 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1847 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1848 events_block : EVENTS stash_comment opt_attr_list opt_sep events_list opt_sep END |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1849 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1850 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1851 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1852 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1853 if (! ($$ = parser.make_classdef_events_block |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1854 ($1, $3, $5, $7, $2))) |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1855 { |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1856 // make_classdef_events_block deleted $3 and $5. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1857 YYABORT; |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1858 } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1859 } |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1860 | EVENTS stash_comment opt_attr_list opt_sep END |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1861 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1862 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1863 |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1864 if (! ($$ = parser.make_classdef_events_block |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1865 ($1, $3, 0, $5, $2))) |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1866 { |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1867 // make_classdef_events_block deleted $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1868 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1869 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1870 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1871 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1872 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1873 events_list : class_event |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1874 { $$ = new tree_classdef_events_list ($1); } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1875 | events_list opt_sep class_event |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1876 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1877 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1878 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1879 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1880 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1881 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1882 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1883 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1884 class_event : identifier |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1885 { $$ = new tree_classdef_event ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1886 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1887 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1888 enum_block : ENUMERATION stash_comment opt_attr_list opt_sep enum_list opt_sep END |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1889 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1890 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1891 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1892 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1893 if (! ($$ = parser.make_classdef_enum_block |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1894 ($1, $3, $5, $7, $2))) |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1895 { |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1896 // make_classdef_enum_block deleted $3 and $5. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1897 YYABORT; |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1898 } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1899 } |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1900 | ENUMERATION stash_comment opt_attr_list opt_sep END |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1901 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1902 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1903 |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1904 if (! ($$ = parser.make_classdef_enum_block |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1905 ($1, $3, 0, $5, $2))) |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1906 { |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1907 // make_classdef_enum_block deleted $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1908 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1909 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1910 } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1911 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1912 |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1913 enum_list : class_enum |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1914 { $$ = new tree_classdef_enum_list ($1); } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1915 | enum_list opt_sep class_enum |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1916 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1917 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1918 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1919 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1920 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1921 } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1922 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1923 |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1924 class_enum : identifier '(' expression ')' |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1925 { $$ = new tree_classdef_enum ($1, $3); } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1926 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1927 |
2970 | 1928 // ============= |
1929 // Miscellaneous | |
1930 // ============= | |
1931 | |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1932 stmt_begin : // empty |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1933 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1934 $$ = 0; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1935 lexer.at_beginning_of_statement = true; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1936 } |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1937 ; |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1938 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1939 stash_comment : // empty |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
1940 { $$ = lexer.get_comment (); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1941 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1942 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1943 parse_error : LEXICAL_ERROR |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1944 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1945 $$ = 0; |
21064
a9f2c2d72892
handle lexical errors as parser errors (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21063
diff
changeset
|
1946 std::string msg = $1->text (); |
a9f2c2d72892
handle lexical errors as parser errors (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21063
diff
changeset
|
1947 parser.bison_error (msg.c_str ()); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1948 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1949 | error |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1950 { $$ = 0; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1951 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1952 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1953 sep_no_nl : ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1954 { $$ = ','; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1955 | ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1956 { $$ = ';'; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1957 | sep_no_nl ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1958 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1959 | sep_no_nl ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1960 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1961 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1962 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1963 opt_sep_no_nl : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1964 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1965 | sep_no_nl |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1966 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1967 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1968 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1969 opt_nl : // empty |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1970 { $$ = 0; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1971 | nl |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1972 { $$ = $1; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1973 ; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1974 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1975 nl : '\n' |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1976 { $$ = '\n'; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1977 | nl '\n' |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1978 { $$ = $1; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1979 ; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1980 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1981 sep : ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1982 { $$ = ','; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1983 | ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1984 { $$ = ';'; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1985 | '\n' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1986 { $$ = '\n'; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1987 | sep ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1988 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1989 | sep ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1990 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1991 | sep '\n' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1992 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1993 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1994 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1995 opt_sep : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1996 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1997 | sep |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1998 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1999 ; |
2525 | 2000 |
1 | 2001 %% |
2002 | |
21023
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2003 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2004 // Restore prevailing warning state for remainder of the file. |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2005 #pragma GCC diagnostic pop |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2006 #endif |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2007 |
666 | 2008 // Generic error messages. |
2009 | |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
2010 #undef lexer |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
2011 |
1 | 2012 static void |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2013 yyerror (octave::base_parser& parser, const char *s) |
1 | 2014 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
2015 parser.bison_error (s); |
16142
26d65d677557
rename yyerror to bison_error and make it a member of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
2016 } |
26d65d677557
rename yyerror to bison_error and make it a member of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
2017 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2018 namespace octave |
16157
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
2019 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2020 base_parser::base_parser (base_lexer& lxr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2021 : endfunction_found (false), autoloading (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2022 fcn_file_from_relative_lookup (false), parsing_subfunctions (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2023 max_fcn_depth (0), curr_fcn_depth (0), primary_fcn_scope (-1), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2024 curr_class_name (), curr_package_name (), function_scopes (), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2025 primary_fcn_ptr (0), subfunction_names (), classdef_object (0), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2026 stmt_list (0), lexer (lxr), parser_state (yypstate_new ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2027 { } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2028 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2029 base_parser::~base_parser (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2030 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2031 delete stmt_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2032 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2033 delete &lexer; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2034 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2035 // FIXME: Deleting the internal Bison parser state structure does |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2036 // not clean up any partial parse trees in the event of an interrupt or |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2037 // error. It's not clear how to safely do that with the C language |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2038 // parser that Bison generates. The C++ language parser that Bison |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2039 // generates would do it for us automatically whenever an exception |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2040 // is thrown while parsing input, but there is currently no C++ |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2041 // interface for a push parser. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2042 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2043 yypstate_delete (static_cast<yypstate *> (parser_state)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2044 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2045 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2046 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2047 base_parser::reset (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2048 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2049 endfunction_found = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2050 autoloading = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2051 fcn_file_from_relative_lookup = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2052 parsing_subfunctions = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2053 max_fcn_depth = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2054 curr_fcn_depth = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2055 primary_fcn_scope = -1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2056 curr_class_name = ""; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2057 curr_package_name = ""; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2058 function_scopes.clear (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2059 primary_fcn_ptr = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2060 subfunction_names.clear (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2061 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2062 delete stmt_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2063 stmt_list = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2064 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2065 lexer.reset (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2066 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2067 yypstate_delete (static_cast<yypstate *> (parser_state)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2068 parser_state = yypstate_new (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2069 } |
16138
284e2ca86ef7
execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16136
diff
changeset
|
2070 } |
284e2ca86ef7
execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16136
diff
changeset
|
2071 |
666 | 2072 // Error mesages for mismatched end tokens. |
2073 | |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2074 static std::string |
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2075 end_token_as_string (token::end_tok_type ettype) |
496 | 2076 { |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2077 std::string retval = "<unknown>"; |
496 | 2078 |
2079 switch (ettype) | |
2080 { | |
2081 case token::simple_end: | |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2082 retval = "end"; |
496 | 2083 break; |
777 | 2084 |
20075
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2085 case token::classdef_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2086 retval = "endclassdef"; |
20075
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2087 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2088 |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2089 case token::enumeration_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2090 retval = "endenumeration"; |
20075
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2091 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2092 |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2093 case token::events_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2094 retval = "endevents"; |
20075
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2095 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2096 |
496 | 2097 case token::for_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2098 retval = "endfor"; |
496 | 2099 break; |
777 | 2100 |
496 | 2101 case token::function_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2102 retval = "endfunction"; |
496 | 2103 break; |
777 | 2104 |
496 | 2105 case token::if_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2106 retval = "endif"; |
496 | 2107 break; |
777 | 2108 |
20075
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2109 case token::methods_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2110 retval = "endmethods"; |
20075
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2111 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2112 |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2113 case token::parfor_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2114 retval = "endparfor"; |
20075
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2115 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2116 |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2117 case token::properties_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2118 retval = "endproperties"; |
20075
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2119 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2120 |
3233 | 2121 case token::switch_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2122 retval = "endswitch"; |
3233 | 2123 break; |
2124 | |
5400 | 2125 case token::try_catch_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2126 retval = "end_try_catch"; |
5400 | 2127 break; |
2128 | |
1371 | 2129 case token::unwind_protect_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2130 retval = "end_unwind_protect"; |
1371 | 2131 break; |
2132 | |
20075
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2133 case token::while_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2134 retval = "endwhile"; |
20075
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2135 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2136 |
496 | 2137 default: |
2138 panic_impossible (); | |
2139 break; | |
2140 } | |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2141 |
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2142 return retval; |
496 | 2143 } |
2144 | |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2145 namespace octave |
578 | 2146 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2147 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2148 base_parser::end_token_error (token *tok, token::end_tok_type expected) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2149 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2150 std::string msg = ("'" + end_token_as_string (expected) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2151 + "' command matched by '" |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2152 + end_token_as_string (tok->ettype ()) + "'"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2153 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2154 bison_error (msg, tok->line (), tok->column ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2155 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2156 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2157 // Check to see that end tokens are properly matched. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2158 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2159 bool |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2160 base_parser::end_token_ok (token *tok, token::end_tok_type expected) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2161 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2162 token::end_tok_type ettype = tok->ettype (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2163 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2164 return ettype == expected || ettype == token::simple_end; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2165 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2166 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2167 // Maybe print a warning if an assignment expression is used as the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2168 // test in a logical expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2169 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2170 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2171 base_parser::maybe_warn_assign_as_truth_value (tree_expression *expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2172 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2173 if (expr->is_assignment_expression () |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2174 && expr->paren_count () < 2) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2175 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2176 if (lexer.fcn_file_full_name.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2177 warning_with_id |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2178 ("Octave:assign-as-truth-value", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2179 "suggest parenthesis around assignment used as truth value"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2180 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2181 warning_with_id |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2182 ("Octave:assign-as-truth-value", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2183 "suggest parenthesis around assignment used as truth value near line %d, column %d in file '%s'", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2184 expr->line (), expr->column (), lexer.fcn_file_full_name.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2185 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2186 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2187 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2188 // Maybe print a warning about switch labels that aren't constants. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2189 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2190 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2191 base_parser::maybe_warn_variable_switch_label (tree_expression *expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2192 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2193 if (! expr->is_constant ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2194 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2195 if (lexer.fcn_file_full_name.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2196 warning_with_id ("Octave:variable-switch-label", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2197 "variable switch label"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2198 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2199 warning_with_id |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2200 ("Octave:variable-switch-label", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2201 "variable switch label near line %d, column %d in file '%s'", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2202 expr->line (), expr->column (), lexer.fcn_file_full_name.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2203 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2204 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2205 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2206 // Finish building a range. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2207 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2208 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2209 base_parser::finish_colon_expression (tree_colon_expression *e) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2210 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2211 tree_expression *retval = e; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2212 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2213 octave::unwind_protect frame; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2214 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2215 frame.protect_var (discard_error_messages); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2216 frame.protect_var (discard_warning_messages); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2217 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2218 discard_error_messages = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2219 discard_warning_messages = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2220 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2221 tree_expression *base = e->base (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2222 tree_expression *limit = e->limit (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2223 tree_expression *incr = e->increment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2224 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2225 if (base) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2226 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2227 if (limit) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2228 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2229 if (base->is_constant () && limit->is_constant () |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2230 && (! incr || (incr && incr->is_constant ()))) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2231 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2232 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2233 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2234 octave_value tmp = e->rvalue1 (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2235 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2236 tree_constant *tc_retval |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2237 = new tree_constant (tmp, base->line (), base->column ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2238 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2239 std::ostringstream buf; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2240 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2241 tree_print_code tpc (buf); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2242 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2243 e->accept (tpc); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2244 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2245 tc_retval->stash_original_text (buf.str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2246 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2247 delete e; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2248 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2249 retval = tc_retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2250 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
2251 catch (const octave::execution_exception&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2252 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2253 recover_from_exception (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2254 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2255 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2256 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2257 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2258 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2259 e->preserve_base (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2260 delete e; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2261 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2262 retval = base; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2263 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2264 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2265 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2266 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2267 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2268 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2269 // Make a constant. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2270 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2271 tree_constant * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2272 base_parser::make_constant (int op, token *tok_val) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2273 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2274 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2275 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2276 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2277 tree_constant *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2278 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2279 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2280 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2281 case NUM: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2282 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2283 octave_value tmp (tok_val->number ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2284 retval = new tree_constant (tmp, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2285 retval->stash_original_text (tok_val->text_rep ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2286 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2287 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2288 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2289 case IMAG_NUM: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2290 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2291 octave_value tmp (Complex (0.0, tok_val->number ())); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2292 retval = new tree_constant (tmp, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2293 retval->stash_original_text (tok_val->text_rep ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2294 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2295 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2296 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2297 case DQ_STRING: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2298 case SQ_STRING: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2299 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2300 std::string txt = tok_val->text (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2301 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2302 char delim = op == DQ_STRING ? '"' : '\''; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2303 octave_value tmp (txt, delim); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2304 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2305 if (txt.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2306 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2307 if (op == DQ_STRING) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2308 tmp = octave_null_str::instance; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2309 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2310 tmp = octave_null_sq_str::instance; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2311 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2312 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2313 retval = new tree_constant (tmp, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2314 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2315 if (op == DQ_STRING) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2316 txt = undo_string_escapes (txt); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2317 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2318 // FIXME: maybe this should also be handled by |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2319 // tok_val->text_rep () for character strings? |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2320 retval->stash_original_text (delim + txt + delim); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2321 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2322 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2323 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2324 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2325 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2326 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2327 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2328 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2329 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2330 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2331 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2332 // Make a function handle. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2333 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2334 tree_fcn_handle * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2335 base_parser::make_fcn_handle (token *tok_val) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2336 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2337 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2338 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2339 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2340 tree_fcn_handle *retval = new tree_fcn_handle (tok_val->text (), l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2341 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2342 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2343 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2344 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2345 // Make an anonymous function handle. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2346 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2347 tree_anon_fcn_handle * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2348 base_parser::make_anon_fcn_handle (tree_parameter_list *param_list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2349 tree_statement *stmt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2350 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2351 // FIXME: need to get these from the location of the @ symbol. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2352 int l = lexer.input_line_number; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2353 int c = lexer.current_input_column; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2354 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2355 tree_parameter_list *ret_list = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2356 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2357 symbol_table::scope_id fcn_scope = lexer.symtab_context.curr_scope (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2358 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2359 lexer.symtab_context.pop (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2360 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2361 stmt->set_print_flag (false); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2362 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2363 tree_statement_list *body = new tree_statement_list (stmt); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2364 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2365 body->mark_as_anon_function_body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2366 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2367 tree_anon_fcn_handle *retval |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2368 = new tree_anon_fcn_handle (param_list, ret_list, body, fcn_scope, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2369 // FIXME: Stash the filename. This does not work and produces |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2370 // errors when executed. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2371 //retval->stash_file_name (lexer.fcn_file_name); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2372 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2373 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2374 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2375 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2376 // Build a binary expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2377 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2378 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2379 base_parser::make_binary_op (int op, tree_expression *op1, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2380 token *tok_val, tree_expression *op2) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2381 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2382 octave_value::binary_op t = octave_value::unknown_binary_op; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2383 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2384 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2385 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2386 case POW: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2387 t = octave_value::op_pow; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2388 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2389 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2390 case EPOW: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2391 t = octave_value::op_el_pow; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2392 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2393 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2394 case '+': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2395 t = octave_value::op_add; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2396 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2397 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2398 case '-': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2399 t = octave_value::op_sub; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2400 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2401 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2402 case '*': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2403 t = octave_value::op_mul; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2404 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2405 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2406 case '/': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2407 t = octave_value::op_div; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2408 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2409 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2410 case EMUL: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2411 t = octave_value::op_el_mul; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2412 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2413 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2414 case EDIV: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2415 t = octave_value::op_el_div; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2416 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2417 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2418 case LEFTDIV: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2419 t = octave_value::op_ldiv; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2420 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2421 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2422 case ELEFTDIV: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2423 t = octave_value::op_el_ldiv; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2424 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2425 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2426 case EXPR_LT: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2427 t = octave_value::op_lt; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2428 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2429 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2430 case EXPR_LE: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2431 t = octave_value::op_le; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2432 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2433 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2434 case EXPR_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2435 t = octave_value::op_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2436 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2437 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2438 case EXPR_GE: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2439 t = octave_value::op_ge; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2440 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2441 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2442 case EXPR_GT: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2443 t = octave_value::op_gt; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2444 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2445 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2446 case EXPR_NE: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2447 t = octave_value::op_ne; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2448 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2449 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2450 case EXPR_AND: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2451 t = octave_value::op_el_and; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2452 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2453 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2454 case EXPR_OR: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2455 t = octave_value::op_el_or; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2456 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2457 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2458 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2459 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2460 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2461 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2462 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2463 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2464 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2465 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2466 return maybe_compound_binary_expression (op1, op2, l, c, t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2467 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2468 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2469 // Build a boolean expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2470 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2471 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2472 base_parser::make_boolean_op (int op, tree_expression *op1, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2473 token *tok_val, tree_expression *op2) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2474 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2475 tree_boolean_expression::type t; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2476 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2477 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2478 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2479 case EXPR_AND_AND: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2480 t = tree_boolean_expression::bool_and; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2481 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2482 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2483 case EXPR_OR_OR: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2484 t = tree_boolean_expression::bool_or; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2485 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2486 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2487 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2488 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2489 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2490 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2491 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2492 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2493 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2494 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2495 return new tree_boolean_expression (op1, op2, l, c, t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2496 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2497 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2498 // Build a prefix expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2499 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2500 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2501 base_parser::make_prefix_op (int op, tree_expression *op1, token *tok_val) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2502 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2503 octave_value::unary_op t = octave_value::unknown_unary_op; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2504 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2505 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2506 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2507 case EXPR_NOT: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2508 t = octave_value::op_not; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2509 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2510 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2511 case '+': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2512 t = octave_value::op_uplus; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2513 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2514 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2515 case '-': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2516 t = octave_value::op_uminus; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2517 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2518 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2519 case PLUS_PLUS: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2520 t = octave_value::op_incr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2521 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2522 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2523 case MINUS_MINUS: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2524 t = octave_value::op_decr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2525 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2526 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2527 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2528 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2529 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2530 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2531 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2532 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2533 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2534 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2535 return new tree_prefix_expression (op1, l, c, t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2536 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2537 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2538 // Build a postfix expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2539 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2540 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2541 base_parser::make_postfix_op (int op, tree_expression *op1, token *tok_val) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2542 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2543 octave_value::unary_op t = octave_value::unknown_unary_op; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2544 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2545 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2546 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2547 case HERMITIAN: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2548 t = octave_value::op_hermitian; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2549 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2550 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2551 case TRANSPOSE: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2552 t = octave_value::op_transpose; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2553 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2554 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2555 case PLUS_PLUS: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2556 t = octave_value::op_incr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2557 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2558 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2559 case MINUS_MINUS: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2560 t = octave_value::op_decr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2561 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2562 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2563 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2564 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2565 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2566 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2567 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2568 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2569 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2570 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2571 return new tree_postfix_expression (op1, l, c, t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2572 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2573 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2574 // Build an unwind-protect command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2575 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2576 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2577 base_parser::make_unwind_command (token *unwind_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2578 tree_statement_list *body, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2579 tree_statement_list *cleanup_stmts, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2580 token *end_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2581 octave_comment_list *lc, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2582 octave_comment_list *mc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2583 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2584 tree_command *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2585 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2586 if (end_token_ok (end_tok, token::unwind_protect_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2587 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2588 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2589 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2590 int l = unwind_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2591 int c = unwind_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2592 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2593 retval = new tree_unwind_protect_command (body, cleanup_stmts, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2594 lc, mc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2595 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2596 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2597 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2598 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2599 delete cleanup_stmts; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2600 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2601 end_token_error (end_tok, token::unwind_protect_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2602 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2603 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2604 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2605 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2606 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2607 // Build a try-catch command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2608 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2609 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2610 base_parser::make_try_command (token *try_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2611 tree_statement_list *body, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2612 char catch_sep, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2613 tree_statement_list *cleanup_stmts, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2614 token *end_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2615 octave_comment_list *lc, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2616 octave_comment_list *mc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2617 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2618 tree_command *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2619 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2620 if (end_token_ok (end_tok, token::try_catch_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2621 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2622 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2623 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2624 int l = try_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2625 int c = try_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2626 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2627 tree_identifier *id = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2628 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2629 if (! catch_sep && cleanup_stmts && ! cleanup_stmts->empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2630 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2631 tree_statement *stmt = cleanup_stmts->front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2632 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2633 if (stmt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2634 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2635 tree_expression *expr = stmt->expression (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2636 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2637 if (expr && expr->is_identifier ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2638 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2639 id = dynamic_cast<tree_identifier *> (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2640 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2641 cleanup_stmts->pop_front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2642 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2643 stmt->set_expression (0); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2644 delete stmt; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2645 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2646 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2647 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2648 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2649 retval = new tree_try_catch_command (body, cleanup_stmts, id, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2650 lc, mc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2651 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2652 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2653 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2654 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2655 delete cleanup_stmts; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2656 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2657 end_token_error (end_tok, token::try_catch_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2658 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2659 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2660 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2661 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2662 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2663 // Build a while command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2664 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2665 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2666 base_parser::make_while_command (token *while_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2667 tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2668 tree_statement_list *body, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2669 token *end_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2670 octave_comment_list *lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2671 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2672 tree_command *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2673 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2674 maybe_warn_assign_as_truth_value (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2675 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2676 if (end_token_ok (end_tok, token::while_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2677 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2678 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2679 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2680 lexer.looping--; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2681 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2682 int l = while_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2683 int c = while_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2684 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2685 retval = new tree_while_command (expr, body, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2686 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2687 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2688 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2689 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2690 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2691 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2692 end_token_error (end_tok, token::while_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2693 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2694 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2695 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2696 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2697 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2698 // Build a do-until command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2699 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2700 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2701 base_parser::make_do_until_command (token *until_tok, |
16287
04a7953496a7
create base class for parser; use reference for curr_lexer
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
2702 tree_statement_list *body, |
04a7953496a7
create base class for parser; use reference for curr_lexer
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
2703 tree_expression *expr, |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2704 octave_comment_list *lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2705 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2706 maybe_warn_assign_as_truth_value (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2707 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2708 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2709 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2710 lexer.looping--; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2711 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2712 int l = until_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2713 int c = until_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2714 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2715 return new tree_do_until_command (expr, body, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2716 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2717 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2718 // Build a for command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2719 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2720 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2721 base_parser::make_for_command (int tok_id, token *for_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2722 tree_argument_list *lhs, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2723 tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2724 tree_expression *maxproc, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2725 tree_statement_list *body, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2726 token *end_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2727 octave_comment_list *lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2728 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2729 tree_command *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2730 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2731 bool parfor = tok_id == PARFOR; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2732 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2733 if (end_token_ok (end_tok, parfor ? token::parfor_end : token::for_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2734 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2735 expr->mark_as_for_cmd_expr (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2736 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2737 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2738 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2739 lexer.looping--; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2740 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2741 int l = for_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2742 int c = for_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2743 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2744 if (lhs->length () == 1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2745 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2746 tree_expression *tmp = lhs->remove_front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2747 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2748 retval = new tree_simple_for_command (parfor, tmp, expr, maxproc, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2749 body, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2750 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2751 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2752 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2753 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2754 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2755 if (parfor) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2756 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2757 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2758 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2759 delete maxproc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2760 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2761 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2762 bison_error ("invalid syntax for parfor statement"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2763 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2764 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2765 retval = new tree_complex_for_command (lhs, expr, body, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2766 lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2767 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2768 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2769 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2770 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2771 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2772 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2773 delete maxproc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2774 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2775 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2776 end_token_error (end_tok, parfor ? token::parfor_end : token::for_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2777 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2778 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2779 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2780 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2781 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2782 // Build a break command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2783 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2784 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2785 base_parser::make_break_command (token *break_tok) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2786 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2787 int l = break_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2788 int c = break_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2789 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2790 return new tree_break_command (l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2791 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2792 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2793 // Build a continue command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2794 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2795 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2796 base_parser::make_continue_command (token *continue_tok) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2797 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2798 int l = continue_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2799 int c = continue_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2800 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2801 return new tree_continue_command (l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2802 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2803 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2804 // Build a return command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2805 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2806 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2807 base_parser::make_return_command (token *return_tok) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2808 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2809 int l = return_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2810 int c = return_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2811 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2812 return new tree_return_command (l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2813 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2814 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2815 // Start an if command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2816 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2817 tree_if_command_list * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2818 base_parser::start_if_command (tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2819 tree_statement_list *list) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2820 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2821 maybe_warn_assign_as_truth_value (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2822 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2823 tree_if_clause *t = new tree_if_clause (expr, list); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2824 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2825 return new tree_if_command_list (t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2826 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2827 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2828 // Finish an if command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2829 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2830 tree_if_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2831 base_parser::finish_if_command (token *if_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2832 tree_if_command_list *list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2833 token *end_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2834 octave_comment_list *lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2835 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2836 tree_if_command *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2837 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2838 if (end_token_ok (end_tok, token::if_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2839 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2840 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2841 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2842 int l = if_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2843 int c = if_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2844 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2845 if (list && ! list->empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2846 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2847 tree_if_clause *elt = list->front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2848 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2849 if (elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2850 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2851 elt->line (l); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2852 elt->column (c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2853 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2854 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2855 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2856 retval = new tree_if_command (list, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2857 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2858 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2859 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2860 delete list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2861 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2862 end_token_error (end_tok, token::if_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2863 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2864 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2865 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2866 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2867 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2868 // Build an elseif clause. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2869 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2870 tree_if_clause * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2871 base_parser::make_elseif_clause (token *elseif_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2872 tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2873 tree_statement_list *list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2874 octave_comment_list *lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2875 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2876 maybe_warn_assign_as_truth_value (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2877 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2878 int l = elseif_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2879 int c = elseif_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2880 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2881 return new tree_if_clause (expr, list, lc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2882 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2883 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2884 // Finish a switch command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2885 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2886 tree_switch_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2887 base_parser::finish_switch_command (token *switch_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2888 tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2889 tree_switch_case_list *list, |
16287
04a7953496a7
create base class for parser; use reference for curr_lexer
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
2890 token *end_tok, |
04a7953496a7
create base class for parser; use reference for curr_lexer
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
2891 octave_comment_list *lc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2892 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2893 tree_switch_command *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2894 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2895 if (end_token_ok (end_tok, token::switch_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2896 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2897 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2898 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2899 int l = switch_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2900 int c = switch_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2901 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2902 if (list && ! list->empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2903 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2904 tree_switch_case *elt = list->front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2905 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2906 if (elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2907 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2908 elt->line (l); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2909 elt->column (c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2910 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2911 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2912 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2913 retval = new tree_switch_command (expr, list, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2914 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2915 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2916 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2917 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2918 delete list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2919 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2920 end_token_error (end_tok, token::switch_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2921 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2922 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2923 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2924 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2925 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2926 // Build a switch case. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2927 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2928 tree_switch_case * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2929 base_parser::make_switch_case (token *case_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2930 tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2931 tree_statement_list *list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2932 octave_comment_list *lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2933 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2934 maybe_warn_variable_switch_label (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2935 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2936 int l = case_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2937 int c = case_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2938 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2939 return new tree_switch_case (expr, list, lc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2940 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2941 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2942 // Build an assignment to a variable. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2943 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2944 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2945 base_parser::make_assign_op (int op, tree_argument_list *lhs, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2946 token *eq_tok, tree_expression *rhs) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2947 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2948 octave_value::assign_op t = octave_value::unknown_assign_op; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2949 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2950 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2951 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2952 case '=': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2953 t = octave_value::op_asn_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2954 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2955 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2956 case ADD_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2957 t = octave_value::op_add_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2958 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2959 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2960 case SUB_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2961 t = octave_value::op_sub_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2962 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2963 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2964 case MUL_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2965 t = octave_value::op_mul_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2966 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2967 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2968 case DIV_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2969 t = octave_value::op_div_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2970 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2971 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2972 case LEFTDIV_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2973 t = octave_value::op_ldiv_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2974 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2975 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2976 case POW_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2977 t = octave_value::op_pow_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2978 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2979 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2980 case EMUL_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2981 t = octave_value::op_el_mul_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2982 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2983 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2984 case EDIV_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2985 t = octave_value::op_el_div_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2986 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2987 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2988 case ELEFTDIV_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2989 t = octave_value::op_el_ldiv_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2990 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2991 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2992 case EPOW_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2993 t = octave_value::op_el_pow_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2994 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2995 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2996 case AND_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2997 t = octave_value::op_el_and_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2998 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2999 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3000 case OR_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3001 t = octave_value::op_el_or_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3002 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3003 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3004 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3005 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3006 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3007 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3008 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3009 int l = eq_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3010 int c = eq_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3011 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3012 if (! lhs->is_simple_assign_lhs () && t != octave_value::op_asn_eq) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3013 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3014 // Multiple assignments like [x,y] OP= rhs are only valid for |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3015 // '=', not '+=', etc. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3016 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3017 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3018 delete rhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3019 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3020 bison_error ("computed multiple assignment not allowed", l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3021 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3022 return 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3023 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3024 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3025 if (lhs->is_simple_assign_lhs ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3026 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3027 // We are looking at a simple assignment statement like x = rhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3028 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3029 tree_expression *tmp = lhs->remove_front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3030 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3031 if ((tmp->is_identifier () || tmp->is_index_expression ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3032 && is_keyword (tmp->name ())) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3033 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3034 std::string kw = tmp->name (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3035 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3036 delete tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3037 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3038 delete rhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3039 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3040 bison_error ("invalid assignment to keyword \"" + kw + "\"", l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3041 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3042 return 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3043 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3044 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3045 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3046 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3047 return new tree_simple_assignment (tmp, rhs, false, l, c, t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3048 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3049 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3050 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3051 std::list<std::string> names = lhs->variable_names (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3052 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3053 for (std::list<std::string>::const_iterator it = names.begin (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3054 it != names.end (); it++) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3055 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3056 std::string kw = *it; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3057 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3058 if (is_keyword (kw)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3059 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3060 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3061 delete rhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3062 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3063 bison_error ("invalid assignment to keyword \"" + kw + "\"", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3064 l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3065 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3066 return 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3067 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3068 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3069 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3070 return new tree_multi_assignment (lhs, rhs, false, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3071 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3072 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3073 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3074 // Define a script. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3075 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3076 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3077 base_parser::make_script (tree_statement_list *cmds, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3078 tree_statement *end_script) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3079 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3080 if (! cmds) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3081 cmds = new tree_statement_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3082 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3083 cmds->append (end_script); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3084 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3085 octave_user_script *script |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3086 = new octave_user_script (lexer.fcn_file_full_name, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3087 lexer.fcn_file_name, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3088 cmds, lexer.help_text); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3089 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3090 lexer.help_text = ""; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3091 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3092 octave::sys::time now; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3093 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3094 script->stash_fcn_file_time (now); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3095 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3096 primary_fcn_ptr = script; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3097 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3098 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3099 // Begin defining a function. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3100 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3101 octave_user_function * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3102 base_parser::start_function (tree_parameter_list *param_list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3103 tree_statement_list *body, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3104 tree_statement *end_fcn_stmt) |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3105 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3106 // We'll fill in the return list later. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3107 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3108 if (! body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3109 body = new tree_statement_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3110 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3111 body->append (end_fcn_stmt); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3112 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3113 octave_user_function *fcn |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3114 = new octave_user_function (lexer.symtab_context.curr_scope (), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3115 param_list, 0, body); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3116 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3117 if (fcn) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3118 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3119 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3120 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3121 fcn->stash_trailing_comment (tc); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3122 fcn->stash_fcn_end_location (end_fcn_stmt->line (), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3123 end_fcn_stmt->column ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3124 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3125 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3126 return fcn; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3127 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3128 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3129 tree_statement * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3130 base_parser::make_end (const std::string& type, bool eof, int l, int c) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3131 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3132 return make_statement (new tree_no_op_command (type, eof, l, c)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3133 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3134 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3135 // Do most of the work for defining a function. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3136 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3137 octave_user_function * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3138 base_parser::frob_function (const std::string& fname, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3139 octave_user_function *fcn) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3140 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3141 std::string id_name = fname; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3142 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3143 // If input is coming from a file, issue a warning if the name of |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3144 // the file does not match the name of the function stated in the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3145 // file. Matlab doesn't provide a diagnostic (it ignores the stated |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3146 // name). |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3147 if (! autoloading && lexer.reading_fcn_file |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3148 && curr_fcn_depth == 1 && ! parsing_subfunctions) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3149 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3150 // FIXME: should lexer.fcn_file_name already be |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3151 // preprocessed when we get here? It seems to only be a |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3152 // problem with relative filenames. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3153 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3154 std::string nm = lexer.fcn_file_name; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3155 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3156 size_t pos = nm.find_last_of (octave::sys::file_ops::dir_sep_chars ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3157 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3158 if (pos != std::string::npos) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3159 nm = lexer.fcn_file_name.substr (pos+1); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3160 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3161 if (nm != id_name) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3162 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3163 warning_with_id |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3164 ("Octave:function-name-clash", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3165 "function name '%s' does not agree with function filename '%s'", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3166 id_name.c_str (), lexer.fcn_file_full_name.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3167 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3168 id_name = nm; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3169 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3170 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3171 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3172 if (lexer.reading_fcn_file || lexer.reading_classdef_file || autoloading) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3173 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3174 octave::sys::time now; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3175 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3176 fcn->stash_fcn_file_name (lexer.fcn_file_full_name); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3177 fcn->stash_fcn_file_time (now); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3178 fcn->mark_as_system_fcn_file (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3179 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3180 if (fcn_file_from_relative_lookup) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3181 fcn->mark_relative (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3182 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3183 if (curr_fcn_depth > 1 || parsing_subfunctions) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3184 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3185 fcn->stash_parent_fcn_name (lexer.fcn_file_name); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3186 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3187 if (curr_fcn_depth > 1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3188 fcn->stash_parent_fcn_scope (function_scopes[function_scopes.size ()-2]); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3189 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3190 fcn->stash_parent_fcn_scope (primary_fcn_scope); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3191 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3192 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3193 if (lexer.parsing_class_method) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3194 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3195 if (curr_class_name == id_name) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3196 fcn->mark_as_class_constructor (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3197 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3198 fcn->mark_as_class_method (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3199 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3200 fcn->stash_dispatch_class (curr_class_name); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3201 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3202 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3203 std::string nm = fcn->fcn_file_name (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3204 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3205 octave::sys::file_stat fs (nm); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3206 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3207 if (fs && fs.is_newer (now)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3208 warning_with_id ("Octave:future-time-stamp", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3209 "time stamp for '%s' is in the future", nm.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3210 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3211 else if (! input_from_tmp_history_file |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3212 && ! lexer.force_script |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3213 && lexer.reading_script_file |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3214 && lexer.fcn_file_name == id_name) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3215 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3216 warning ("function '%s' defined within script file '%s'", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3217 id_name.c_str (), lexer.fcn_file_full_name.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3218 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3219 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3220 fcn->stash_function_name (id_name); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3221 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3222 if (! lexer.help_text.empty () && curr_fcn_depth == 1 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3223 && ! parsing_subfunctions) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3224 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3225 fcn->document (lexer.help_text); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3226 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3227 lexer.help_text = ""; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3228 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3229 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3230 if (lexer.reading_fcn_file && curr_fcn_depth == 1 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3231 && ! parsing_subfunctions) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3232 primary_fcn_ptr = fcn; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3233 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3234 return fcn; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3235 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3236 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3237 tree_function_def * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3238 base_parser::finish_function (tree_parameter_list *ret_list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3239 octave_user_function *fcn, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3240 octave_comment_list *lc, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3241 int l, int c) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3242 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3243 tree_function_def *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3244 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3245 if (ret_list) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3246 ret_list->mark_as_formal_parameters (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3247 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3248 if (fcn) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3249 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3250 std::string nm = fcn->name (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3251 std::string file = fcn->fcn_file_name (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3252 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3253 std::string tmp = nm; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3254 if (! file.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3255 tmp += ": " + file; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3256 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3257 symbol_table::cache_name (fcn->scope (), tmp); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3258 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3259 if (lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3260 fcn->stash_leading_comment (lc); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3261 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3262 fcn->define_ret_list (ret_list); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3263 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3264 if (curr_fcn_depth > 1 || parsing_subfunctions) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3265 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3266 fcn->mark_as_subfunction (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3267 fcn->stash_fcn_location (l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3268 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3269 subfunction_names.push_back (nm); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3270 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3271 if (endfunction_found && function_scopes.size () > 1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3272 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3273 symbol_table::scope_id pscope |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3274 = function_scopes[function_scopes.size ()-2]; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3275 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3276 symbol_table::install_nestfunction (nm, octave_value (fcn), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3277 pscope); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3278 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3279 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3280 symbol_table::install_subfunction (nm, octave_value (fcn), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3281 primary_fcn_scope); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3282 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3283 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3284 if (curr_fcn_depth == 1 && fcn) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3285 symbol_table::update_nest (fcn->scope ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3286 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3287 if (! lexer.reading_fcn_file && curr_fcn_depth == 1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3288 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3289 // We are either reading a script file or defining a function |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3290 // at the command line, so this definition creates a |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3291 // tree_function object that is placed in the parse tree. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3292 // Otherwise, it is just inserted in the symbol table, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3293 // either as a subfunction or nested function (see above), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3294 // or as the primary function for the file, via |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3295 // primary_fcn_ptr (see also load_fcn_from_file,, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3296 // parse_fcn_file, and |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3297 // symbol_table::fcn_info::fcn_info_rep::find_user_function). |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3298 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3299 retval = new tree_function_def (fcn); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3300 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3301 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3302 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3303 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3304 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3305 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3306 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3307 base_parser::recover_from_parsing_function (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3308 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3309 lexer.symtab_context.pop (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3310 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3311 if (lexer.reading_fcn_file && curr_fcn_depth == 1 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3312 && ! parsing_subfunctions) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3313 parsing_subfunctions = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3314 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3315 curr_fcn_depth--; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3316 function_scopes.pop_back (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3317 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3318 lexer.defining_func--; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3319 lexer.parsed_function_name.pop (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3320 lexer.looking_at_return_list = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3321 lexer.looking_at_parameter_list = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3322 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3323 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3324 tree_funcall * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3325 base_parser::make_superclass_ref (const std::string& method_nm, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3326 const std::string& class_nm) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3327 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3328 octave_value_list args; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3329 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3330 args(1) = class_nm; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3331 args(0) = method_nm; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3332 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3333 octave_value fcn |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3334 = symbol_table::find_built_in_function ("__superclass_reference__"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3335 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3336 return new tree_funcall (fcn, args); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3337 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3338 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3339 tree_funcall * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3340 base_parser::make_meta_class_query (const std::string& class_nm) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3341 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3342 octave_value_list args; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3343 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3344 args(0) = class_nm; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3345 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3346 octave_value fcn |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3347 = symbol_table::find_built_in_function ("__meta_class_query__"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3348 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3349 return new tree_funcall (fcn, args); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3350 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3351 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3352 // A CLASSDEF block defines a class that has a constructor and other |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3353 // methods, but it is not an executable command. Parsing the block |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3354 // makes some changes in the symbol table (inserting the constructor |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3355 // and methods, and adding to the list of known objects) and creates |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3356 // a parse tree containing meta information about the class. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3357 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3358 tree_classdef * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3359 base_parser::make_classdef (token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3360 tree_classdef_attribute_list *a, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3361 tree_identifier *id, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3362 tree_classdef_superclass_list *sc, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3363 tree_classdef_body *body, token *end_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3364 octave_comment_list *lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3365 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3366 tree_classdef *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3367 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3368 std::string cls_name = id->name (); |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3369 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
3370 std::string nm = lexer.fcn_file_name; |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3371 |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
3372 size_t pos = nm.find_last_of (octave::sys::file_ops::dir_sep_chars ()); |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3373 |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3374 if (pos != std::string::npos) |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
3375 nm = lexer.fcn_file_name.substr (pos+1); |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3376 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3377 if (nm != cls_name) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3378 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3379 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3380 delete id; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3381 delete sc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3382 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3383 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3384 bison_error ("invalid classdef definition, the class name must match the filename"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3385 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3386 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3387 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3388 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3389 if (end_token_ok (end_tok, token::classdef_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3390 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3391 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3392 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3393 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3394 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3395 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3396 if (! body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3397 body = new tree_classdef_body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3398 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3399 retval = new tree_classdef (a, id, sc, body, lc, tc, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3400 curr_package_name, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3401 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3402 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3403 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3404 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3405 delete id; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3406 delete sc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3407 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3408 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3409 end_token_error (end_tok, token::switch_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3410 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3411 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3412 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3413 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3414 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3415 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3416 tree_classdef_properties_block * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3417 base_parser::make_classdef_properties_block (token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3418 tree_classdef_attribute_list *a, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3419 tree_classdef_property_list *plist, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3420 token *end_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3421 octave_comment_list *lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3422 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3423 tree_classdef_properties_block *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3424 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3425 if (end_token_ok (end_tok, token::properties_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3426 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3427 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3428 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3429 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3430 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3431 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3432 if (! plist) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3433 plist = new tree_classdef_property_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3434 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3435 retval = new tree_classdef_properties_block (a, plist, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3436 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3437 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3438 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3439 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3440 delete plist; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3441 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3442 end_token_error (end_tok, token::properties_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3443 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3444 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3445 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3446 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3447 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3448 tree_classdef_methods_block * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3449 base_parser::make_classdef_methods_block (token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3450 tree_classdef_attribute_list *a, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3451 tree_classdef_methods_list *mlist, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3452 token *end_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3453 octave_comment_list *lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3454 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3455 tree_classdef_methods_block *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3456 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3457 if (end_token_ok (end_tok, token::methods_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3458 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3459 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3460 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3461 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3462 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3463 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3464 if (! mlist) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3465 mlist = new tree_classdef_methods_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3466 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3467 retval = new tree_classdef_methods_block (a, mlist, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3468 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3469 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3470 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3471 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3472 delete mlist; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3473 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3474 end_token_error (end_tok, token::methods_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3475 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3476 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3477 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3478 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3479 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3480 tree_classdef_events_block * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3481 base_parser::make_classdef_events_block (token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3482 tree_classdef_attribute_list *a, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3483 tree_classdef_events_list *elist, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3484 token *end_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3485 octave_comment_list *lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3486 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3487 tree_classdef_events_block *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3488 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3489 if (end_token_ok (end_tok, token::events_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3490 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3491 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3492 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3493 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3494 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3495 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3496 if (! elist) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3497 elist = new tree_classdef_events_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3498 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3499 retval = new tree_classdef_events_block (a, elist, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3500 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3501 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3502 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3503 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3504 delete elist; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3505 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3506 end_token_error (end_tok, token::events_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3507 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3508 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3509 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3510 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3511 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3512 tree_classdef_enum_block * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3513 base_parser::make_classdef_enum_block (token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3514 tree_classdef_attribute_list *a, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3515 tree_classdef_enum_list *elist, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3516 token *end_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3517 octave_comment_list *lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3518 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3519 tree_classdef_enum_block *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3520 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3521 if (end_token_ok (end_tok, token::enumeration_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3522 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3523 octave_comment_list *tc = lexer.comment_buf.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3524 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3525 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3526 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3527 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3528 if (! elist) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3529 elist = new tree_classdef_enum_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3530 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3531 retval = new tree_classdef_enum_block (a, elist, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3532 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3533 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3534 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3535 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3536 delete elist; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3537 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3538 end_token_error (end_tok, token::enumeration_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3539 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3540 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3541 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3542 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3543 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3544 octave_user_function* |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3545 base_parser::start_classdef_external_method (tree_identifier *id, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3546 tree_parameter_list *pl) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3547 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3548 octave_user_function* retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3549 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3550 // External methods are only allowed within @-folders. In this case, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3551 // curr_class_name will be non-empty. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3552 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3553 if (! curr_class_name.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3554 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3555 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3556 std::string mname = id->name (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3557 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3558 // Methods that cannot be declared outside the classdef file: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3559 // - methods with '.' character (e.g. property accessors) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3560 // - class constructor |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3561 // - `delete' |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3562 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3563 if (mname.find_first_of (".") == std::string::npos |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3564 && mname != "delete" |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3565 && mname != curr_class_name) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3566 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3567 // Create a dummy function that is used until the real method |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3568 // is loaded. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3569 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3570 retval = new octave_user_function (-1, pl); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3571 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3572 retval->stash_function_name (mname); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3573 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3574 int l = id->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3575 int c = id->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3576 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3577 retval->stash_fcn_location (l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3578 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3579 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3580 bison_error ("invalid external method declaration, an external " |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3581 "method cannot be the class constructor, `delete' " |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3582 "or have a dot (.) character in its name"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3583 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3584 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3585 bison_error ("external methods are only allowed in @-folders"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3586 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3587 if (! retval) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3588 delete id; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3589 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3590 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3591 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3592 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3593 tree_function_def * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3594 base_parser::finish_classdef_external_method (octave_user_function *fcn, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3595 tree_parameter_list *ret_list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3596 octave_comment_list *cl) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3597 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3598 if (ret_list) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3599 fcn->define_ret_list (ret_list); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3600 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3601 if (cl) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3602 fcn->stash_leading_comment (cl); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3603 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3604 int l = fcn->beginning_line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3605 int c = fcn->beginning_column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3606 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3607 return new tree_function_def (fcn, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3608 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3609 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3610 // Make an index expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3611 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3612 tree_index_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3613 base_parser::make_index_expression (tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3614 tree_argument_list *args, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3615 char type) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3616 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3617 tree_index_expression *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3618 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3619 if (args && args->has_magic_tilde ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3620 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3621 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3622 delete args; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3623 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3624 bison_error ("invalid use of empty argument (~) in index expression"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3625 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3626 else |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3627 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3628 int l = expr->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3629 int c = expr->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3630 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3631 if (! expr->is_postfix_indexed ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3632 expr->set_postfix_index (type); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3633 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3634 if (expr->is_index_expression ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3635 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3636 tree_index_expression *tmp = |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3637 static_cast<tree_index_expression *> (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3638 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3639 tmp->append (args, type); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3640 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3641 retval = tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3642 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3643 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3644 retval = new tree_index_expression (expr, args, l, c, type); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3645 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3646 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3647 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3648 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3649 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3650 // Make an indirect reference expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3651 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3652 tree_index_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3653 base_parser::make_indirect_ref (tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3654 const std::string& elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3655 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3656 tree_index_expression *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3657 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3658 int l = expr->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3659 int c = expr->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3660 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3661 if (! expr->is_postfix_indexed ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3662 expr->set_postfix_index ('.'); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3663 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3664 if (expr->is_index_expression ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3665 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3666 tree_index_expression *tmp = static_cast<tree_index_expression *> (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3667 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3668 tmp->append (elt); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3669 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3670 retval = tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3671 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3672 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3673 retval = new tree_index_expression (expr, elt, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3674 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3675 lexer.looking_at_indirect_ref = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3676 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3677 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3678 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3679 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3680 // Make an indirect reference expression with dynamic field name. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3681 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3682 tree_index_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3683 base_parser::make_indirect_ref (tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3684 tree_expression *elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3685 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3686 tree_index_expression *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3687 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3688 int l = expr->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3689 int c = expr->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3690 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3691 if (! expr->is_postfix_indexed ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3692 expr->set_postfix_index ('.'); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3693 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3694 if (expr->is_index_expression ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3695 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3696 tree_index_expression *tmp = static_cast<tree_index_expression *> (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3697 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3698 tmp->append (elt); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3699 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3700 retval = tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3701 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3702 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3703 retval = new tree_index_expression (expr, elt, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3704 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3705 lexer.looking_at_indirect_ref = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3706 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3707 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3708 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3709 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3710 // Make a declaration command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3711 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3712 tree_decl_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3713 base_parser::make_decl_command (int tok, token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3714 tree_decl_init_list *lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3715 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3716 tree_decl_command *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3717 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3718 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3719 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3720 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3721 switch (tok) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3722 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3723 case GLOBAL: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3724 retval = new tree_global_command (lst, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3725 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3726 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3727 case PERSISTENT: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3728 if (curr_fcn_depth > 0) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3729 retval = new tree_persistent_command (lst, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3730 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3731 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3732 if (lexer.reading_script_file) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3733 warning ("ignoring persistent declaration near line %d of file '%s'", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3734 l, lexer.fcn_file_full_name.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3735 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3736 warning ("ignoring persistent declaration near line %d", l); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3737 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3738 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3739 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3740 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3741 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3742 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3743 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3744 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3745 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3746 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3747 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3748 bool |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3749 base_parser::validate_array_list (tree_expression *e) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3750 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3751 bool retval = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3752 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3753 tree_array_list *al = dynamic_cast<tree_array_list *> (e); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3754 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3755 for (tree_array_list::iterator i = al->begin (); i != al->end (); i++) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3756 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3757 tree_argument_list *row = *i; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3758 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3759 if (row && row->has_magic_tilde ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3760 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3761 retval = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3762 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3763 if (e->is_matrix ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3764 bison_error ("invalid use of tilde (~) in matrix expression"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3765 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3766 bison_error ("invalid use of tilde (~) in cell expression"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3767 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3768 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3769 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3770 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3771 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3772 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3773 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3774 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3775 tree_argument_list * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3776 base_parser::validate_matrix_for_assignment (tree_expression *e) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3777 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3778 tree_argument_list *retval = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3779 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3780 if (e->is_constant ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3781 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3782 octave_value ov = e->rvalue1 (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3783 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3784 delete e; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3785 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3786 if (ov.is_empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3787 bison_error ("invalid empty left hand side of assignment"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3788 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3789 bison_error ("invalid constant left hand side of assignment"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3790 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3791 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3792 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3793 bool is_simple_assign = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3794 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3795 tree_argument_list *tmp = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3796 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3797 if (e->is_matrix ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3798 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3799 tree_matrix *mat = dynamic_cast<tree_matrix *> (e); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3800 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3801 if (mat && mat->size () == 1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3802 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3803 tmp = mat->front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3804 mat->pop_front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3805 delete e; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3806 is_simple_assign = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3807 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3808 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3809 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3810 tmp = new tree_argument_list (e); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3811 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3812 if (tmp && tmp->is_valid_lvalue_list ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3813 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3814 lexer.mark_as_variables (tmp->variable_names ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3815 retval = tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3816 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3817 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3818 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3819 delete tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3820 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3821 bison_error ("invalid left hand side of assignment"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3822 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3823 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3824 if (retval && is_simple_assign) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3825 retval->mark_as_simple_assign_lhs (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3826 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3827 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3828 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3829 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3830 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3831 // Finish building an array_list. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3832 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3833 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3834 base_parser::finish_array_list (tree_array_list *array_list) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3835 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3836 tree_expression *retval = array_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3837 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3838 octave::unwind_protect frame; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3839 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3840 frame.protect_var (discard_error_messages); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3841 frame.protect_var (discard_warning_messages); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3842 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3843 discard_error_messages = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3844 discard_warning_messages = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3845 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3846 if (array_list->all_elements_are_constant ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3847 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3848 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3849 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3850 octave_value tmp = array_list->rvalue1 (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3851 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3852 tree_constant *tc_retval |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3853 = new tree_constant (tmp, array_list->line (), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3854 array_list->column ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3855 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3856 std::ostringstream buf; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3857 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3858 tree_print_code tpc (buf); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3859 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3860 array_list->accept (tpc); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3861 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3862 tc_retval->stash_original_text (buf.str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3863 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3864 delete array_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3865 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3866 retval = tc_retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3867 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
3868 catch (const octave::execution_exception&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3869 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3870 recover_from_exception (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3871 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3872 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3873 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3874 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3875 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3876 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3877 // Finish building a matrix list. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3878 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3879 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3880 base_parser::finish_matrix (tree_matrix *m) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3881 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3882 return (m |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3883 ? finish_array_list (m) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3884 : new tree_constant (octave_null_matrix::instance)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3885 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3886 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3887 // Finish building a cell list. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3888 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3889 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3890 base_parser::finish_cell (tree_cell *c) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3891 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3892 return (c |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3893 ? finish_array_list (c) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3894 : new tree_constant (octave_value (Cell ()))); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3895 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3896 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3897 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3898 base_parser::maybe_warn_missing_semi (tree_statement_list *t) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3899 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3900 if (curr_fcn_depth > 0) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3901 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3902 tree_statement *tmp = t->back (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3903 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3904 if (tmp->is_expression ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3905 warning_with_id |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3906 ("Octave:missing-semicolon", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3907 "missing semicolon near line %d, column %d in file '%s'", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3908 tmp->line (), tmp->column (), lexer.fcn_file_full_name.c_str ()); |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3909 } |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3910 } |
1623 | 3911 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3912 tree_statement_list * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3913 base_parser::set_stmt_print_flag (tree_statement_list *list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3914 char sep, bool warn_missing_semi) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3915 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3916 tree_statement *tmp = list->back (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3917 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3918 switch (sep) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3919 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3920 case ';': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3921 tmp->set_print_flag (false); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3922 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3923 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3924 case 0: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3925 case ',': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3926 case '\n': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3927 tmp->set_print_flag (true); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3928 if (warn_missing_semi) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3929 maybe_warn_missing_semi (list); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3930 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3931 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3932 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3933 warning ("unrecognized separator type!"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3934 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3935 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3936 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3937 // Even if a statement is null, we add it to the list then remove it |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3938 // here so that the print flag is applied to the correct statement. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3939 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3940 if (tmp->is_null_statement ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3941 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3942 list->pop_back (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3943 delete tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3944 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3945 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3946 return list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3947 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3948 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3949 // Finish building a statement. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3950 template <typename T> |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3951 tree_statement * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3952 base_parser::make_statement (T *arg) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3953 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3954 octave_comment_list *comment = lexer.get_comment (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3955 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3956 return new tree_statement (arg, comment); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3957 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3958 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3959 tree_statement_list * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3960 base_parser::make_statement_list (tree_statement *stmt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3961 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3962 return new tree_statement_list (stmt); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3963 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3964 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3965 tree_statement_list * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3966 base_parser::append_statement_list (tree_statement_list *list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3967 char sep, tree_statement *stmt, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3968 bool warn_missing_semi) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3969 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3970 set_stmt_print_flag (list, sep, warn_missing_semi); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3971 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3972 list->append (stmt); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3973 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3974 return list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3975 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3976 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3977 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3978 base_parser::bison_error (const std::string& str, int l, int c) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3979 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3980 int err_line = l < 0 ? lexer.input_line_number : l; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3981 int err_col = c < 0 ? lexer.current_input_column - 1 : c; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3982 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3983 std::ostringstream output_buf; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3984 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3985 if (lexer.reading_fcn_file || lexer.reading_script_file |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3986 || lexer.reading_classdef_file) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3987 output_buf << "parse error near line " << err_line |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3988 << " of file " << lexer.fcn_file_full_name; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3989 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3990 output_buf << "parse error:"; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3991 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3992 if (str != "parse error") |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3993 output_buf << "\n\n " << str; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3994 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3995 output_buf << "\n\n"; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3996 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3997 std::string curr_line = lexer.current_input_line; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3998 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3999 if (! curr_line.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4000 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4001 size_t len = curr_line.length (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4002 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4003 if (curr_line[len-1] == '\n') |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4004 curr_line.resize (len-1); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4005 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4006 // Print the line, maybe with a pointer near the error token. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4007 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4008 output_buf << ">>> " << curr_line << "\n"; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4009 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4010 if (err_col == 0) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4011 err_col = len; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4012 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4013 for (int i = 0; i < err_col + 3; i++) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4014 output_buf << " "; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4015 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4016 output_buf << "^"; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4017 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4018 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4019 output_buf << "\n"; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4020 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4021 parse_error_msg = output_buf.str (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4022 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4023 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4024 int |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4025 parser::run (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4026 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4027 int status = -1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4028 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4029 yypstate *pstate = static_cast<yypstate *> (parser_state); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4030 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4031 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4032 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4033 status = octave_pull_parse (pstate, *this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4034 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4035 catch (octave::execution_exception& e) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4036 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4037 std::string file = lexer.fcn_file_full_name; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4038 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4039 if (file.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4040 error (e, "parse error"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4041 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4042 error (e, "parse error in %s", file.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4043 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4044 catch (octave::interrupt_exception &) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4045 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4046 throw; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4047 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4048 catch (...) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4049 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4050 std::string file = lexer.fcn_file_full_name; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4051 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4052 if (file.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4053 error ("unexpected exception while parsing input"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4054 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4055 error ("unexpected exception while parsing %s", file.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4056 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4057 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4058 if (status != 0) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4059 parse_error ("%s", parse_error_msg.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4060 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4061 return status; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4062 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4063 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4064 // Parse input from INPUT. Pass TRUE for EOF if the end of INPUT should |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4065 // finish the parse. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4066 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4067 int |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4068 push_parser::run (const std::string& input, bool eof) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4069 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4070 int status = -1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4071 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4072 dynamic_cast<push_lexer&> (lexer).append_input (input, eof); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4073 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4074 do |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4075 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4076 YYSTYPE lval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4077 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4078 int token = octave_lex (&lval, scanner); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4079 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4080 if (token < 0) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4081 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4082 if (! eof && lexer.at_end_of_buffer ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4083 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4084 status = -1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4085 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4086 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4087 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4088 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4089 yypstate *pstate = static_cast<yypstate *> (parser_state); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4090 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4091 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4092 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4093 status = octave_push_parse (pstate, token, &lval, *this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4094 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4095 catch (octave::execution_exception& e) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4096 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4097 std::string file = lexer.fcn_file_full_name; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4098 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4099 if (file.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4100 error (e, "parse error"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4101 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4102 error (e, "parse error in %s", file.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4103 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4104 catch (octave::interrupt_exception &) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4105 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4106 throw; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4107 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4108 catch (...) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4109 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4110 std::string file = lexer.fcn_file_full_name; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4111 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4112 if (file.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4113 error ("unexpected exception while parsing input"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4114 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4115 error ("unexpected exception while parsing %s", file.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4116 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4117 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4118 while (status == YYPUSH_MORE); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4119 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4120 if (status != 0) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4121 parse_error ("%s", parse_error_msg.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4122 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4123 return status; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4124 } |
16294
0925d1f6875e
push parser/lexer interface
John W. Eaton <jwe@octave.org>
parents:
16293
diff
changeset
|
4125 } |
0925d1f6875e
push parser/lexer interface
John W. Eaton <jwe@octave.org>
parents:
16293
diff
changeset
|
4126 |
3021 | 4127 static void |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
4128 safe_fclose (FILE *f) |
3021 | 4129 { |
4130 if (f) | |
4131 fclose (static_cast<FILE *> (f)); | |
4132 } | |
4133 | |
7336 | 4134 static octave_function * |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4135 parse_fcn_file (const std::string& full_file, const std::string& file, |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4136 const std::string& dispatch_type, |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
4137 const std::string& package_name, |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
4138 bool require_file, bool force_script, bool autoload, |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
4139 bool relative_lookup, const std::string& warn_for) |
3021 | 4140 { |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21740
diff
changeset
|
4141 octave::unwind_protect frame; |
3021 | 4142 |
7336 | 4143 octave_function *fcn_ptr = 0; |
3021 | 4144 |
4145 // Open function file and parse. | |
4146 | |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4147 FILE *in_stream = octave::command_editor::get_input_stream (); |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4148 |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4149 frame.add_fcn (octave::command_editor::set_input_stream, in_stream); |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4150 |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4151 frame.add_fcn (octave::command_history::ignore_entries, |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4152 octave::command_history::ignoring_entries ()); |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4153 |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4154 octave::command_history::ignore_entries (); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4155 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
4156 FILE *ffile = 0; |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
4157 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4158 if (! full_file.empty ()) |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21861
diff
changeset
|
4159 ffile = std::fopen (full_file.c_str (), "rb"); |
3021 | 4160 |
4161 if (ffile) | |
4162 { | |
19709
5cfb3ccbf24a
style fixes for resource management
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
4163 frame.add_fcn (safe_fclose, ffile); |
5cfb3ccbf24a
style fixes for resource management
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
4164 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4165 // octave::base_parser constructor sets this for us. |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4166 frame.protect_var (LEXER); |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4167 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4168 octave::parser parser (ffile); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4169 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4170 parser.curr_class_name = dispatch_type; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
4171 parser.curr_package_name = package_name; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4172 parser.autoloading = autoload; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4173 parser.fcn_file_from_relative_lookup = relative_lookup; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4174 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4175 parser.lexer.force_script = force_script; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4176 parser.lexer.prep_for_file (); |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4177 parser.lexer.parsing_class_method = ! dispatch_type.empty (); |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4178 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4179 parser.lexer.fcn_file_name = file; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4180 parser.lexer.fcn_file_full_name = full_file; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4181 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4182 int status = parser.run (); |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4183 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4184 fcn_ptr = parser.primary_fcn_ptr; |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4185 |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4186 if (status == 0) |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
4187 { |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4188 if (parser.lexer.reading_classdef_file |
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4189 && parser.classdef_object) |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
4190 { |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4191 // Convert parse tree for classdef object to |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4192 // meta.class info (and stash it in the symbol |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4193 // table?). Return pointer to constructor? |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4194 |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4195 if (fcn_ptr) |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4196 panic_impossible (); |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4197 |
18263
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18262
diff
changeset
|
4198 bool is_at_folder = ! dispatch_type.empty (); |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18262
diff
changeset
|
4199 |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18262
diff
changeset
|
4200 fcn_ptr = |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18262
diff
changeset
|
4201 parser.classdef_object->make_meta_class (is_at_folder); |
21589
ad90fb5a139f
eliminate memory leaks from classdef parse tree (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
21581
diff
changeset
|
4202 |
ad90fb5a139f
eliminate memory leaks from classdef parse tree (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
21581
diff
changeset
|
4203 delete (parser.classdef_object); |
ad90fb5a139f
eliminate memory leaks from classdef parse tree (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
21581
diff
changeset
|
4204 |
ad90fb5a139f
eliminate memory leaks from classdef parse tree (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
21581
diff
changeset
|
4205 parser.classdef_object = 0; |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
4206 } |
16644
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4207 else if (fcn_ptr) |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4208 { |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4209 fcn_ptr->maybe_relocate_end (); |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4210 |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4211 if (parser.parsing_subfunctions) |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4212 { |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4213 if (! parser.endfunction_found) |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4214 parser.subfunction_names.reverse (); |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4215 |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4216 fcn_ptr->stash_subfunction_names (parser.subfunction_names); |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4217 } |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
4218 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
4219 } |
10872
988d16d5ae34
correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents:
10659
diff
changeset
|
4220 else |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4221 error ("parse error while reading file %s", full_file.c_str ()); |
3021 | 4222 } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4223 else if (require_file) |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4224 error ("no such file, '%s'", full_file.c_str ()); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4225 else if (! warn_for.empty ()) |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4226 error ("%s: unable to open file '%s'", warn_for.c_str (), |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4227 full_file.c_str ()); |
3021 | 4228 |
7336 | 4229 return fcn_ptr; |
3021 | 4230 } |
4231 | |
5484 | 4232 std::string |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4233 get_help_from_file (const std::string& nm, bool& symbol_found, |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4234 std::string& full_file) |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4235 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4236 std::string retval; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4237 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4238 full_file = fcn_file_in_path (nm); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4239 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4240 std::string file = full_file; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4241 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4242 size_t file_len = file.length (); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4243 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4244 if ((file_len > 4 && file.substr (file_len-4) == ".oct") |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4245 || (file_len > 4 && file.substr (file_len-4) == ".mex") |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4246 || (file_len > 2 && file.substr (file_len-2) == ".m")) |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4247 { |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
4248 file = octave::sys::env::base_pathname (file); |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4249 file = file.substr (0, file.find_last_of ('.')); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4250 |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
4251 size_t pos = file.find_last_of (octave::sys::file_ops::dir_sep_str ()); |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4252 if (pos != std::string::npos) |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4253 file = file.substr (pos+1); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4254 } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4255 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4256 if (! file.empty ()) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4257 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4258 symbol_found = true; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4259 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4260 octave_function *fcn |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
4261 = parse_fcn_file (full_file, file, "", "", true, false, false, false, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
4262 ""); |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4263 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4264 if (fcn) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4265 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4266 retval = fcn->doc_string (); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4267 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4268 delete fcn; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4269 } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4270 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4271 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4272 return retval; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4273 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4274 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4275 std::string |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4276 get_help_from_file (const std::string& nm, bool& symbol_found) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4277 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4278 std::string file; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4279 return get_help_from_file (nm, symbol_found, file); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4280 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4281 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4282 std::string |
5484 | 4283 lookup_autoload (const std::string& nm) |
4284 { | |
5626 | 4285 std::string retval; |
4286 | |
4287 typedef std::map<std::string, std::string>::const_iterator am_iter; | |
4288 | |
4289 am_iter p = autoload_map.find (nm); | |
4290 | |
4291 if (p != autoload_map.end ()) | |
6323 | 4292 retval = load_path::find_file (p->second); |
5626 | 4293 |
4294 return retval; | |
5484 | 4295 } |
4296 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
4297 string_vector |
5592 | 4298 autoloaded_functions (void) |
4299 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14584
diff
changeset
|
4300 string_vector names (autoload_map.size ()); |
5592 | 4301 |
4302 octave_idx_type i = 0; | |
5626 | 4303 typedef std::map<std::string, std::string>::const_iterator am_iter; |
4304 for (am_iter p = autoload_map.begin (); p != autoload_map.end (); p++) | |
5592 | 4305 names[i++] = p->first; |
4306 | |
4307 return names; | |
4308 } | |
4309 | |
4310 string_vector | |
4311 reverse_lookup_autoload (const std::string& nm) | |
4312 { | |
4313 string_vector names; | |
4314 | |
5626 | 4315 typedef std::map<std::string, std::string>::const_iterator am_iter; |
4316 for (am_iter p = autoload_map.begin (); p != autoload_map.end (); p++) | |
5592 | 4317 if (nm == p->second) |
4318 names.append (p->first); | |
4319 | |
4320 return names; | |
4321 } | |
4322 | |
7336 | 4323 octave_function * |
4324 load_fcn_from_file (const std::string& file_name, const std::string& dir_name, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4325 const std::string& dispatch_type, |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
4326 const std::string& package_name, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4327 const std::string& fcn_name, bool autoload) |
3021 | 4328 { |
7336 | 4329 octave_function *retval = 0; |
4330 | |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21740
diff
changeset
|
4331 octave::unwind_protect frame; |
5484 | 4332 |
7336 | 4333 std::string nm = file_name; |
6238 | 4334 |
4335 size_t nm_len = nm.length (); | |
5472 | 4336 |
4337 std::string file; | |
4338 | |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
4339 bool relative_lookup = false; |
6323 | 4340 |
7336 | 4341 file = nm; |
4342 | |
4343 if ((nm_len > 4 && nm.substr (nm_len-4) == ".oct") | |
4344 || (nm_len > 4 && nm.substr (nm_len-4) == ".mex") | |
4345 || (nm_len > 2 && nm.substr (nm_len-2) == ".m")) | |
5472 | 4346 { |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
4347 nm = octave::sys::env::base_pathname (file); |
6238 | 4348 nm = nm.substr (0, nm.find_last_of ('.')); |
11136
a51ac4198e1c
oct-parse.yy (load_fcn_from_file): also strip directory when computing function name from filename
John W. Eaton <jwe@octave.org>
parents:
11091
diff
changeset
|
4349 |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
4350 size_t pos = nm.find_last_of (octave::sys::file_ops::dir_sep_str ()); |
11136
a51ac4198e1c
oct-parse.yy (load_fcn_from_file): also strip directory when computing function name from filename
John W. Eaton <jwe@octave.org>
parents:
11091
diff
changeset
|
4351 if (pos != std::string::npos) |
11138
40206fe759db
oct-parse.yy: fix typo in previous change
John W. Eaton <jwe@octave.org>
parents:
11136
diff
changeset
|
4352 nm = nm.substr (pos+1); |
5472 | 4353 } |
7336 | 4354 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
4355 relative_lookup = ! octave::sys::env::absolute_pathname (file); |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
4356 |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
4357 file = octave::sys::env::make_absolute (file); |
4243 | 4358 |
4359 int len = file.length (); | |
4360 | |
4244 | 4361 if (len > 4 && file.substr (len-4, len-1) == ".oct") |
3021 | 4362 { |
7336 | 4363 if (autoload && ! fcn_name.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4364 nm = fcn_name; |
7336 | 4365 |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
4366 retval = octave_dynamic_loader::load_oct (nm, file, relative_lookup); |
5864 | 4367 } |
4368 else if (len > 4 && file.substr (len-4, len-1) == ".mex") | |
10570
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
4369 { |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
4370 // Temporarily load m-file version of mex-file, if it exists, |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
4371 // to get the help-string to use. |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
4372 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
4373 octave_function *tmpfcn = parse_fcn_file (file.substr (0, len - 2), |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
4374 nm, dispatch_type, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
4375 package_name, false, |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
4376 autoload, autoload, |
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
4377 relative_lookup, ""); |
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
4378 |
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
4379 retval = octave_dynamic_loader::load_mex (nm, file, relative_lookup); |
10570
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
4380 |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
4381 if (tmpfcn) |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
4382 retval->document (tmpfcn->doc_string ()); |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
4383 delete tmpfcn; |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
4384 } |
4244 | 4385 else if (len > 2) |
3021 | 4386 { |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
4387 retval = parse_fcn_file (file, nm, dispatch_type, package_name, true, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
4388 autoload, autoload, relative_lookup, ""); |
3021 | 4389 } |
4390 | |
7336 | 4391 if (retval) |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
4392 { |
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
4393 retval->stash_dir_name (dir_name); |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18263
diff
changeset
|
4394 retval->stash_package_name (package_name); |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
4395 |
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
4396 if (retval->is_user_function ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4397 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4398 symbol_table::scope_id id = retval->scope (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4399 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4400 symbol_table::stash_dir_name_for_subfunctions (id, dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4401 } |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
4402 } |
7336 | 4403 |
4404 return retval; | |
5312 | 4405 } |
4406 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
4407 DEFUN (autoload, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4408 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4409 @deftypefn {} {@var{autoload_map} =} autoload () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4410 @deftypefnx {} {} autoload (@var{function}, @var{file}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4411 @deftypefnx {} {} autoload (@dots{}, "remove") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4412 Define @var{function} to autoload from @var{file}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4413 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4414 The second argument, @var{file}, should be an absolute filename or a file |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4415 name in the same directory as the function or script from which the autoload |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4416 command was run. @var{file} @emph{should not} depend on the Octave load |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4417 path. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4418 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4419 Normally, calls to @code{autoload} appear in PKG_ADD script files that are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4420 evaluated when a directory is added to Octave's load path. To avoid having |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4421 to hardcode directory names in @var{file}, if @var{file} is in the same |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4422 directory as the PKG_ADD script then |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4423 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4424 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4425 autoload ("foo", "bar.oct"); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4426 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4427 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4428 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4429 will load the function @code{foo} from the file @code{bar.oct}. The above |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4430 usage when @code{bar.oct} is not in the same directory, or usages such as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4431 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4432 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4433 autoload ("foo", file_in_loadpath ("bar.oct")) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4434 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4435 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4436 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4437 are strongly discouraged, as their behavior may be unpredictable. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4438 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4439 With no arguments, return a structure containing the current autoload map. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4440 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4441 If a third argument @qcode{"remove"} is given, the function is cleared and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4442 not loaded anymore during the current Octave session. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4443 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4444 @seealso{PKG_ADD} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4445 @end deftypefn */) |
5484 | 4446 { |
5626 | 4447 octave_value retval; |
5484 | 4448 |
4449 int nargin = args.length (); | |
4450 | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4451 if (nargin == 1 || nargin > 3) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4452 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4453 |
5626 | 4454 if (nargin == 0) |
4455 { | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
4456 Cell func_names (dim_vector (autoload_map.size (), 1)); |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
4457 Cell file_names (dim_vector (autoload_map.size (), 1)); |
5626 | 4458 |
4459 octave_idx_type i = 0; | |
4460 typedef std::map<std::string, std::string>::const_iterator am_iter; | |
4461 for (am_iter p = autoload_map.begin (); p != autoload_map.end (); p++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4462 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4463 func_names(i) = p->first; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4464 file_names(i) = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4465 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4466 i++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4467 } |
5626 | 4468 |
11060
54697b37d8bf
replace Octave_map->octave_scalar_map in oct-parse.yy and ov-fcn-handle.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10879
diff
changeset
|
4469 octave_map m; |
5626 | 4470 |
4471 m.assign ("function", func_names); | |
4472 m.assign ("file", file_names); | |
4473 | |
4474 retval = m; | |
4475 } | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4476 else |
5484 | 4477 { |
4478 string_vector argv = args.make_argv ("autoload"); | |
4479 | |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4480 std::string nm = argv[2]; |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4481 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
4482 if (! octave::sys::env::absolute_pathname (nm)) |
6380 | 4483 { |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4484 octave_user_code *fcn = octave_call_stack::caller_user_code (); |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4485 |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4486 bool found = false; |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4487 |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4488 if (fcn) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4489 { |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4490 std::string fname = fcn->fcn_file_name (); |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4491 |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4492 if (! fname.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4493 { |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
4494 fname = octave::sys::env::make_absolute (fname); |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
4495 fname = fname.substr (0, fname.find_last_of (octave::sys::file_ops::dir_sep_str ()) + 1); |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4496 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
4497 octave::sys::file_stat fs (fname + nm); |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4498 |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4499 if (fs.exists ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4500 { |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4501 nm = fname + nm; |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4502 found = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4503 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4504 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4505 } |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4506 if (! found) |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4507 warning_with_id ("Octave:autoload-relative-file-name", |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
20700
diff
changeset
|
4508 "autoload: '%s' is not an absolute filename", |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4509 nm.c_str ()); |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4510 } |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4511 if (nargin == 2) |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4512 autoload_map[argv[1]] = nm; |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4513 else if (nargin == 3) |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4514 { |
21021
a5b99b09f8fd
maint: Use comparison operators rather than compare() for strings.
Rik <rik@octave.org>
parents:
20957
diff
changeset
|
4515 if (argv[3] != "remove") |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4516 error_with_id ("Octave:invalid-input-arg", |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4517 "autoload: third argument can only be 'remove'"); |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4518 |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4519 // Remove function from symbol table and autoload map. |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4520 symbol_table::clear_dld_function (argv[1]); |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4521 autoload_map.erase (argv[1]); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4522 } |
5484 | 4523 } |
4524 | |
4525 return retval; | |
4526 } | |
4527 | |
4486 | 4528 void |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4529 source_file (const std::string& file_name, const std::string& context, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4530 bool verbose, bool require_file, const std::string& warn_for) |
4486 | 4531 { |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4532 // Map from absolute name of script file to recursion level. We |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4533 // use a map instead of simply placing a limit on recursion in the |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4534 // source_file function so that two mutually recursive scripts |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4535 // written as |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4536 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4537 // foo1.m: |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4538 // ------ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4539 // foo2 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4540 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4541 // foo2.m: |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4542 // ------ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4543 // foo1 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4544 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4545 // and called with |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4546 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4547 // foo1 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4548 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4549 // (for example) will behave the same if they are written as |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4550 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4551 // foo1.m: |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4552 // ------ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4553 // source ("foo2.m") |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4554 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4555 // foo2.m: |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4556 // ------ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4557 // source ("foo1.m") |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4558 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4559 // and called with |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4560 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4561 // source ("foo1.m") |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4562 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4563 // (for example). |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4564 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4565 static std::map<std::string, int> source_call_depth; |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4566 |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
4567 std::string file_full_name = octave::sys::file_ops::tilde_expand (file_name); |
4486 | 4568 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
4569 file_full_name = octave::sys::env::make_absolute (file_full_name); |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4570 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21740
diff
changeset
|
4571 octave::unwind_protect frame; |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
4572 |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4573 if (source_call_depth.find (file_full_name) == source_call_depth.end ()) |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4574 source_call_depth[file_full_name] = -1; |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4575 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4576 frame.protect_var (source_call_depth[file_full_name]); |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4577 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4578 source_call_depth[file_full_name]++; |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4579 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4580 if (source_call_depth[file_full_name] >= Vmax_recursion_depth) |
20957
9db35d2042be
maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents:
20895
diff
changeset
|
4581 error ("max_recursion_depth exceeded"); |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
4582 |
5975 | 4583 if (! context.empty ()) |
4584 { | |
4585 if (context == "caller") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4586 octave_call_stack::goto_caller_frame (); |
5975 | 4587 else if (context == "base") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4588 octave_call_stack::goto_base_frame (); |
5975 | 4589 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4590 error ("source: context must be \"caller\" or \"base\""); |
7336 | 4591 |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4592 frame.add_fcn (octave_call_stack::pop); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
4593 } |
5975 | 4594 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20550
diff
changeset
|
4595 octave_function *fcn = 0; |
21707
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4596 // Don't delete a function already in symbol_table |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4597 bool delete_fcn = false; |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4598 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4599 // Find symbol name that would be in symbol_table, if it were loaded. |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
4600 size_t dir_end = file_name.find_last_of (octave::sys::file_ops::dir_sep_chars ()); |
21707
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4601 dir_end = (dir_end == std::string::npos) ? 0 : dir_end + 1; |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4602 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4603 size_t extension = file_name.find_last_of ('.'); |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4604 if (extension == std::string::npos) |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4605 extension = file_name.length (); |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4606 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4607 std::string symbol = file_name.substr (dir_end, extension - dir_end); |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
4608 std::string full_name = octave::sys::canonicalize_file_name (file_name); |
21707
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4609 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4610 // Check if this file is already loaded (or in the path) |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4611 octave_value loaded_sym = symbol_table::find (symbol); |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4612 if (loaded_sym.is_function ()) |
5975 | 4613 { |
21707
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4614 fcn = loaded_sym.function_value (); |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4615 if (fcn) |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4616 { |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
4617 if (octave::sys::canonicalize_file_name (fcn->fcn_file_name ()) |
21740
767c81fe30ba
Fix memory bug in source() from cset 4c080cbc4ef9 (bug #47938)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21736
diff
changeset
|
4618 != full_name) |
767c81fe30ba
Fix memory bug in source() from cset 4c080cbc4ef9 (bug #47938)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21736
diff
changeset
|
4619 { |
767c81fe30ba
Fix memory bug in source() from cset 4c080cbc4ef9 (bug #47938)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21736
diff
changeset
|
4620 fcn = 0; // wrong file, so load it below |
767c81fe30ba
Fix memory bug in source() from cset 4c080cbc4ef9 (bug #47938)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21736
diff
changeset
|
4621 delete_fcn = true; // and delete it when done. |
767c81fe30ba
Fix memory bug in source() from cset 4c080cbc4ef9 (bug #47938)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21736
diff
changeset
|
4622 } |
21707
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4623 } |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4624 } |
21707
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4625 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4626 // If no symbol of this name, or the symbol is for a different file, load |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4627 if (! fcn) |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4628 { |
21707
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4629 try |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4630 { |
21707
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4631 fcn = parse_fcn_file (file_full_name, file_name, "", "", |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4632 require_file, true, false, false, warn_for); |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4633 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4634 catch (octave::execution_exception& e) |
21707
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4635 { |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4636 error (e, "source: error sourcing file '%s'", |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4637 file_full_name.c_str ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4638 } |
21707
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4639 } |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4640 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4641 // Return or error if we don't have a valid script |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4642 if (! fcn) |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4643 return; |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4644 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4645 if (! fcn->is_user_code ()) |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4646 { |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4647 if (delete_fcn) |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4648 delete fcn; |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4649 error ("source: %s is not a script", full_name.c_str ()); |
5975 | 4650 } |
21707
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4651 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4652 // Parameter checking is over. Now run. |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4653 octave_value_list args; |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4654 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4655 if (verbose) |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4656 { |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4657 std::cout << "executing commands from " << full_name << " ... "; |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4658 reading_startup_message_printed = true; |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4659 std::cout.flush (); |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4660 } |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4661 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4662 fcn->do_multi_index_op (0, args); |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4663 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4664 if (verbose) |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4665 std::cout << "done." << std::endl; |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4666 |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4667 // Delete scripts not on the path, so they don't shadow ones that are. |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4668 if (delete_fcn) |
4c080cbc4ef9
Make source() not re-parse a file if it is already loaded (bug #33411).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21589
diff
changeset
|
4669 delete fcn; |
4486 | 4670 } |
4671 | |
5739 | 4672 DEFUN (mfilename, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4673 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4674 @deftypefn {} {} mfilename () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4675 @deftypefnx {} {} mfilename ("fullpath") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4676 @deftypefnx {} {} mfilename ("fullpathext") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4677 Return the name of the currently executing file. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4678 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4679 When called from outside an m-file return the empty string. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4680 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4681 Given the argument @qcode{"fullpath"}, include the directory part of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4682 filename, but not the extension. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4683 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4684 Given the argument @qcode{"fullpathext"}, include the directory part of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4685 the filename and the extension. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4686 @end deftypefn */) |
5739 | 4687 { |
4688 octave_value retval; | |
4689 | |
4690 int nargin = args.length (); | |
4691 | |
4692 if (nargin > 1) | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4693 print_usage (); |
5739 | 4694 |
4695 std::string arg; | |
4696 | |
4697 if (nargin == 1) | |
21861
a55f1fa2c94a
oct-parse.in.yy: Shorten lines to < 80 characters where possible.
Rik <rik@octave.org>
parents:
21748
diff
changeset
|
4698 arg = args(0).xstring_value ("mfilename: argument must be a string"); |
5739 | 4699 |
4700 std::string fname; | |
4701 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
4702 octave_user_code *fcn = octave_call_stack::caller_user_code (); |
5743 | 4703 |
4704 if (fcn) | |
4705 { | |
4706 fname = fcn->fcn_file_name (); | |
4707 | |
4708 if (fname.empty ()) | |
4709 fname = fcn->name (); | |
4710 } | |
5739 | 4711 |
4712 if (arg == "fullpathext") | |
4713 retval = fname; | |
4714 else | |
4715 { | |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
4716 size_t dpos = fname.rfind (octave::sys::file_ops::dir_sep_char ()); |
5747 | 4717 size_t epos = fname.rfind ('.'); |
4718 | |
4719 if (epos <= dpos) | |
8021 | 4720 epos = std::string::npos; |
4721 | |
4722 fname = (epos != std::string::npos) ? fname.substr (0, epos) : fname; | |
5739 | 4723 |
4724 if (arg == "fullpath") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4725 retval = fname; |
5739 | 4726 else |
8021 | 4727 retval = (dpos != std::string::npos) ? fname.substr (dpos+1) : fname; |
5739 | 4728 } |
4729 | |
4730 return retval; | |
4731 } | |
4732 | |
3021 | 4733 DEFUN (source, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4734 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4735 @deftypefn {} {} source (@var{file}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4736 @deftypefnx {} {} source (@var{file}, @var{context}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4737 Parse and execute the contents of @var{file}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4738 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4739 Without specifying @var{context}, this is equivalent to executing commands |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4740 from a script file, but without requiring the file to be named |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4741 @file{@var{file}.m} or to be on the execution path. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4742 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4743 Instead of the current context, the script may be executed in either the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4744 context of the function that called the present function |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4745 (@qcode{"caller"}), or the top-level context (@qcode{"base"}). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4746 @seealso{run} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4747 @end deftypefn */) |
3021 | 4748 { |
4749 octave_value_list retval; | |
4750 | |
4751 int nargin = args.length (); | |
4752 | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4753 if (nargin < 1 || nargin > 2) |
5823 | 4754 print_usage (); |
3021 | 4755 |
21861
a55f1fa2c94a
oct-parse.in.yy: Shorten lines to < 80 characters where possible.
Rik <rik@octave.org>
parents:
21748
diff
changeset
|
4756 std::string file_name = args(0).xstring_value ("source: FILE must be a string"); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4757 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4758 std::string context; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4759 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4760 if (nargin == 2) |
21861
a55f1fa2c94a
oct-parse.in.yy: Shorten lines to < 80 characters where possible.
Rik <rik@octave.org>
parents:
21748
diff
changeset
|
4761 context = args(1).xstring_value ("source: CONTEXT must be a string"); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4762 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4763 source_file (file_name, context); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4764 |
3021 | 4765 return retval; |
4766 } | |
4767 | |
22298
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
4768 /*! |
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
4769 Evaluate an Octave function (built-in or interpreted) and return |
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
4770 the list of result values. |
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
4771 |
22300 | 4772 @param name The name of the function to call. |
4773 @param args The arguments to the function. | |
4774 @param nargout The number of output arguments expected. | |
4775 @return A list of output values. The length of the list is not | |
4776 necessarily the same as @c nargout. | |
4777 | |
22298
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
4778 */ |
3021 | 4779 octave_value_list |
3523 | 4780 feval (const std::string& name, const octave_value_list& args, int nargout) |
3156 | 4781 { |
4782 octave_value_list retval; | |
4783 | |
7336 | 4784 octave_value fcn = symbol_table::find_function (name, args); |
4785 | |
4786 if (fcn.is_defined ()) | |
22300 | 4787 retval = fcn.do_multi_index_op (nargout, args); |
7336 | 4788 else |
22712
e07fa946f763
Fix regression in feval and emit an error when function does not exist (bug #49516).
Rik <rik@octave.org>
parents:
22504
diff
changeset
|
4789 error ("feval: function '%s' not found", name.c_str ()); |
3156 | 4790 |
4791 return retval; | |
4792 } | |
4793 | |
4342 | 4794 octave_value_list |
4795 feval (octave_function *fcn, const octave_value_list& args, int nargout) | |
4796 { | |
4797 octave_value_list retval; | |
4798 | |
4799 if (fcn) | |
4800 retval = fcn->do_multi_index_op (nargout, args); | |
4801 | |
4802 return retval; | |
4803 } | |
4804 | |
4805 static octave_value_list | |
4806 get_feval_args (const octave_value_list& args) | |
4807 { | |
10659
8baff2aceabc
fix slicing value lists with name tags (bug #29960)
Jaroslav Hajek <highegg@gmail.com>
parents:
10578
diff
changeset
|
4808 return args.slice (1, args.length () - 1, true); |
4342 | 4809 } |
4810 | |
22298
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
4811 /*! |
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
4812 Evaluate an Octave function (built-in or interpreted) and return |
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
4813 the list of result values. |
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
4814 |
22300 | 4815 @param args The first element of @c args is the function to call. |
4816 It may be the name of the function as a string, a function | |
4817 handle, or an inline function. The remaining arguments are | |
4818 passed to the function. | |
4819 @param nargout The number of output arguments expected. | |
4820 @return A list of output values. The length of the list is not | |
4821 necessarily the same as @c nargout. | |
22298
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
4822 */ |
3156 | 4823 octave_value_list |
3021 | 4824 feval (const octave_value_list& args, int nargout) |
4825 { | |
4826 octave_value_list retval; | |
4827 | |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20798
diff
changeset
|
4828 if (args.length () > 0) |
3021 | 4829 { |
4342 | 4830 octave_value f_arg = args(0); |
4831 | |
4832 if (f_arg.is_string ()) | |
4833 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4834 std::string name = f_arg.string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4835 |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4836 octave_value_list tmp_args = get_feval_args (args); |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4837 |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4838 retval = feval (name, tmp_args, nargout); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4839 } |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
13237
diff
changeset
|
4840 else if (f_arg.is_function_handle () |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
13237
diff
changeset
|
4841 || f_arg.is_anonymous_function () |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
13237
diff
changeset
|
4842 || f_arg.is_inline_function ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4843 { |
10492
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10463
diff
changeset
|
4844 const octave_value_list tmp_args = get_feval_args (args); |
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10463
diff
changeset
|
4845 |
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10463
diff
changeset
|
4846 retval = f_arg.do_multi_index_op (nargout, tmp_args); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4847 } |
10492
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10463
diff
changeset
|
4848 else |
21861
a55f1fa2c94a
oct-parse.in.yy: Shorten lines to < 80 characters where possible.
Rik <rik@octave.org>
parents:
21748
diff
changeset
|
4849 error ("feval: first argument must be a string, inline function, or a function handle"); |
3021 | 4850 } |
4851 | |
4852 return retval; | |
4853 } | |
4854 | |
4855 DEFUN (feval, args, nargout, | |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4856 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4857 @deftypefn {} {} feval (@var{name}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4858 Evaluate the function named @var{name}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4859 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4860 Any arguments after the first are passed as inputs to the named function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4861 For example, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4862 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4863 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4864 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4865 feval ("acos", -1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4866 @result{} 3.1416 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4867 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4868 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4869 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4870 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4871 calls the function @code{acos} with the argument @samp{-1}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4872 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4873 The function @code{feval} can also be used with function handles of any sort |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4874 (@pxref{Function Handles}). Historically, @code{feval} was the only way to |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4875 call user-supplied functions in strings, but function handles are now |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4876 preferred due to the cleaner syntax they offer. For example, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4877 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4878 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4879 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4880 @var{f} = @@exp; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4881 feval (@var{f}, 1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4882 @result{} 2.7183 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4883 @var{f} (1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4884 @result{} 2.7183 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4885 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4886 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4887 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4888 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4889 are equivalent ways to call the function referred to by @var{f}. If it |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4890 cannot be predicted beforehand whether @var{f} is a function handle, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4891 function name in a string, or inline function then @code{feval} can be used |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4892 instead. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4893 @end deftypefn */) |
3021 | 4894 { |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20798
diff
changeset
|
4895 if (args.length () == 0) |
5823 | 4896 print_usage (); |
3021 | 4897 |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4898 return feval (args, nargout); |
3021 | 4899 } |
4900 | |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
4901 DEFUN (builtin, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4902 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4903 @deftypefn {} {[@dots{}] =} builtin (@var{f}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4904 Call the base function @var{f} even if @var{f} is overloaded to another |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4905 function for the given type signature. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4906 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4907 This is normally useful when doing object-oriented programming and there is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4908 a requirement to call one of Octave's base functions rather than the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4909 overloaded one of a new class. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4910 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4911 A trivial example which redefines the @code{sin} function to be the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4912 @code{cos} function shows how @code{builtin} works. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4913 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4914 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4915 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4916 sin (0) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4917 @result{} 0 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4918 function y = sin (x), y = cos (x); endfunction |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4919 sin (0) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4920 @result{} 1 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4921 builtin ("sin", 0) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4922 @result{} 0 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4923 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4924 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4925 @end deftypefn */) |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
4926 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
4927 octave_value_list retval; |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
4928 |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20798
diff
changeset
|
4929 if (args.length () == 0) |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4930 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4931 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4932 const std::string name (args(0).xstring_value ("builtin: function name (F) must be a string")); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4933 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4934 octave_value fcn = symbol_table::builtin_find (name); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4935 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4936 if (fcn.is_defined ()) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4937 retval = feval (fcn.function_value (), args.splice (0, 1), nargout); |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
4938 else |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4939 error ("builtin: lookup for symbol '%s' failed", name.c_str ()); |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
4940 |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
4941 return retval; |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
4942 } |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
4943 |
3099 | 4944 octave_value_list |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
4945 eval_string (const std::string& eval_str, bool silent, |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
4946 int& parse_status, int nargout) |
3021 | 4947 { |
3877 | 4948 octave_value_list retval; |
4949 | |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4950 octave::parser parser (eval_str); |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
4951 |
3877 | 4952 do |
4953 { | |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4954 parser.reset (); |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4955 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4956 parse_status = parser.run (); |
3877 | 4957 |
3883 | 4958 if (parse_status == 0) |
3877 | 4959 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4960 if (parser.stmt_list) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4961 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4962 tree_statement *stmt = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4963 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4964 if (parser.stmt_list->length () == 1 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4965 && (stmt = parser.stmt_list->front ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4966 && stmt->is_expression ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4967 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4968 tree_expression *expr = stmt->expression (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4969 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4970 if (silent) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4971 expr->set_print_flag (false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4972 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4973 bool do_bind_ans = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4974 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4975 if (expr->is_identifier ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4976 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4977 tree_identifier *id |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4978 = dynamic_cast<tree_identifier *> (expr); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4979 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4980 do_bind_ans = (! id->is_variable ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4981 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4982 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4983 do_bind_ans = (! expr->is_assignment_expression ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4984 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4985 retval = expr->rvalue (nargout); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4986 |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4987 if (do_bind_ans && ! retval.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4988 bind_ans (retval(0), expr->print_result ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4989 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4990 if (nargout == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4991 retval = octave_value_list (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4992 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4993 else if (nargout == 0) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4994 parser.stmt_list->accept (*octave::current_evaluator); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4995 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4996 error ("eval: invalid use of statement list"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4997 |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4998 if (tree_return_command::returning |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4999 || tree_break_command::breaking |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
5000 || tree_continue_command::continuing) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
5001 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
5002 } |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
5003 else if (parser.lexer.end_of_input) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
5004 break; |
3883 | 5005 } |
3877 | 5006 } |
5007 while (parse_status == 0); | |
3021 | 5008 |
5009 return retval; | |
5010 } | |
5011 | |
5012 octave_value | |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
5013 eval_string (const std::string& eval_str, bool silent, int& parse_status) |
3021 | 5014 { |
5015 octave_value retval; | |
5016 | |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
5017 octave_value_list tmp = eval_string (eval_str, silent, parse_status, 1); |
3021 | 5018 |
5019 if (! tmp.empty ()) | |
5020 retval = tmp(0); | |
5021 | |
5022 return retval; | |
5023 } | |
5024 | |
5025 static octave_value_list | |
5026 eval_string (const octave_value& arg, bool silent, int& parse_status, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
5027 int nargout) |
3021 | 5028 { |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
5029 std::string s = arg.xstring_value ("eval: expecting std::string argument"); |
3021 | 5030 |
5031 return eval_string (s, silent, parse_status, nargout); | |
5032 } | |
5033 | |
13970 | 5034 void |
5035 cleanup_statement_list (tree_statement_list **lst) | |
5036 { | |
5037 if (*lst) | |
5038 { | |
5039 delete *lst; | |
5040 *lst = 0; | |
5041 } | |
5042 } | |
5043 | |
3021 | 5044 DEFUN (eval, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5045 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5046 @deftypefn {} {} eval (@var{try}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5047 @deftypefnx {} {} eval (@var{try}, @var{catch}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5048 Parse the string @var{try} and evaluate it as if it were an Octave |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5049 program. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5050 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5051 If execution fails, evaluate the optional string @var{catch}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5052 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5053 The string @var{try} is evaluated in the current context, so any results |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5054 remain available after @code{eval} returns. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5055 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5056 The following example creates the variable @var{A} with the approximate |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5057 value of 3.1416 in the current workspace. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5058 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5059 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5060 eval ("A = acos(-1);"); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5061 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5062 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5063 If an error occurs during the evaluation of @var{try} then the @var{catch} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5064 string is evaluated, as the following example shows: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5065 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5066 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5067 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5068 eval ('error ("This is a bad example");', |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5069 'printf ("This error occurred:\n%s\n", lasterr ());'); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5070 @print{} This error occurred: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5071 This is a bad example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5072 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5073 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5074 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5075 Programming Note: if you are only using @code{eval} as an error-capturing |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5076 mechanism, rather than for the execution of arbitrary code strings, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5077 Consider using try/catch blocks or unwind_protect/unwind_protect_cleanup |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5078 blocks instead. These techniques have higher performance and don't |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5079 introduce the security considerations that the evaluation of arbitrary code |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5080 does. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5081 @seealso{evalin, evalc, assignin, feval} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5082 @end deftypefn */) |
3021 | 5083 { |
5084 octave_value_list retval; | |
5085 | |
5086 int nargin = args.length (); | |
5087 | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5088 if (nargin == 0) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5089 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5090 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21740
diff
changeset
|
5091 octave::unwind_protect frame; |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5092 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5093 if (nargin > 1) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5094 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5095 frame.protect_var (buffer_error_messages); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5096 buffer_error_messages++; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5097 } |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5098 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5099 int parse_status = 0; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5100 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5101 bool execution_error = false; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5102 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5103 octave_value_list tmp; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5104 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5105 try |
3021 | 5106 { |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5107 tmp = eval_string (args(0), nargout > 0, parse_status, nargout); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5108 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
5109 catch (const octave::execution_exception&) |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5110 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5111 recover_from_exception (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5112 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5113 execution_error = true; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5114 } |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5115 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5116 if (nargin > 1 && (parse_status != 0 || execution_error)) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5117 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5118 // Set up for letting the user print any messages from |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5119 // errors that occurred in the first part of this eval(). |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5120 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5121 buffer_error_messages--; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5122 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5123 tmp = eval_string (args(1), nargout > 0, parse_status, nargout); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5124 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5125 if (nargout > 0) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5126 retval = tmp; |
3021 | 5127 } |
5128 else | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5129 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5130 if (nargout > 0) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5131 retval = tmp; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5132 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5133 // FIXME: we should really be rethrowing whatever exception occurred, |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5134 // not just throwing an execution exception. |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5135 if (execution_error) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5136 octave_throw_execution_exception (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5137 } |
3021 | 5138 |
5139 return retval; | |
5140 } | |
5141 | |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5142 /* |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5143 |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5144 %!shared x |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5145 %! x = 1; |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5146 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5147 %!assert (eval ("x"), 1) |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5148 %!assert (eval ("x;")) |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
5149 %!assert (eval ("x;"), 1) |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5150 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5151 %!test |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5152 %! y = eval ("x"); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5153 %! assert (y, 1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5154 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5155 %!test |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5156 %! y = eval ("x;"); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5157 %! assert (y, 1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5158 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5159 %!test |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21416
diff
changeset
|
5160 %! eval ("x = 1;"); |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5161 %! assert (x,1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5162 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5163 %!test |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5164 %! eval ("flipud = 2;"); |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5165 %! assert (flipud, 2); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5166 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5167 %!function y = __f () |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5168 %! eval ("flipud = 2;"); |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5169 %! y = flipud; |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5170 %!endfunction |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5171 %!assert (__f(), 2) |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5172 |
14533
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
5173 % bug #35645 |
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
5174 %!test |
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
5175 %! [a,] = gcd (1,2); |
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
5176 %! [a,b,] = gcd (1, 2); |
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
5177 |
21581
6fab85c1538f
maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
5178 %!error eval ("switch = 13;") |
21369
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5179 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5180 */ |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5181 |
4661 | 5182 DEFUN (assignin, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5183 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5184 @deftypefn {} {} assignin (@var{context}, @var{varname}, @var{value}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5185 Assign @var{value} to @var{varname} in context @var{context}, which |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5186 may be either @qcode{"base"} or @qcode{"caller"}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5187 @seealso{evalin} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5188 @end deftypefn */) |
4297 | 5189 { |
5190 octave_value_list retval; | |
5191 | |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20798
diff
changeset
|
5192 if (args.length () != 3) |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5193 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5194 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5195 std::string context = args(0).xstring_value ("assignin: CONTEXT must be a string"); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5196 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21740
diff
changeset
|
5197 octave::unwind_protect frame; |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5198 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5199 if (context == "caller") |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5200 octave_call_stack::goto_caller_frame (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5201 else if (context == "base") |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5202 octave_call_stack::goto_base_frame (); |
4297 | 5203 else |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5204 error ("assignin: CONTEXT must be \"caller\" or \"base\""); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5205 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5206 frame.add_fcn (octave_call_stack::pop); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5207 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5208 std::string nm = args(1).xstring_value ("assignin: VARNAME must be a string"); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5209 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5210 if (valid_identifier (nm)) |
21369
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5211 { |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5212 // Put the check here so that we don't slow down assignments |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5213 // generally. Any that go through Octave's parser should have |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5214 // already been checked. |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5215 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5216 if (octave::is_keyword (nm)) |
21369
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5217 error ("assignin: invalid assignment to keyword '%s'", nm.c_str ()); |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5218 |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5219 symbol_table::assign (nm, args(2)); |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5220 } |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5221 else |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5222 error ("assignin: invalid variable name in argument VARNAME"); |
4297 | 5223 |
5224 return retval; | |
5225 } | |
5226 | |
21369
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5227 /* |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5228 |
21581
6fab85c1538f
maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
5229 %!error assignin ("base", "switch", "13") |
21369
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5230 |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5231 */ |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5232 |
4245 | 5233 DEFUN (evalin, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5234 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5235 @deftypefn {} {} evalin (@var{context}, @var{try}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5236 @deftypefnx {} {} evalin (@var{context}, @var{try}, @var{catch}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5237 Like @code{eval}, except that the expressions are evaluated in the context |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5238 @var{context}, which may be either @qcode{"caller"} or @qcode{"base"}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5239 @seealso{eval, assignin} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5240 @end deftypefn */) |
4245 | 5241 { |
5242 octave_value_list retval; | |
5243 | |
5244 int nargin = args.length (); | |
5245 | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5246 if (nargin < 2) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5247 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5248 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5249 std::string context = args(0).xstring_value ("evalin: CONTEXT must be a string"); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5250 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21740
diff
changeset
|
5251 octave::unwind_protect frame; |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5252 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5253 if (context == "caller") |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5254 octave_call_stack::goto_caller_frame (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5255 else if (context == "base") |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5256 octave_call_stack::goto_base_frame (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5257 else |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5258 error ("evalin: CONTEXT must be \"caller\" or \"base\""); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5259 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5260 frame.add_fcn (octave_call_stack::pop); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5261 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5262 if (nargin > 2) |
4245 | 5263 { |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5264 frame.protect_var (buffer_error_messages); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5265 buffer_error_messages++; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5266 } |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5267 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5268 int parse_status = 0; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5269 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5270 bool execution_error = false; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5271 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5272 octave_value_list tmp; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5273 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5274 try |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5275 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5276 tmp = eval_string (args(1), nargout > 0, |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5277 parse_status, nargout); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5278 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
5279 catch (const octave::execution_exception&) |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5280 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5281 recover_from_exception (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5282 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5283 execution_error = true; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5284 } |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5285 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5286 if (nargin > 2 && (parse_status != 0 || execution_error)) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5287 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5288 // Set up for letting the user print any messages from |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5289 // errors that occurred in the first part of this eval(). |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5290 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5291 buffer_error_messages--; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5292 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5293 tmp = eval_string (args(2), nargout > 0, |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5294 parse_status, nargout); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5295 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5296 retval = (nargout > 0) ? tmp : octave_value_list (); |
4245 | 5297 } |
5298 else | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5299 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5300 if (nargout > 0) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5301 retval = tmp; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5302 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5303 // FIXME: we should really be rethrowing whatever |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5304 // exception occurred, not just throwing an |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5305 // execution exception. |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5306 if (execution_error) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5307 octave_throw_execution_exception (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5308 } |
4245 | 5309 |
5310 return retval; | |
5311 } | |
5312 | |
22504
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5313 static void |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5314 maybe_print_last_error_message (bool *doit) |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5315 { |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5316 if (doit && *doit) |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5317 // Print error message again, which was lost because of the stderr buffer |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5318 // Note: this keeps error_state and last_error_stack intact |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5319 message_with_id ("error", last_error_id ().c_str (), |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5320 last_error_message ().c_str ()); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5321 } |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5322 |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5323 static void |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5324 restore_octave_stdout (std::streambuf *buf) |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5325 { |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5326 octave_stdout.flush (); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5327 octave_stdout.rdbuf (buf); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5328 } |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5329 |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5330 static void |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5331 restore_octave_stderr (std::streambuf *buf) |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5332 { |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5333 std::cerr.flush (); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5334 std::cerr.rdbuf (buf); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5335 } |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5336 |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5337 DEFUN (evalc, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5338 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5339 @deftypefn {} {@var{s} =} evalc (@var{try}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5340 @deftypefnx {} {@var{s} =} evalc (@var{try}, @var{catch}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5341 Parse and evaluate the string @var{try} as if it were an Octave program, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5342 while capturing the output into the return variable @var{s}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5343 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5344 If execution fails, evaluate the optional string @var{catch}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5345 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5346 This function behaves like @code{eval}, but any output or warning messages |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5347 which would normally be written to the console are captured and returned in |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5348 the string @var{s}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5349 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5350 The @code{diary} is disabled during the execution of this function. When |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5351 @code{system} is used, any output produced by external programs is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5352 @emph{not} captured, unless their output is captured by the @code{system} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5353 function itself. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5354 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5355 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5356 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5357 s = evalc ("t = 42"), t |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5358 @result{} s = t = 42 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5359 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5360 @result{} t = 42 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5361 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5362 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5363 @seealso{eval, diary} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5364 @end deftypefn */) |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5365 { |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5366 int nargin = args.length (); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5367 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5368 if (nargin == 0 || nargin > 2) |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5369 print_usage (); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5370 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5371 // redirect stdout/stderr to capturing buffer |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5372 std::ostringstream buffer; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5373 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5374 std::ostream& out_stream = octave_stdout; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5375 std::ostream& err_stream = std::cerr; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5376 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5377 out_stream.flush (); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5378 err_stream.flush (); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5379 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5380 std::streambuf* old_out_buf = out_stream.rdbuf (buffer.rdbuf ()); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5381 std::streambuf* old_err_buf = err_stream.rdbuf (buffer.rdbuf ()); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5382 |
22504
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5383 bool eval_error_occurred = true; |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5384 |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5385 octave::unwind_protect frame; |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5386 |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5387 frame.add_fcn (maybe_print_last_error_message, &eval_error_occurred); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5388 frame.add_fcn (restore_octave_stdout, old_out_buf); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5389 frame.add_fcn (restore_octave_stderr, old_err_buf); |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5390 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5391 // call standard eval function |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5392 octave_value_list retval; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5393 int eval_nargout = std::max (0, nargout - 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5394 |
22504
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5395 retval = Feval (args, eval_nargout); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5396 eval_error_occurred = false; |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5397 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5398 retval.prepend (buffer.str ()); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5399 return retval; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5400 } |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5401 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5402 /* |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5403 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5404 %!assert (evalc ("1"), "ans = 1\n") |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5405 %!assert (evalc ("1;"), "") |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5406 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5407 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5408 %! [s, y] = evalc ("1"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5409 %! assert (s, ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5410 %! assert (y, 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5411 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5412 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5413 %! [s, y] = evalc ("1;"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5414 %! assert (s, ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5415 %! assert (y, 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5416 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5417 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5418 %! assert (evalc ("y = 2"), "y = 2\n"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5419 %! assert (y, 2); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5420 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5421 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5422 %! assert (evalc ("y = 3;"), ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5423 %! assert (y, 3); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5424 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5425 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5426 %! [s, a, b] = evalc ("deal (1, 2)"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5427 %! assert (s, ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5428 %! assert (a, 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5429 %! assert (b, 2); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5430 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5431 %!function [a, b] = __f_evalc () |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5432 %! printf ("foo"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5433 %! fprintf (stdout, "bar"); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21416
diff
changeset
|
5434 %! disp (pi); |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5435 %! a = 1; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5436 %! b = 2; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5437 %!endfunction |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5438 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5439 %! [s, a, b] = evalc ("__f_evalc ()"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5440 %! assert (s, "foobar 3.1416\n"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5441 %! assert (a, 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5442 %! assert (b, 2); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5443 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5444 %!error <foo> (evalc ("error ('foo')")) |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5445 %!error <bar> (evalc ("error ('foo')", "error ('bar')")) |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5446 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5447 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5448 %! warning ("off", "quiet", "local"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5449 %! assert (evalc ("warning ('foo')"), "warning: foo\n"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5450 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5451 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5452 %! warning ("off", "quiet", "local"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5453 %! assert (evalc ("error ('foo')", "warning ('bar')"), "warning: bar\n"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5454 |
21581
6fab85c1538f
maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
5455 %!error evalc ("switch = 13;") |
21369
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5456 |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5457 */ |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5458 |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5459 DEFUN (__parser_debug_flag__, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5460 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5461 @deftypefn {} {@var{val} =} __parser_debug_flag__ () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5462 @deftypefnx {} {@var{old_val} =} __parser_debug_flag__ (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5463 Query or set the internal flag that determines whether Octave's parser |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5464 prints debug information as it processes an expression. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5465 @seealso{__lexer_debug_flag__} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5466 @end deftypefn */) |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5467 { |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5468 octave_value retval; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5469 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5470 bool debug_flag = octave_debug; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5471 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5472 retval = set_internal_variable (debug_flag, args, nargout, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
5473 "__parser_debug_flag__"); |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5474 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5475 octave_debug = debug_flag; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5476 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5477 return retval; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5478 } |
17342
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5479 |
17377
15e2ad6372f7
maint: Tweaks to remove compiler warnings.
Rik <rik@octave.org>
parents:
17342
diff
changeset
|
5480 DEFUN (__parse_file__, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5481 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5482 @deftypefn {} {} __parse_file__ (@var{file}, @var{verbose}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5483 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5484 @end deftypefn */) |
17342
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5485 { |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5486 octave_value retval; |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5487 |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5488 int nargin = args.length (); |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5489 |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5490 if (nargin < 1 || nargin > 2) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5491 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5492 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5493 std::string file = args(0).xstring_value ("__parse_file__: expecting filename as argument"); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5494 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
5495 std::string full_file = octave::sys::env::make_absolute (file); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5496 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5497 size_t file_len = file.length (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5498 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5499 if ((file_len > 4 && file.substr (file_len-4) == ".oct") |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5500 || (file_len > 4 && file.substr (file_len-4) == ".mex") |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5501 || (file_len > 2 && file.substr (file_len-2) == ".m")) |
17342
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5502 { |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
5503 file = octave::sys::env::base_pathname (file); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5504 file = file.substr (0, file.find_last_of ('.')); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5505 |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
5506 size_t pos = file.find_last_of (octave::sys::file_ops::dir_sep_str ()); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5507 if (pos != std::string::npos) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5508 file = file.substr (pos+1); |
17342
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5509 } |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5510 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5511 if (nargin == 2) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5512 octave_stdout << "parsing " << full_file << std::endl; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5513 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5514 octave_function *fcn = parse_fcn_file (full_file, file, "", "", |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5515 true, false, false, |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5516 false, "__parse_file__"); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5517 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5518 if (fcn) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5519 delete fcn; |
17342
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5520 |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5521 return retval; |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5522 } |