Mercurial > octave
annotate libinterp/parse-tree/oct-parse.in.yy @ 23577:80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
* ov.h (is_empty): Use OCTAVE_DEPRECATED macro around function.
* ov.h (isempty): New function.
* Array.h (is_empty): Use OCTAVE_DEPRECATED macro around function.
* Array.h (isempty): New function.
* Range.h (is_empty): Use OCTAVE_DEPRECATED macro around function.
* Range.h (isempty): New function.
* Sparse.h (is_empty): Use OCTAVE_DEPRECATED macro around function.
* Sparse.h (isempty): New function.
* Backend.cc, BaseControl.cc, Canvas.cc, Figure.cc, gl-select.cc,
__magick_read__.cc, __qp__.cc, cellfun.cc, daspk.cc, dasrt.cc, dassl.cc,
data.cc, debug.cc, det.cc, eig.cc, error.cc, fft.cc, filter.cc, find.cc,
ft-text-renderer.cc, gl-render.cc, gl2ps-print.cc, graphics.cc, graphics.in.h,
hess.cc, inv.cc, lsode.cc, lu.cc, max.cc, mex.cc, mxarray.in.h, oct-handle.h,
oct-lvalue.cc, oct-map.cc, oct-map.h, oct-stream.cc, pinv.cc, pr-output.cc,
quadcc.cc, qz.cc, strfind.cc, strfns.cc, sylvester.cc, time.cc, toplev.cc,
tril.cc, urlwrite.cc, utils.cc, utils.h, xnorm.cc, __delaunayn__.cc,
__glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc,
__voronoi__.cc, chol.cc, convhulln.cc, ov-base-diag.cc, ov-base-mat.cc,
ov-base-sparse.cc, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-sparse.cc,
ov-cell.cc, ov-class.cc, ov-classdef.cc, ov-cx-sparse.cc, ov-fcn-inline.cc,
ov-flt-re-mat.cc, ov-intx.h, ov-java.cc, ov-perm.cc, ov-range.cc, ov-re-mat.cc,
ov-re-sparse.cc, ov-str-mat.cc, ov-struct.cc, ov-usr-fcn.cc, ov.cc, ov.h,
bp-table.cc, oct-parse.in.yy, pt-eval.cc, pt-tm-const.cc, pt-tm-const.h,
Array.cc, Range.cc, Range.h, Sparse.cc, Sparse.h, chNDArray.cc, dNDArray.cc,
fNDArray.cc, DASPK.cc, DASRT.cc, DASSL.cc, LSODE.cc, bsxfun-defs.cc,
eigs-base.cc, oct-convn.cc, qr.cc:
Replace instances of is_empty with isempty.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 11 Jun 2017 22:14:09 -0700 |
parents | 00e518162fda |
children | 5cb3a2bb5e1e |
rev | line source |
---|---|
1829 | 1 /* |
1 | 2 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23049
diff
changeset
|
3 Copyright (C) 1993-2017 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" |
23454
30b6eccd6708
use builtin-defun-decls.h to ensure declarations of interpreter functions
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
56 #include "builtin-defun-decls.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
22003
diff
changeset
|
57 #include "call-stack.h" |
3665 | 58 #include "comment-list.h" |
4243 | 59 #include "defaults.h" |
2166 | 60 #include "defun.h" |
4243 | 61 #include "dirfns.h" |
3021 | 62 #include "dynamic-ld.h" |
1351 | 63 #include "error.h" |
64 #include "input.h" | |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
65 #include "interpreter-private.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
66 #include "interpreter.h" |
1351 | 67 #include "lex.h" |
5832 | 68 #include "load-path.h" |
1743 | 69 #include "oct-hist.h" |
5626 | 70 #include "oct-map.h" |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
71 #include "ov-classdef.h" |
4935 | 72 #include "ov-fcn-handle.h" |
2970 | 73 #include "ov-usr-fcn.h" |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
74 #include "ov-null-mat.h" |
1351 | 75 #include "pager.h" |
76 #include "parse.h" | |
2987 | 77 #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
|
78 #include "pt-eval.h" |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
79 #include "pt-funcall.h" |
1351 | 80 #include "symtab.h" |
81 #include "token.h" | |
3021 | 82 #include "unwind-prot.h" |
1 | 83 #include "utils.h" |
1351 | 84 #include "variables.h" |
1 | 85 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
86 // oct-parse.h must be included after pt-all.h |
23479
06bf3a0b08bf
maint: Use "" instead of <> for our own include files.
John W. Eaton <jwe@octave.org>
parents:
23473
diff
changeset
|
87 #include "oct-parse.h" |
16149
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 extern int octave_lex (YYSTYPE *, void *); |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
90 |
5484 | 91 // List of autoloads (function -> file mapping). |
92 static std::map<std::string, std::string> autoload_map; | |
93 | |
496 | 94 // Forward declarations for some functions defined at the bottom of |
95 // the file. | |
96 | |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
97 static void yyerror (octave::base_parser& parser, const char *s); |
1 | 98 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
99 #define lexer parser.lexer |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
100 #define scanner lexer.scanner |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
101 |
21023
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
102 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
103 // 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
|
104 // 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
|
105 // 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
|
106 #pragma GCC diagnostic push |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
107 #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
|
108 #endif |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
109 |
1 | 110 %} |
111 | |
666 | 112 // Bison declarations. |
113 | |
17743
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
114 // 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
|
115 // we notice if that number changes. |
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
116 |
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
117 %expect 14 |
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
118 |
18974
d8abf813c69f
handle changes in bison 3.x
John W. Eaton <jwe@octave.org>
parents:
18531
diff
changeset
|
119 %API_PREFIX_DECL% |
4753 | 120 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
121 // 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
|
122 // 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
|
123 // 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
|
124 // 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
|
125 // 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
|
126 // 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
|
127 // 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
|
128 // 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
|
129 |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
130 %define api.pure |
16174
39096b290a2f
check syntax used to enable bison push/pull parser
John W. Eaton <jwe@octave.org>
parents:
16167
diff
changeset
|
131 %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
|
132 %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
|
133 %lex-param { void *scanner } |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
134 |
1 | 135 %union |
136 { | |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
137 int dummy_type; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
138 |
2891 | 139 // The type of the basic tokens returned by the lexer. |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
140 octave::token *tok_val; |
143 | 141 |
3665 | 142 // Comment strings that we need to deal with mid-rule. |
143 octave_comment_list *comment_type; | |
144 | |
2891 | 145 // 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
|
146 char punct_type; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
147 octave::tree *tree_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
148 octave::tree_matrix *tree_matrix_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
149 octave::tree_cell *tree_cell_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
150 octave::tree_expression *tree_expression_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
151 octave::tree_constant *tree_constant_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
152 octave::tree_fcn_handle *tree_fcn_handle_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
153 octave::tree_funcall *tree_funcall_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
154 octave::tree_function_def *tree_function_def_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
155 octave::tree_anon_fcn_handle *tree_anon_fcn_handle_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
156 octave::tree_identifier *tree_identifier_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
157 octave::tree_index_expression *tree_index_expression_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
158 octave::tree_colon_expression *tree_colon_expression_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
159 octave::tree_argument_list *tree_argument_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
160 octave::tree_parameter_list *tree_parameter_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
161 octave::tree_command *tree_command_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
162 octave::tree_if_command *tree_if_command_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
163 octave::tree_if_clause *tree_if_clause_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
164 octave::tree_if_command_list *tree_if_command_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
165 octave::tree_switch_command *tree_switch_command_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
166 octave::tree_switch_case *tree_switch_case_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
167 octave::tree_switch_case_list *tree_switch_case_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
168 octave::tree_decl_elt *tree_decl_elt_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
169 octave::tree_decl_init_list *tree_decl_init_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
170 octave::tree_decl_command *tree_decl_command_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
171 octave::tree_statement *tree_statement_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
172 octave::tree_statement_list *tree_statement_list_type; |
2891 | 173 octave_user_function *octave_user_function_type; |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
174 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
175 octave::tree_classdef *tree_classdef_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
176 octave::tree_classdef_attribute* tree_classdef_attribute_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
177 octave::tree_classdef_attribute_list* tree_classdef_attribute_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
178 octave::tree_classdef_superclass* tree_classdef_superclass_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
179 octave::tree_classdef_superclass_list* tree_classdef_superclass_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
180 octave::tree_classdef_body* tree_classdef_body_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
181 octave::tree_classdef_property* tree_classdef_property_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
182 octave::tree_classdef_property_list* tree_classdef_property_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
183 octave::tree_classdef_properties_block* tree_classdef_properties_block_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
184 octave::tree_classdef_methods_list* tree_classdef_methods_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
185 octave::tree_classdef_methods_block* tree_classdef_methods_block_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
186 octave::tree_classdef_event* tree_classdef_event_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
187 octave::tree_classdef_events_list* tree_classdef_events_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
188 octave::tree_classdef_events_block* tree_classdef_events_block_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
189 octave::tree_classdef_enum* tree_classdef_enum_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
190 octave::tree_classdef_enum_list* tree_classdef_enum_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
191 octave::tree_classdef_enum_block* tree_classdef_enum_block_type; |
1 | 192 } |
193 | |
143 | 194 // Tokens with line and column information. |
195 %token <tok_val> '=' ':' '-' '+' '*' '/' | |
4018 | 196 %token <tok_val> ADD_EQ SUB_EQ MUL_EQ DIV_EQ LEFTDIV_EQ POW_EQ |
197 %token <tok_val> EMUL_EQ EDIV_EQ ELEFTDIV_EQ EPOW_EQ AND_EQ OR_EQ | |
428 | 198 %token <tok_val> EXPR_AND_AND EXPR_OR_OR |
143 | 199 %token <tok_val> EXPR_AND EXPR_OR EXPR_NOT |
200 %token <tok_val> EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT | |
1276 | 201 %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
|
202 %token <tok_val> HERMITIAN TRANSPOSE |
143 | 203 %token <tok_val> PLUS_PLUS MINUS_MINUS POW EPOW |
204 %token <tok_val> NUM IMAG_NUM | |
2970 | 205 %token <tok_val> STRUCT_ELT |
2883 | 206 %token <tok_val> NAME |
143 | 207 %token <tok_val> END |
5279 | 208 %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
|
209 %token <tok_val> FOR PARFOR WHILE DO UNTIL |
1491 | 210 %token <tok_val> IF ELSEIF ELSE |
2764 | 211 %token <tok_val> SWITCH CASE OTHERWISE |
1491 | 212 %token <tok_val> BREAK CONTINUE FUNC_RET |
924 | 213 %token <tok_val> UNWIND CLEANUP |
1489 | 214 %token <tok_val> TRY CATCH |
14294
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14293
diff
changeset
|
215 %token <tok_val> GLOBAL PERSISTENT |
4342 | 216 %token <tok_val> FCN_HANDLE |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
217 %token <tok_val> CLASSDEF |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
218 %token <tok_val> PROPERTIES METHODS EVENTS ENUMERATION |
9476 | 219 %token <tok_val> METAQUERY |
220 %token <tok_val> SUPERCLASSREF | |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
221 %token <tok_val> FQ_IDENT |
9476 | 222 %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
|
223 %token <tok_val> FCN |
21064
a9f2c2d72892
handle lexical errors as parser errors (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21063
diff
changeset
|
224 %token <tok_val> LEXICAL_ERROR |
1 | 225 |
143 | 226 // Other tokens. |
21064
a9f2c2d72892
handle lexical errors as parser errors (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21063
diff
changeset
|
227 %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
|
228 %token<dummy_type> INPUT_FILE |
7587
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7562
diff
changeset
|
229 // %token VARARGIN VARARGOUT |
1 | 230 |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
231 %token<dummy_type> '(' ')' '[' ']' '{' '}' '.' ',' ';' '@' '\n' |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
232 |
143 | 233 // Nonterminals we construct. |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
234 %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
|
235 %type <dummy_type> param_list_beg param_list_end stmt_begin parse_error |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
236 %type <dummy_type> parsing_local_fcns |
16644
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
237 %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
|
238 %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
|
239 %type <punct_type> sep_no_nl opt_sep_no_nl nl opt_nl sep opt_sep |
578 | 240 %type <tree_type> input |
5861 | 241 %type <tree_constant_type> string constant magic_colon |
242 %type <tree_anon_fcn_handle_type> anon_fcn_handle | |
4342 | 243 %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
|
244 %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
|
245 %type <tree_cell_type> cell_rows |
5102 | 246 %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
|
247 %type <tree_expression_type> primary_expr oper_expr power_expr |
4207 | 248 %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
|
249 %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
|
250 %type <tree_funcall_type> superclass_identifier meta_identifier |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
251 %type <octave_user_function_type> function1 function2 |
2970 | 252 %type <tree_index_expression_type> word_list_cmd |
253 %type <tree_colon_expression_type> colon_expr1 | |
3351 | 254 %type <tree_argument_list_type> arg_list word_list assign_lhs |
255 %type <tree_argument_list_type> cell_or_matrix_row | |
4935 | 256 %type <tree_parameter_list_type> param_list param_list1 param_list2 |
723 | 257 %type <tree_parameter_list_type> return_list return_list1 |
2970 | 258 %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
|
259 %type <tree_command_type> jump_command except_command |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
260 %type <tree_function_def_type> function |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
261 %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
|
262 %type <tree_command_type> file |
578 | 263 %type <tree_if_command_type> if_command |
264 %type <tree_if_clause_type> elseif_clause else_clause | |
265 %type <tree_if_command_list_type> if_cmd_list1 if_cmd_list | |
2764 | 266 %type <tree_switch_command_type> switch_command |
267 %type <tree_switch_case_type> switch_case default_case | |
268 %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
|
269 %type <tree_decl_elt_type> decl2 param_list_elt |
2846 | 270 %type <tree_decl_init_list_type> decl1 |
271 %type <tree_decl_command_type> declaration | |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
272 %type <tree_statement_type> statement function_end |
627 | 273 %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
|
274 %type <tree_statement_list_type> opt_list |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
275 %type <tree_statement_list_type> opt_fcn_list fcn_list fcn_list1 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
276 %type <tree_classdef_attribute_type> attr |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
277 %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
|
278 %type <tree_classdef_superclass_type> superclass |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
279 %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
|
280 %type <tree_classdef_body_type> class_body |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
281 %type <tree_classdef_property_type> class_property |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
282 %type <tree_classdef_property_list_type> property_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
283 %type <tree_classdef_properties_block_type> properties_block |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
284 %type <tree_classdef_methods_list_type> methods_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
285 %type <tree_classdef_methods_block_type> methods_block |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
286 %type <tree_classdef_event_type> class_event |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
287 %type <tree_classdef_events_list_type> events_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
288 %type <tree_classdef_events_block_type> events_block |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
289 %type <tree_classdef_enum_type> class_enum |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
290 %type <tree_classdef_enum_list_type> enum_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
291 %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
|
292 %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
|
293 %type <octave_user_function_type> method_decl1 |
1 | 294 |
143 | 295 // Precedence and associativity. |
21294
3d375b0905a0
eliminate unused << and >> operators from Octave scripting language
John W. Eaton <jwe@octave.org>
parents:
21159
diff
changeset
|
296 %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 | 297 %left EXPR_OR_OR |
298 %left EXPR_AND_AND | |
299 %left EXPR_OR | |
300 %left EXPR_AND | |
1 | 301 %left EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT |
302 %left ':' | |
1276 | 303 %left '-' '+' EPLUS EMINUS |
1 | 304 %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
|
305 %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
|
306 %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
|
307 %right PLUS_PLUS MINUS_MINUS |
3351 | 308 %left '(' '.' '{' |
1 | 309 |
17629
1e8f8900a041
clean up partially constructed parse tree objects on parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17622
diff
changeset
|
310 // 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
|
311 // 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
|
312 // 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
|
313 // 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
|
314 // 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
|
315 // here). |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
316 |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
317 %destructor { } <tok_val> |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
318 %destructor { } <punct_type> |
17658
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
319 %destructor { } <comment_type> |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
320 %destructor { } <> |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
321 |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
322 %destructor { delete $$; } <tree_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
323 %destructor { delete $$; } <tree_matrix_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
324 %destructor { delete $$; } <tree_cell_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
325 %destructor { delete $$; } <tree_expression_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
326 %destructor { delete $$; } <tree_constant_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
327 %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
|
328 %destructor { delete $$; } <tree_funcall_type> |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
329 %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
|
330 %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
|
331 %destructor { delete $$; } <tree_identifier_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
332 %destructor { delete $$; } <tree_index_expression_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
333 %destructor { delete $$; } <tree_colon_expression_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
334 %destructor { delete $$; } <tree_argument_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
335 %destructor { delete $$; } <tree_parameter_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
336 %destructor { delete $$; } <tree_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
337 %destructor { delete $$; } <tree_if_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
338 %destructor { delete $$; } <tree_if_clause_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
339 %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
|
340 %destructor { delete $$; } <tree_switch_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
341 %destructor { delete $$; } <tree_switch_case_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
342 %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
|
343 %destructor { delete $$; } <tree_decl_elt_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
344 %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
|
345 %destructor { delete $$; } <tree_decl_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
346 %destructor { delete $$; } <tree_statement_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
347 %destructor { delete $$; } <tree_statement_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
348 %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
|
349 |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
350 %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
|
351 %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
|
352 %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
|
353 %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
|
354 %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
|
355 %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
|
356 %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
|
357 %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
|
358 %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
|
359 %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
|
360 %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
|
361 %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
|
362 %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
|
363 %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
|
364 %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
|
365 %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
|
366 %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
|
367 |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
368 // 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
|
369 // already explicitly declared for all types. |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
370 // |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
371 // %destructor { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
372 // warning_with_id |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
373 // ("Octave:parser-destructor", |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
374 // "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
|
375 // } <*> |
17629
1e8f8900a041
clean up partially constructed parse tree objects on parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17622
diff
changeset
|
376 |
143 | 377 // Where to start. |
1 | 378 %start input |
379 | |
380 %% | |
381 | |
2970 | 382 // ============================== |
383 // Statements and statement lists | |
384 // ============================== | |
385 | |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
386 input : simple_list '\n' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
387 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
388 $$ = 0; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
389 parser.stmt_list = $1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
390 YYACCEPT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
391 } |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
392 | simple_list END_OF_INPUT |
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
393 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
394 $$ = 0; |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
395 lexer.end_of_input = true; |
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
396 parser.stmt_list = $1; |
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
397 YYACCEPT; |
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
398 } |
17326
f444e4cef9b9
avoid exiting Octave on parse error (bug #39862)
John W. Eaton <jwe@octave.org>
parents:
17322
diff
changeset
|
399 | parse_error |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
400 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
401 $$ = 0; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
402 YYABORT; |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
403 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
404 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
405 |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
406 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
|
407 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
408 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
409 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
410 $$ = 0; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
411 } |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
412 | 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
|
413 { $$ = 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
|
414 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
415 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
416 simple_list1 : statement |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
417 { $$ = parser.make_statement_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
418 | 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
|
419 { $$ = 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
|
420 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
421 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
422 opt_list : // empty |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
423 { $$ = new octave::tree_statement_list (); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
424 | list |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
425 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
426 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
427 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
428 list : list1 opt_sep |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
429 { $$ = 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
|
430 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
431 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
432 list1 : statement |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
433 { $$ = parser.make_statement_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
434 | list1 sep statement |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
435 { $$ = 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
|
436 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
437 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
438 opt_fcn_list : // empty |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
439 { $$ = 0; } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
440 | fcn_list |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
441 { $$ = $1; } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
442 ; |
23396
945b53af4655
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
23343
diff
changeset
|
443 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
444 fcn_list : fcn_list1 opt_sep |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
445 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
446 YYUSE ($2); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
447 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
448 $$ = $1; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
449 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
450 ; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
451 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
452 fcn_list1 : function |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
453 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
454 octave::tree_statement *stmt = parser.make_statement ($1); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
455 $$ = new octave::tree_statement_list (stmt); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
456 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
457 | fcn_list1 opt_sep function |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
458 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
459 octave::tree_statement *stmt = parser.make_statement ($3); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
460 $$ = parser.append_statement_list ($1, $2, stmt, false); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
461 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
462 ; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
463 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
464 statement : expression |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
465 { $$ = parser.make_statement ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
466 | command |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
467 { $$ = parser.make_statement ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
468 | word_list_cmd |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
469 { $$ = parser.make_statement ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
470 ; |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
471 |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
472 // ================= |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
473 // Word-list command |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
474 // ================= |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
475 |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
476 // 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
|
477 // 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
|
478 // WHILE, etc. |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
479 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
480 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
|
481 { |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
482 $$ = 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
|
483 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
484 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
485 // 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
|
486 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
487 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
488 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
489 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
490 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
491 word_list : string |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
492 { $$ = new octave::tree_argument_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
493 | word_list string |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
494 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
495 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
496 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
497 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
498 ; |
1 | 499 |
2970 | 500 // =========== |
501 // Expressions | |
502 // =========== | |
503 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
504 identifier : NAME |
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 symbol_table::symbol_record *sr = $1->sym_rec (); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
507 $$ = new octave::tree_identifier (*sr, $1->line (), $1->column ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
508 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
509 ; |
2970 | 510 |
9476 | 511 superclass_identifier |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
512 : SUPERCLASSREF |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
513 { |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
514 std::string method_nm = $1->superclass_method_name (); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
515 std::string class_nm = $1->superclass_class_name (); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
516 |
18927
09eb8a2ddb02
eliminate some unused parameter warnings in parser functions
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
517 $$ = parser.make_superclass_ref (method_nm, class_nm); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
518 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
519 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
520 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
521 meta_identifier : METAQUERY |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
522 { |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
523 std::string class_nm = $1->text (); |
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
524 |
18927
09eb8a2ddb02
eliminate some unused parameter warnings in parser functions
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
525 $$ = parser.make_meta_class_query (class_nm); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
526 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
527 ; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
528 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
529 string : DQ_STRING |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
530 { $$ = parser.make_constant (DQ_STRING, $1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
531 | SQ_STRING |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
532 { $$ = parser.make_constant (SQ_STRING, $1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
533 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
534 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
535 constant : NUM |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
536 { $$ = parser.make_constant (NUM, $1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
537 | IMAG_NUM |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
538 { $$ = parser.make_constant (IMAG_NUM, $1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
539 | string |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
540 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
541 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
542 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
543 matrix : '[' matrix_rows ']' |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
544 { $$ = parser.finish_matrix ($2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
545 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
546 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
547 matrix_rows : cell_or_matrix_row |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
548 { $$ = $1 ? new octave::tree_matrix ($1) : 0; } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
549 | matrix_rows ';' cell_or_matrix_row |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
550 { |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
551 if ($1) |
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 if ($3) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
554 $1->append ($3); |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
555 |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
556 $$ = $1; |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
557 } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
558 else |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
559 $$ = $3 ? new octave::tree_matrix ($3) : 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
560 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
561 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
562 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
563 cell : '{' cell_rows '}' |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
564 { $$ = parser.finish_cell ($2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
565 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
566 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
567 cell_rows : cell_or_matrix_row |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
568 { $$ = $1 ? new octave::tree_cell ($1) : 0; } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
569 | cell_rows ';' cell_or_matrix_row |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
570 { |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
571 if ($1) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
572 { |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
573 if ($3) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
574 $1->append ($3); |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
575 |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
576 $$ = $1; |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
577 } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
578 else |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
579 $$ = $3 ? new octave::tree_cell ($3) : 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
580 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
581 ; |
3351 | 582 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
583 // 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
|
584 // 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
|
585 |
3351 | 586 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
|
587 : // empty |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
588 { $$ = 0; } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
589 | ',' |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
590 { $$ = 0; } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
591 | arg_list |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
592 { $$ = $1; } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
593 | arg_list ',' |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
594 { $$ = $1; } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
595 | ',' arg_list |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
596 { $$ = $2; } |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
597 | ',' arg_list ',' |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
598 { $$ = $2; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
599 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
600 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
601 fcn_handle : '@' FCN_HANDLE |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
602 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
603 $$ = parser.make_fcn_handle ($2); |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
604 lexer.looking_at_function_handle--; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
605 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
606 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
607 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
608 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
|
609 { |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
610 $$ = 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
|
611 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
|
612 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
613 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
614 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
615 primary_expr : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
616 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
617 | constant |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
618 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
619 | fcn_handle |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
620 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
621 | matrix |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
622 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
623 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
|
624 $$ = $1; |
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
625 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
626 | cell |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
627 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
628 | meta_identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
629 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
630 | superclass_identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
631 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
632 | '(' expression ')' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
633 { $$ = $2->mark_in_parens (); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
634 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
635 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
636 magic_colon : ':' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
637 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
638 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
639 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
640 octave_value tmp (octave_value::magic_colon_t); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
641 $$ = new octave::tree_constant (tmp); |
10315
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 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
644 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
645 magic_tilde : EXPR_NOT |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
646 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
647 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
648 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
649 $$ = new octave::tree_black_hole (); |
10315
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 arg_list : expression |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
654 { $$ = new octave::tree_argument_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
655 | magic_colon |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
656 { $$ = new octave::tree_argument_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
657 | magic_tilde |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
658 { $$ = new octave::tree_argument_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
659 | arg_list ',' magic_colon |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
660 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
661 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
662 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
663 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
664 | arg_list ',' magic_tilde |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
665 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
666 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
667 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
668 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
669 | arg_list ',' expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
670 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
671 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
672 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
673 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
674 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
675 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
676 indirect_ref_op : '.' |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
677 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
678 $$ = 0; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
679 lexer.looking_at_indirect_ref = true; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
680 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
681 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
682 |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
683 oper_expr : primary_expr |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
684 { $$ = $1; } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
685 | oper_expr PLUS_PLUS |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
686 { $$ = 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
|
687 | oper_expr MINUS_MINUS |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
688 { $$ = 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
|
689 | oper_expr '(' ')' |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
690 { |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
691 $$ = 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
|
692 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
693 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
694 // 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
|
695 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
696 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
697 } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
698 | 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
|
699 { |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
700 $$ = 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
|
701 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
702 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
703 // 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
|
704 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
705 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
706 } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
707 | oper_expr '{' '}' |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
708 { |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
709 $$ = 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
|
710 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
711 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
712 // 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
|
713 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
714 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
715 } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
716 | 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
|
717 { |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
718 $$ = 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
|
719 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
720 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
721 // 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
|
722 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
723 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
724 } |
16284
09881dab3aaf
* lex.ll, oct-parse.in.yy (HERMITIAN): Rename token from QUOTE.
John W. Eaton <jwe@octave.org>
parents:
16279
diff
changeset
|
725 | oper_expr HERMITIAN |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
726 { $$ = 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
|
727 | oper_expr TRANSPOSE |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
728 { $$ = 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
|
729 | 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
|
730 { $$ = 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
|
731 | 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
|
732 { $$ = 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
|
733 | 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
|
734 { $$ = 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
|
735 | 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
|
736 { $$ = 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
|
737 | 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
|
738 { $$ = 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
|
739 | '+' oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
740 { $$ = 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
|
741 | '-' oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
742 { $$ = 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
|
743 | oper_expr POW power_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
744 { $$ = 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
|
745 | oper_expr EPOW power_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
746 { $$ = 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
|
747 | oper_expr '+' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
748 { $$ = 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
|
749 | oper_expr '-' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
750 { $$ = 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
|
751 | oper_expr '*' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
752 { $$ = 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
|
753 | oper_expr '/' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
754 { $$ = 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
|
755 | oper_expr EPLUS oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
756 { $$ = 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
|
757 | oper_expr EMINUS oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
758 { $$ = 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
|
759 | oper_expr EMUL oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
760 { $$ = 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
|
761 | oper_expr EDIV oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
762 { $$ = 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
|
763 | oper_expr LEFTDIV oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
764 { $$ = 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
|
765 | oper_expr ELEFTDIV oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
766 { $$ = 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
|
767 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
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 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
|
770 { $$ = $1; } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
771 | 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
|
772 { $$ = 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
|
773 | 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
|
774 { $$ = 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
|
775 | power_expr '(' ')' |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
776 { |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
777 $$ = 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
|
778 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
779 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
780 // 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
|
781 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
782 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
783 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
784 | 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
|
785 { |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
786 $$ = 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
|
787 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
788 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
789 // 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
|
790 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
791 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
792 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
793 | power_expr '{' '}' |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
794 { |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
795 $$ = 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
|
796 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
797 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
798 // 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
|
799 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
800 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
801 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
802 | 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
|
803 { |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
804 $$ = 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
|
805 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
806 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
807 // 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
|
808 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
809 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
810 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
811 | 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
|
812 { $$ = 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
|
813 | 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
|
814 { $$ = 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
|
815 | 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
|
816 { $$ = 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
|
817 | 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
|
818 { $$ = 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
|
819 | 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
|
820 { $$ = 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
|
821 | '+' 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
|
822 { $$ = 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
|
823 | '-' 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
|
824 { $$ = 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
|
825 ; |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
826 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
827 colon_expr : colon_expr1 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
828 { $$ = parser.finish_colon_expression ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
829 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
830 |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
831 colon_expr1 : oper_expr |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
832 { $$ = new octave::tree_colon_expression ($1); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
833 | colon_expr1 ':' oper_expr |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
834 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
835 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
836 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
837 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
|
838 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
839 delete $1; |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
840 delete $3; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
841 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
842 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
843 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
844 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
845 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
846 simple_expr : colon_expr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
847 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
848 | 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
|
849 { $$ = 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
|
850 | 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
|
851 { $$ = 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
|
852 | 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
|
853 { $$ = 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
|
854 | 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
|
855 { $$ = 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
|
856 | 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
|
857 { $$ = 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
|
858 | 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
|
859 { $$ = 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
|
860 | 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
|
861 { $$ = 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
|
862 | 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
|
863 { $$ = 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
|
864 | 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
|
865 { $$ = 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
|
866 | 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
|
867 { $$ = 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
|
868 ; |
2970 | 869 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
870 assign_lhs : simple_expr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
871 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
872 $$ = parser.validate_matrix_for_assignment ($1); |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
873 |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
874 if ($$) |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
875 { 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
|
876 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
877 { |
16277
8cb65fd72164
eliminate obsolete concepts of "pending local" and "forced" variables
John W. Eaton <jwe@octave.org>
parents:
16273
diff
changeset
|
878 // 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
|
879 YYABORT; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
880 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
881 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
882 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
883 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
884 assign_expr : assign_lhs '=' expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
885 { $$ = parser.make_assign_op ('=', $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
886 | assign_lhs ADD_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
887 { $$ = 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
|
888 | assign_lhs SUB_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
889 { $$ = 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
|
890 | assign_lhs MUL_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
891 { $$ = 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
|
892 | assign_lhs DIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
893 { $$ = 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
|
894 | assign_lhs LEFTDIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
895 { $$ = 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
|
896 | assign_lhs POW_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
897 { $$ = 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
|
898 | assign_lhs EMUL_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
899 { $$ = 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
|
900 | assign_lhs EDIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
901 { $$ = 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
|
902 | assign_lhs ELEFTDIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
903 { $$ = 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
|
904 | assign_lhs EPOW_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
905 { $$ = 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
|
906 | assign_lhs AND_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
907 { $$ = 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
|
908 | assign_lhs OR_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
909 { $$ = 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
|
910 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
911 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
912 expression : simple_expr |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
913 { |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23553
diff
changeset
|
914 if ($1 && ($1->is_matrix () || $1->iscell ())) |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
915 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
916 if (parser.validate_array_list ($1)) |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
917 $$ = $1; |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
918 else |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
919 { |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
920 delete $1; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
921 YYABORT; |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
922 } |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
923 } |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
924 else |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
925 $$ = $1; |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
926 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
927 | assign_expr |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
928 { |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
929 if (! $1) |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
930 YYABORT; |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
931 |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
932 $$ = $1; |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
933 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
934 | anon_fcn_handle |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
935 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
936 ; |
2970 | 937 |
938 // ================================================ | |
939 // Commands, declarations, and function definitions | |
940 // ================================================ | |
941 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
942 command : declaration |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
943 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
944 | select_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
945 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
946 | loop_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
947 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
948 | jump_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
949 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
950 | except_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
951 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
952 | function |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
953 { $$ = $1; } |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
954 | file |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
955 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
956 ; |
2970 | 957 |
958 // ===================== | |
959 // Declaration statemnts | |
960 // ===================== | |
961 | |
16263
9acb86e6ac90
4/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16259
diff
changeset
|
962 declaration : GLOBAL decl1 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
963 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
964 $$ = 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
|
965 lexer.looking_at_decl_list = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
966 } |
16263
9acb86e6ac90
4/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16259
diff
changeset
|
967 | PERSISTENT decl1 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
968 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
969 $$ = 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
|
970 lexer.looking_at_decl_list = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
971 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
972 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
973 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
974 decl1 : decl2 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
975 { $$ = new octave::tree_decl_init_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
976 | decl1 decl2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
977 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
978 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
979 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
980 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
981 ; |
2970 | 982 |
7634
ae90e05ad299
fix parameter list initializer bug
John W. Eaton <jwe@octave.org>
parents:
7587
diff
changeset
|
983 decl_param_init : // empty |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
984 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
985 $$ = 0; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
986 lexer.looking_at_initializer_expression = true; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
987 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
988 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
989 decl2 : identifier |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
990 { $$ = new octave::tree_decl_elt ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
991 | identifier '=' decl_param_init expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
992 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
993 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
994 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
995 lexer.looking_at_initializer_expression = false; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
996 $$ = new octave::tree_decl_elt ($1, $4); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
997 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
998 ; |
2970 | 999 |
1000 // ==================== | |
1001 // Selection statements | |
1002 // ==================== | |
1003 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1004 select_command : if_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1005 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1006 | switch_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1007 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1008 ; |
2970 | 1009 |
1010 // ============ | |
1011 // If statement | |
1012 // ============ | |
1013 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1014 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
|
1015 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1016 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
|
1017 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1018 // 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
|
1019 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1020 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1021 } |
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 if_cmd_list : if_cmd_list1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1025 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1026 | if_cmd_list1 else_clause |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1027 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1028 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1029 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1030 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1031 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1032 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1033 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
|
1034 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1035 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1036 |
18127
d76f790b4eec
enable do_braindead_shortcircuit_evaluation by default and deprecate
John W. Eaton <jwe@octave.org>
parents:
17796
diff
changeset
|
1037 $1->mark_braindead_shortcircuit (); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1038 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1039 $$ = 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
|
1040 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1041 | if_cmd_list1 elseif_clause |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1042 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1043 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1044 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1045 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1046 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1047 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1048 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
|
1049 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1050 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1051 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1052 |
18127
d76f790b4eec
enable do_braindead_shortcircuit_evaluation by default and deprecate
John W. Eaton <jwe@octave.org>
parents:
17796
diff
changeset
|
1053 $4->mark_braindead_shortcircuit (); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1054 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1055 $$ = 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
|
1056 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1057 ; |
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 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
|
1060 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1061 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1062 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1063 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1064 $$ = new octave::tree_if_clause ($4, $2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1065 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1066 ; |
2970 | 1067 |
1068 // ================ | |
1069 // Switch statement | |
1070 // ================ | |
1071 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1072 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
|
1073 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1074 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1075 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1076 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
|
1077 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1078 // 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
|
1079 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1080 } |
10315
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 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1083 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1084 case_list : // empty |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1085 { $$ = new octave::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
|
1086 | default_case |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1087 { $$ = new octave::tree_switch_case_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1088 | case_list1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1089 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1090 | case_list1 default_case |
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 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1093 $$ = $1; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1094 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1095 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1096 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1097 case_list1 : switch_case |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1098 { $$ = new octave::tree_switch_case_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1099 | case_list1 switch_case |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1100 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1101 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1102 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1103 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1104 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1105 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1106 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
|
1107 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1108 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1109 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1110 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1111 $$ = 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
|
1112 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1113 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1114 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1115 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
|
1116 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1117 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1118 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1119 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1120 $$ = new octave::tree_switch_case ($4, $2); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1121 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1122 ; |
2970 | 1123 |
1124 // ======= | |
1125 // Looping | |
1126 // ======= | |
1127 | |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1128 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
|
1129 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1130 YYUSE ($5); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1131 |
18127
d76f790b4eec
enable do_braindead_shortcircuit_evaluation by default and deprecate
John W. Eaton <jwe@octave.org>
parents:
17796
diff
changeset
|
1132 $3->mark_braindead_shortcircuit (); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1133 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1134 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
|
1135 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1136 // 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
|
1137 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1138 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1139 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1140 | 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
|
1141 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1142 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1143 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1144 |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1145 $$ = 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
|
1146 } |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1147 | 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
|
1148 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1149 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1150 YYUSE ($7); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1151 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1152 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
|
1153 $8, $9, $2))) |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1154 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1155 // 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
|
1156 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1157 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1158 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1159 | 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
|
1160 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1161 YYUSE ($5); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1162 YYUSE ($8); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1163 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1164 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
|
1165 $9, $10, $2))) |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1166 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1167 // 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
|
1168 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1169 } |
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
|
1170 } |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1171 | 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
|
1172 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1173 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1174 YYUSE ($7); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1175 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1176 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
|
1177 0, $8, $9, $2))) |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1178 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1179 // 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
|
1180 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1181 } |
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
|
1182 } |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
1183 | 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
|
1184 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1185 YYUSE ($5); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1186 YYUSE ($10); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1187 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1188 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
|
1189 $8, $11, $12, $2))) |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1190 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1191 // 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
|
1192 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1193 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1194 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1195 ; |
2970 | 1196 |
1197 // ======= | |
1198 // Jumping | |
1199 // ======= | |
1200 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1201 jump_command : BREAK |
22785
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1202 { |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1203 if (! ($$ = parser.make_break_command ($1))) |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1204 YYABORT; |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1205 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1206 | CONTINUE |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1207 { $$ = parser.make_continue_command ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1208 | FUNC_RET |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1209 { $$ = parser.make_return_command ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1210 ; |
2970 | 1211 |
1212 // ========== | |
1213 // Exceptions | |
1214 // ========== | |
1215 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1216 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
|
1217 stash_comment opt_sep opt_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1218 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1219 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1220 YYUSE ($5); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1221 YYUSE ($7); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1222 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1223 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
|
1224 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1225 // 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
|
1226 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1227 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1228 } |
17283
e6c0ac8ce5b6
eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
1229 | 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
|
1230 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
|
1231 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1232 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1233 YYUSE ($5); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1234 YYUSE ($7); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1235 |
17283
e6c0ac8ce5b6
eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
1236 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
|
1237 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1238 // 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
|
1239 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1240 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1241 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1242 | TRY stash_comment opt_sep opt_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1243 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1244 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1245 |
17249
923ce8b42db2
improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents:
17170
diff
changeset
|
1246 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
|
1247 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1248 // 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
|
1249 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1250 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1251 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1252 ; |
2970 | 1253 |
1254 // =========================================== | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
1255 // Some 'subroutines' for function definitions |
2970 | 1256 // =========================================== |
1257 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1258 push_fcn_symtab : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1259 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1260 $$ = 0; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1261 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1262 parser.curr_fcn_depth++; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1263 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1264 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
|
1265 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
|
1266 |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16302
diff
changeset
|
1267 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
|
1268 |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1269 parser.function_scopes.push (lexer.symtab_context.curr_scope ()); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1270 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1271 if (! lexer.reading_script_file |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1272 && parser.curr_fcn_depth == 1 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1273 && ! parser.parsing_subfunctions) |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16302
diff
changeset
|
1274 parser.primary_fcn_scope |
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16302
diff
changeset
|
1275 = lexer.symtab_context.curr_scope (); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1276 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1277 if (lexer.reading_script_file |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1278 && 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
|
1279 { |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1280 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
|
1281 YYABORT; |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1282 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1283 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1284 ; |
2970 | 1285 |
1286 // =========================== | |
1287 // List of function parameters | |
1288 // =========================== | |
1289 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1290 param_list_beg : '(' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1291 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1292 $$ = 0; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1293 lexer.looking_at_parameter_list = true; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1294 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1295 if (lexer.looking_at_function_handle) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1296 { |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16302
diff
changeset
|
1297 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
|
1298 lexer.looking_at_function_handle--; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1299 lexer.looking_at_anon_fcn_args = true; |
10315
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 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1303 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1304 param_list_end : ')' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1305 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1306 $$ = 0; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1307 lexer.looking_at_parameter_list = false; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1308 lexer.looking_for_object_index = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1309 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1310 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1311 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1312 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
|
1313 { |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1314 if ($2) |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1315 lexer.mark_as_variables ($2->variable_names ()); |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1316 |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1317 $$ = $2; |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1318 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1319 | param_list_beg error |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1320 { |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1321 $$ = 0; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1322 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
|
1323 YYABORT; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1324 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1325 ; |
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 param_list1 : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1328 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1329 | param_list2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1330 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1331 $1->mark_as_formal_parameters (); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1332 if ($1->validate (octave::tree_parameter_list::in)) |
16360
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1333 { |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1334 lexer.mark_as_variables ($1->variable_names ()); |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1335 $$ = $1; |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1336 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1337 else |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1338 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1339 delete $1; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1340 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1341 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1342 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1343 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1344 |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1345 param_list2 : param_list_elt |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1346 { $$ = new octave::tree_parameter_list ($1); } |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1347 | param_list2 ',' param_list_elt |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1348 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1349 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1350 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1351 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1352 ; |
2970 | 1353 |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1354 param_list_elt : decl2 |
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1355 { $$ = $1; } |
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1356 | magic_tilde |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1357 { $$ = new octave::tree_decl_elt ($1); } |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1358 ; |
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1359 |
2970 | 1360 // =================================== |
1361 // List of function return value names | |
1362 // =================================== | |
1363 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1364 return_list : '[' ']' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1365 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1366 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
|
1367 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1368 $$ = new octave::tree_parameter_list (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1369 } |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1370 | identifier |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1371 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1372 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
|
1373 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1374 octave::tree_parameter_list *tmp = new octave::tree_parameter_list ($1); |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1375 |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1376 // 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
|
1377 // 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
|
1378 // to check for varargin or varargout. |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1379 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1380 if (tmp->validate (octave::tree_parameter_list::out)) |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1381 $$ = tmp; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1382 else |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1383 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1384 delete tmp; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1385 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1386 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1387 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1388 | '[' return_list1 ']' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1389 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1390 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
|
1391 |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1392 // Check for duplicate parameter names, varargin, |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1393 // or varargout. |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1394 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1395 if ($2->validate (octave::tree_parameter_list::out)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1396 $$ = $2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1397 else |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1398 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1399 delete $2; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1400 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1401 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1402 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1403 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1404 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1405 return_list1 : identifier |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1406 { $$ = new octave::tree_parameter_list (new octave::tree_decl_elt ($1)); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1407 | return_list1 ',' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1408 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1409 $1->append (new octave::tree_decl_elt ($3)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1410 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1411 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1412 ; |
2970 | 1413 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1414 // ======================= |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1415 // Script or function file |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1416 // ======================= |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1417 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1418 parsing_local_fcns |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1419 : // empty |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1420 { parser.parsing_local_functions = true; } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1421 ; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1422 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1423 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
|
1424 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1425 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1426 |
17618
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1427 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
|
1428 { |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1429 // 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
|
1430 // 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
|
1431 // 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
|
1432 // 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
|
1433 // 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
|
1434 |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1435 delete $3; |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1436 } |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1437 else |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1438 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1439 octave::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
|
1440 = 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
|
1441 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
|
1442 lexer.current_input_column); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1443 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1444 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
|
1445 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1446 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1447 $$ = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1448 } |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1449 | INPUT_FILE opt_nl classdef parsing_local_fcns opt_sep opt_fcn_list END_OF_INPUT |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1450 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1451 YYUSE ($2); |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1452 YYUSE ($5); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1453 YYUSE ($6); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1454 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1455 if (lexer.reading_classdef_file) |
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1456 parser.classdef_object = $3; |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1457 |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1458 $$ = 0; |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1459 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1460 ; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
1461 |
2970 | 1462 // =================== |
1463 // Function definition | |
1464 // =================== | |
1465 | |
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
|
1466 function_beg : push_fcn_symtab FCN |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1467 { |
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
|
1468 $$ = $2; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1469 if (lexer.reading_classdef_file |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1470 || lexer.parsing_classdef) |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1471 lexer.maybe_classdef_get_set_method = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1472 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1473 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1474 |
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
|
1475 function : function_beg stash_comment function1 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1476 { |
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
|
1477 $$ = 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
|
1478 $1->column ()); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1479 parser.recover_from_parsing_function (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1480 } |
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
|
1481 | function_beg stash_comment return_list '=' function1 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1482 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1483 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1484 |
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
|
1485 $$ = 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
|
1486 $1->column ()); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1487 parser.recover_from_parsing_function (); |
10315
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 ; |
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 fcn_name : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1492 { |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1493 std::string id = $1->name (); |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1494 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1495 if (! parser.function_scopes.name_current_scope (id)) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1496 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1497 parser.bison_error ("duplicate subfunction or nested function name", |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1498 $1->line (), $1->column ()); |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1499 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1500 delete $1; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1501 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1502 YYABORT; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1503 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1504 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1505 lexer.parsed_function_name.top () = true; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1506 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
|
1507 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1508 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1509 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1510 | GET '.' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1511 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1512 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1513 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1514 lexer.parsed_function_name.top () = true; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1515 lexer.maybe_classdef_get_set_method = false; |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1516 lexer.parsing_classdef_get_method = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1517 $$ = $3; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1518 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1519 | SET '.' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1520 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1521 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1522 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1523 lexer.parsed_function_name.top () = true; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1524 lexer.maybe_classdef_get_set_method = false; |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1525 lexer.parsing_classdef_set_method = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1526 $$ = $3; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1527 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1528 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1529 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1530 function1 : fcn_name function2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1531 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1532 std::string fname = $1->name (); |
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 delete $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1535 |
16698
13b3b92ea99c
Implement property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16683
diff
changeset
|
1536 if (lexer.parsing_classdef_get_method) |
13b3b92ea99c
Implement property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16683
diff
changeset
|
1537 fname.insert (0, "get."); |
13b3b92ea99c
Implement property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16683
diff
changeset
|
1538 else if (lexer.parsing_classdef_set_method) |
13b3b92ea99c
Implement property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16683
diff
changeset
|
1539 fname.insert (0, "set."); |
13b3b92ea99c
Implement property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16683
diff
changeset
|
1540 |
18395
2319bf776fa2
Fix parsing of classdef property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18341
diff
changeset
|
1541 lexer.parsing_classdef_get_method = false; |
2319bf776fa2
Fix parsing of classdef property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18341
diff
changeset
|
1542 lexer.parsing_classdef_set_method = false; |
2319bf776fa2
Fix parsing of classdef property accessors.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18341
diff
changeset
|
1543 |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1544 $$ = parser.frob_function (fname, $2); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1545 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1546 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1547 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1548 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
|
1549 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1550 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1551 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1552 $$ = parser.start_function ($1, $3, $4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1553 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1554 | 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
|
1555 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1556 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1557 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1558 $$ = parser.start_function (0, $2, $3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1559 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1560 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1561 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1562 function_end : END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1563 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1564 parser.endfunction_found = true; |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
1565 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
1566 if (parser.end_token_ok ($1, octave::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
|
1567 $$ = 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
|
1568 $1->line (), $1->column ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1569 else |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
1570 { |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
1571 parser.end_token_error ($1, octave::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
|
1572 YYABORT; |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
1573 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1574 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1575 | END_OF_INPUT |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1576 { |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
1577 // 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
|
1578 // if (lexer.reading_script_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1579 // { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1580 // 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
|
1581 // YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1582 // } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1583 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1584 if (parser.endfunction_found) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1585 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1586 parser.bison_error ("inconsistent function endings -- " |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1587 "if one function is explicitly ended, " |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1588 "so must all the others"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1589 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1590 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1591 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1592 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
|
1593 || lexer.input_from_eval_string ())) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1594 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1595 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
|
1596 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1597 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1598 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1599 if (lexer.reading_classdef_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1600 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1601 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
|
1602 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1603 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1604 |
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
|
1605 $$ = 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
|
1606 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
|
1607 lexer.current_input_column); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1608 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1609 ; |
2970 | 1610 |
9476 | 1611 // ======== |
1612 // Classdef | |
1613 // ======== | |
1614 | |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1615 classdef_beg : CLASSDEF |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1616 { |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1617 if (! lexer.reading_classdef_file) |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1618 { |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1619 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
|
1620 YYABORT; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1621 } |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1622 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1623 lexer.parsing_classdef = true; |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1624 $$ = $1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1625 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1626 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1627 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1628 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
|
1629 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1630 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1631 YYUSE ($8); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1632 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1633 lexer.parsing_classdef = false; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1634 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1635 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
|
1636 { |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1637 // 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
|
1638 YYABORT; |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1639 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1640 } |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1641 | 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
|
1642 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1643 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1644 |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1645 lexer.parsing_classdef = false; |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1646 |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1647 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
|
1648 { |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1649 // 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
|
1650 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1651 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1652 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1653 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1654 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1655 opt_attr_list : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1656 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1657 | '(' attr_list ')' |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1658 { $$ = $2; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1659 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1660 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1661 attr_list : attr |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1662 { $$ = new octave::tree_classdef_attribute_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1663 | attr_list ',' attr |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1664 { |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1665 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1666 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1667 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1668 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1669 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1670 attr : identifier |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1671 { $$ = new octave::tree_classdef_attribute ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1672 | identifier '=' decl_param_init expression |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1673 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1674 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1675 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1676 lexer.looking_at_initializer_expression = false; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1677 $$ = new octave::tree_classdef_attribute ($1, $4); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1678 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1679 | EXPR_NOT identifier |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1680 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1681 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1682 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1683 $$ = new octave::tree_classdef_attribute ($2, false); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1684 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1685 ; |
9476 | 1686 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1687 opt_superclass_list |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1688 : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1689 { $$ = 0; } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1690 | superclass_list |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1691 { $$ = $1; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1692 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1693 |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1694 superclass_list : EXPR_LT |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1695 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1696 YYUSE ($1); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1697 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1698 lexer.enable_fq_identifier (); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1699 } |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1700 superclass |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1701 { $$ = new octave::tree_classdef_superclass_list ($3); } |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1702 | superclass_list EXPR_AND |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1703 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1704 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1705 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1706 lexer.enable_fq_identifier (); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1707 } |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1708 superclass |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1709 { |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1710 $1->append ($4); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1711 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1712 } |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1713 ; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1714 |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1715 superclass : FQ_IDENT |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1716 { $$ = new octave::tree_classdef_superclass ($1->text ()); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1717 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1718 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1719 class_body : properties_block |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1720 { $$ = new octave::tree_classdef_body ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1721 | methods_block |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1722 { $$ = new octave::tree_classdef_body ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1723 | events_block |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1724 { $$ = new octave::tree_classdef_body ($1); } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1725 | enum_block |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1726 { $$ = new octave::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
|
1727 | class_body opt_sep properties_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1728 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1729 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1730 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1731 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1732 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1733 } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1734 | class_body opt_sep methods_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1735 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1736 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1737 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1738 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1739 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1740 } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1741 | class_body opt_sep events_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1742 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1743 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1744 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1745 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1746 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1747 } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1748 | class_body opt_sep enum_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1749 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1750 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1751 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1752 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1753 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1754 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1755 ; |
9476 | 1756 |
1757 properties_block | |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1758 : 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
|
1759 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1760 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1761 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1762 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1763 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
|
1764 ($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
|
1765 { |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1766 // 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
|
1767 YYABORT; |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1768 } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1769 } |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1770 | 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
|
1771 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1772 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1773 |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1774 if (! ($$ = parser.make_classdef_properties_block |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1775 ($1, $3, 0, $5, $2))) |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1776 { |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1777 // 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
|
1778 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1779 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1780 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1781 ; |
9476 | 1782 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1783 property_list |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1784 : class_property |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1785 { $$ = new octave::tree_classdef_property_list ($1); } |
22879
194481349d22
don't require semicolon between property list elements (bug #49819)
John W. Eaton <jwe@octave.org>
parents:
22712
diff
changeset
|
1786 | property_list sep class_property |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1787 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1788 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1789 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1790 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1791 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1792 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1793 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1794 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1795 class_property : identifier |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1796 { $$ = new octave::tree_classdef_property ($1); } |
22879
194481349d22
don't require semicolon between property list elements (bug #49819)
John W. Eaton <jwe@octave.org>
parents:
22712
diff
changeset
|
1797 | identifier '=' decl_param_init expression |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1798 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1799 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1800 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1801 lexer.looking_at_initializer_expression = false; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1802 $$ = new octave::tree_classdef_property ($1, $4); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1803 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1804 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1805 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1806 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
|
1807 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1808 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1809 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1810 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1811 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
|
1812 ($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
|
1813 { |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1814 // 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
|
1815 YYABORT; |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1816 } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1817 } |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1818 | 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
|
1819 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1820 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1821 |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1822 if (! ($$ = parser.make_classdef_methods_block |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1823 ($1, $3, 0, $5, $2))) |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1824 { |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1825 // 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
|
1826 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1827 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1828 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1829 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1830 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1831 |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1832 method_decl1 : identifier |
18308
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
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 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
|
1835 YYABORT; |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1836 } |
18308
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
1837 | identifier param_list |
18341
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1838 { |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1839 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
|
1840 YYABORT; |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1841 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1842 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1843 |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1844 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
|
1845 { $$ = 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
|
1846 | stash_comment return_list '=' |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1847 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1848 YYUSE ($3); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1849 |
18341
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1850 lexer.defining_func++; |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1851 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
|
1852 } |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1853 method_decl1 |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1854 { |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1855 lexer.defining_func--; |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1856 lexer.parsed_function_name.pop (); |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
1857 $$ = 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
|
1858 } |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1859 ; |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1860 |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1861 method : method_decl |
18308
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
1862 { $$ = $1; } |
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
1863 | function |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1864 { $$ = $1; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1865 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1866 |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1867 methods_list : method |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1868 { |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1869 octave_value fcn; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1870 if ($1) |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1871 fcn = $1->function (); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1872 delete $1; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1873 $$ = new octave::tree_classdef_methods_list (fcn); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1874 } |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
1875 | methods_list opt_sep method |
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 octave_value fcn; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1880 if ($3) |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1881 fcn = $3->function (); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1882 delete $3; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1883 |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1884 $1->append (fcn); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1885 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1886 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1887 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1888 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1889 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
|
1890 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1891 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1892 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1893 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1894 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
|
1895 ($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
|
1896 { |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1897 // 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
|
1898 YYABORT; |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1899 } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1900 } |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1901 | 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
|
1902 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1903 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1904 |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1905 if (! ($$ = parser.make_classdef_events_block |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1906 ($1, $3, 0, $5, $2))) |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1907 { |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1908 // 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
|
1909 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1910 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1911 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1912 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1913 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1914 events_list : class_event |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1915 { $$ = new octave::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
|
1916 | events_list opt_sep class_event |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1917 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1918 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1919 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1920 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1921 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1922 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1923 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1924 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1925 class_event : identifier |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1926 { $$ = new octave::tree_classdef_event ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1927 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1928 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1929 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
|
1930 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1931 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1932 YYUSE ($6); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1933 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1934 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
|
1935 ($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
|
1936 { |
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1937 // 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
|
1938 YYABORT; |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1939 } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1940 } |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1941 | 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
|
1942 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1943 YYUSE ($4); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1944 |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1945 if (! ($$ = parser.make_classdef_enum_block |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1946 ($1, $3, 0, $5, $2))) |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1947 { |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1948 // 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
|
1949 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1950 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1951 } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1952 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1953 |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1954 enum_list : class_enum |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1955 { $$ = new octave::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
|
1956 | enum_list opt_sep class_enum |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1957 { |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1958 YYUSE ($2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1959 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1960 $1->append ($3); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1961 $$ = $1; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1962 } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1963 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1964 |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1965 class_enum : identifier '(' expression ')' |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1966 { $$ = new octave::tree_classdef_enum ($1, $3); } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1967 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1968 |
2970 | 1969 // ============= |
1970 // Miscellaneous | |
1971 // ============= | |
1972 | |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1973 stmt_begin : // empty |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1974 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1975 $$ = 0; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1976 lexer.at_beginning_of_statement = true; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1977 } |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1978 ; |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1979 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1980 stash_comment : // empty |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
1981 { $$ = lexer.get_comment (); } |
10315
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 parse_error : LEXICAL_ERROR |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1985 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1986 $$ = 0; |
21064
a9f2c2d72892
handle lexical errors as parser errors (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21063
diff
changeset
|
1987 std::string msg = $1->text (); |
a9f2c2d72892
handle lexical errors as parser errors (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21063
diff
changeset
|
1988 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
|
1989 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1990 | error |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1991 { $$ = 0; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1992 ; |
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 sep_no_nl : ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1995 { $$ = ','; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1996 | ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1997 { $$ = ';'; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1998 | sep_no_nl ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1999 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2000 | sep_no_nl ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2001 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2002 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2003 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2004 opt_sep_no_nl : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2005 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2006 | sep_no_nl |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2007 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2008 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2009 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2010 opt_nl : // empty |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2011 { $$ = 0; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2012 | nl |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2013 { $$ = $1; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2014 ; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2015 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2016 nl : '\n' |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2017 { $$ = '\n'; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2018 | nl '\n' |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2019 { $$ = $1; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2020 ; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2021 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2022 sep : ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2023 { $$ = ','; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2024 | ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2025 { $$ = ';'; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2026 | '\n' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2027 { $$ = '\n'; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2028 | sep ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2029 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2030 | sep ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2031 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2032 | sep '\n' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2033 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2034 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2035 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2036 opt_sep : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2037 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2038 | sep |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2039 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2040 ; |
2525 | 2041 |
1 | 2042 %% |
2043 | |
21023
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2044 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2045 // 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
|
2046 #pragma GCC diagnostic pop |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2047 #endif |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2048 |
666 | 2049 // Generic error messages. |
2050 | |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
2051 #undef lexer |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
2052 |
1 | 2053 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
|
2054 yyerror (octave::base_parser& parser, const char *s) |
1 | 2055 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
2056 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
|
2057 } |
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
|
2058 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2059 namespace octave |
16157
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
2060 { |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2061 size_t |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2062 base_parser::parent_scope_info::size (void) const |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2063 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2064 return info.size (); |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2065 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2066 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2067 void |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2068 base_parser::parent_scope_info::push (const value_type& elt) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2069 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2070 info.push_back (elt); |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2071 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2072 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2073 void |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2074 base_parser::parent_scope_info::push (symbol_table::scope_id id) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2075 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2076 push (value_type (id, "")); |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2077 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2078 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2079 void |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2080 base_parser::parent_scope_info::pop (void) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2081 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2082 info.pop_back (); |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2083 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2084 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2085 bool |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2086 base_parser::parent_scope_info::name_ok (const std::string& name) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2087 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2088 // Name can't be the same as any parent function or any other |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2089 // function we've already seen. We could maintain a complex |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2090 // tree structure of names, or we can just store the set of |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2091 // full names of all the functions, which must be unique. |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2092 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2093 std::string full_name; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2094 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2095 for (size_t i = 0; i < size()-1; i++) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2096 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2097 const value_type& elt = info[i]; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2098 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2099 if (name == elt.second) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2100 return false; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2101 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2102 full_name += elt.second + ">"; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2103 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2104 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2105 full_name += name; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2106 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2107 if (all_names.find (full_name) != all_names.end ()) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2108 return false; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2109 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2110 all_names.insert (full_name); |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2111 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2112 return true; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2113 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2114 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2115 bool |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2116 base_parser::parent_scope_info::name_current_scope (const std::string& name) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2117 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2118 if (! name_ok (name)) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2119 return false; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2120 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2121 if (size () > 0) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2122 info.back().second = name; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2123 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2124 return true; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2125 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2126 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2127 symbol_table::scope_id |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2128 base_parser::parent_scope_info::parent_scope (void) const |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2129 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2130 return size () > 1 ? info[size()-2].first : 0; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2131 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2132 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2133 std::string |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2134 base_parser::parent_scope_info::parent_name (void) const |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2135 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2136 return info[size()-2].second; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2137 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2138 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2139 void base_parser::parent_scope_info::clear (void) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2140 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2141 info.clear (); |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2142 all_names.clear (); |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2143 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
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 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
|
2146 : endfunction_found (false), autoloading (false), |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
2147 fcn_file_from_relative_lookup (false), |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
2148 parsing_subfunctions (false), parsing_local_functions (false), |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2149 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
|
2150 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
|
2151 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
|
2152 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
|
2153 { } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2154 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2155 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
|
2156 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2157 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
|
2158 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2159 delete &lexer; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2160 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2161 // 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
|
2162 // 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
|
2163 // 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
|
2164 // 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
|
2165 // 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
|
2166 // 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
|
2167 // 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
|
2168 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2169 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
|
2170 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2171 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2172 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2173 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
|
2174 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2175 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
|
2176 autoloading = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2177 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
|
2178 parsing_subfunctions = false; |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
2179 parsing_local_functions = false; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2180 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
|
2181 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
|
2182 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
|
2183 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
|
2184 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
|
2185 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
|
2186 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
|
2187 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
|
2188 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2189 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
|
2190 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
|
2191 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2192 lexer.reset (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2193 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2194 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
|
2195 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
|
2196 } |
16138
284e2ca86ef7
execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16136
diff
changeset
|
2197 } |
284e2ca86ef7
execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16136
diff
changeset
|
2198 |
666 | 2199 // Error mesages for mismatched end tokens. |
2200 | |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2201 static std::string |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2202 end_token_as_string (octave::token::end_tok_type ettype) |
496 | 2203 { |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2204 std::string retval = "<unknown>"; |
496 | 2205 |
2206 switch (ettype) | |
2207 { | |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2208 case octave::token::simple_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2209 retval = "end"; |
496 | 2210 break; |
777 | 2211 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2212 case octave::token::classdef_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2213 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
|
2214 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2215 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2216 case octave::token::enumeration_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2217 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
|
2218 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2219 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2220 case octave::token::events_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2221 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
|
2222 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2223 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2224 case octave::token::for_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2225 retval = "endfor"; |
496 | 2226 break; |
777 | 2227 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2228 case octave::token::function_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2229 retval = "endfunction"; |
496 | 2230 break; |
777 | 2231 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2232 case octave::token::if_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2233 retval = "endif"; |
496 | 2234 break; |
777 | 2235 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2236 case octave::token::methods_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2237 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
|
2238 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2239 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2240 case octave::token::parfor_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2241 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
|
2242 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2243 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2244 case octave::token::properties_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2245 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
|
2246 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2247 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2248 case octave::token::switch_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2249 retval = "endswitch"; |
3233 | 2250 break; |
2251 | |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2252 case octave::token::try_catch_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2253 retval = "end_try_catch"; |
5400 | 2254 break; |
2255 | |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2256 case octave::token::unwind_protect_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2257 retval = "end_unwind_protect"; |
1371 | 2258 break; |
2259 | |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
2260 case octave::token::while_end: |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2261 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
|
2262 break; |
8aa424ffc076
handle all end token types when reporting parse errors (bug #44824)
John W. Eaton <jwe@octave.org>
parents:
19849
diff
changeset
|
2263 |
496 | 2264 default: |
2265 panic_impossible (); | |
2266 break; | |
2267 } | |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2268 |
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
2269 return retval; |
496 | 2270 } |
2271 | |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2272 namespace octave |
578 | 2273 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2274 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2275 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
|
2276 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2277 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
|
2278 + "' 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
|
2279 + 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
|
2280 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2281 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
|
2282 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2283 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2284 // 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
|
2285 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2286 bool |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2287 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
|
2288 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2289 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
|
2290 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2291 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
|
2292 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2293 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2294 // 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
|
2295 // 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
|
2296 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2297 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2298 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
|
2299 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2300 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
|
2301 && 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
|
2302 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2303 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
|
2304 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
|
2305 ("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
|
2306 "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
|
2307 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2308 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
|
2309 ("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
|
2310 "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
|
2311 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
|
2312 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2313 } |
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 // 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
|
2316 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2317 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2318 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
|
2319 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2320 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
|
2321 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2322 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
|
2323 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
|
2324 "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
|
2325 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2326 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
|
2327 ("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
|
2328 "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
|
2329 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
|
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2333 // 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
|
2334 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2335 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2336 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
|
2337 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2338 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
|
2339 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2340 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
|
2341 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2342 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
|
2343 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
|
2344 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2345 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
|
2346 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
|
2347 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2348 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
|
2349 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
|
2350 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
|
2351 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2352 if (base) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2353 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2354 if (limit) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2355 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2356 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
|
2357 && (! 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
|
2358 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2359 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2360 { |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
2361 octave::tree_evaluator& tw |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
2362 = __get_evaluator__ ("finish_colon_expression"); |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
2363 |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
2364 octave_value tmp = tw.evaluate (e); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2365 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2366 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
|
2367 = 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
|
2368 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2369 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
|
2370 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2371 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
|
2372 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2373 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
|
2374 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2375 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
|
2376 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2377 delete e; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2378 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2379 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
|
2380 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
2381 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
|
2382 { |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
2383 octave::interpreter::recover_from_exception (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2384 } |
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 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2387 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2388 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2389 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
|
2390 delete e; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2391 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2392 retval = base; |
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 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2395 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2396 return retval; |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2399 // 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
|
2400 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2401 tree_constant * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2402 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
|
2403 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2404 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
|
2405 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
|
2406 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2407 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
|
2408 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2409 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2410 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2411 case NUM: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2412 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2413 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
|
2414 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
|
2415 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
|
2416 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2417 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2418 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2419 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
|
2420 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2421 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
|
2422 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
|
2423 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
|
2424 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2425 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2426 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2427 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
|
2428 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
|
2429 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2430 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
|
2431 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2432 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
|
2433 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
|
2434 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2435 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
|
2436 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2437 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
|
2438 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
|
2439 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2440 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
|
2441 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2442 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2443 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
|
2444 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2445 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
|
2446 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
|
2447 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2448 // 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
|
2449 // 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
|
2450 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
|
2451 } |
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 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2455 panic_impossible (); |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2459 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2460 } |
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 // 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
|
2463 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2464 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
|
2465 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
|
2466 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2467 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
|
2468 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
|
2469 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2470 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
|
2471 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2472 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2473 } |
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 // 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
|
2476 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2477 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
|
2478 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
|
2479 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
|
2480 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2481 // 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
|
2482 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
|
2483 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
|
2484 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2485 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
|
2486 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2487 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
|
2488 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2489 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
|
2490 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2491 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
|
2492 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2493 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
|
2494 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2495 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
|
2496 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2497 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
|
2498 = 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
|
2499 // 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
|
2500 // 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
|
2501 //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
|
2502 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2503 return retval; |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2506 // 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
|
2507 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2508 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2509 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
|
2510 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
|
2511 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2512 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
|
2513 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2514 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2515 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2516 case POW: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2517 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
|
2518 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2519 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2520 case EPOW: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2521 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
|
2522 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2523 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2524 case '+': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2525 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
|
2526 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2527 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2528 case '-': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2529 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
|
2530 break; |
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 case '*': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2533 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
|
2534 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2535 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2536 case '/': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2537 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
|
2538 break; |
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 case EMUL: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2541 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
|
2542 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2543 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2544 case EDIV: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2545 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
|
2546 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2547 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2548 case LEFTDIV: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2549 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
|
2550 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2551 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2552 case ELEFTDIV: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2553 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
|
2554 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2555 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2556 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
|
2557 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
|
2558 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2559 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2560 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
|
2561 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
|
2562 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2563 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2564 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
|
2565 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
|
2566 break; |
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 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
|
2569 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
|
2570 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2571 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2572 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
|
2573 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
|
2574 break; |
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 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
|
2577 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
|
2578 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2579 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2580 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
|
2581 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
|
2582 break; |
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 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
|
2585 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
|
2586 break; |
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 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2589 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2590 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2591 } |
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 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
|
2594 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
|
2595 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2596 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
|
2597 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2598 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2599 // 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
|
2600 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2601 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2602 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
|
2603 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
|
2604 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2605 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
|
2606 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2607 switch (op) |
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 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
|
2610 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
|
2611 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2612 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2613 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
|
2614 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
|
2615 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2616 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2617 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2618 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2619 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2620 } |
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 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
|
2623 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
|
2624 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2625 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
|
2626 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2627 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2628 // 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
|
2629 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2630 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2631 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
|
2632 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2633 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
|
2634 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2635 switch (op) |
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 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
|
2638 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
|
2639 break; |
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 case '+': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2642 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
|
2643 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2644 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2645 case '-': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2646 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
|
2647 break; |
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 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
|
2650 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
|
2651 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2652 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2653 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
|
2654 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
|
2655 break; |
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 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2658 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2659 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2660 } |
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 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
|
2663 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
|
2664 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2665 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
|
2666 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2667 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2668 // 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
|
2669 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2670 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2671 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
|
2672 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2673 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
|
2674 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2675 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2676 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2677 case HERMITIAN: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2678 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
|
2679 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2680 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2681 case TRANSPOSE: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2682 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
|
2683 break; |
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 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
|
2686 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
|
2687 break; |
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 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
|
2690 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
|
2691 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2692 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2693 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2694 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2695 break; |
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 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
|
2699 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
|
2700 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2701 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
|
2702 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2703 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2704 // 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
|
2705 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2706 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2707 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
|
2708 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
|
2709 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
|
2710 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
|
2711 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
|
2712 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
|
2713 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2714 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
|
2715 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2716 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
|
2717 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2718 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
|
2719 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2720 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
|
2721 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
|
2722 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2723 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
|
2724 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
|
2725 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2726 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2727 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2728 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2729 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
|
2730 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2731 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
|
2732 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2733 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2734 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2735 } |
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 // 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
|
2738 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2739 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2740 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
|
2741 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
|
2742 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
|
2743 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
|
2744 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
|
2745 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
|
2746 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
|
2747 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2748 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
|
2749 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2750 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
|
2751 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2752 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
|
2753 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2754 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
|
2755 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
|
2756 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2757 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
|
2758 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2759 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
|
2760 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2761 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
|
2762 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2763 if (stmt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2764 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2765 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
|
2766 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2767 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
|
2768 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2769 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
|
2770 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2771 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
|
2772 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2773 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
|
2774 delete stmt; |
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 } |
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 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
|
2780 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
|
2781 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2782 else |
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 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2785 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
|
2786 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2787 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
|
2788 } |
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 retval; |
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 while 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_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
|
2797 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
|
2798 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
|
2799 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
|
2800 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
|
2801 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2802 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
|
2803 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2804 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
|
2805 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2806 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
|
2807 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2808 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
|
2809 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2810 lexer.looping--; |
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 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
|
2813 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
|
2814 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2815 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
|
2816 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2817 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2818 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2819 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2820 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2821 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2822 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
|
2823 } |
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 retval; |
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 // 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
|
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_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::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
|
2832 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
|
2833 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
|
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 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
|
2837 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2838 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
|
2839 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2840 lexer.looping--; |
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 = 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
|
2843 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
|
2844 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2845 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
|
2846 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2847 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2848 // 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
|
2849 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2850 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2851 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
|
2852 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
|
2853 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
|
2854 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
|
2855 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
|
2856 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
|
2857 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
|
2858 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2859 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
|
2860 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2861 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
|
2862 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2863 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
|
2864 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2865 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
|
2866 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2867 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
|
2868 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2869 lexer.looping--; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2870 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2871 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
|
2872 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
|
2873 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2874 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
|
2875 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2876 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
|
2877 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2878 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
|
2879 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
|
2880 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2881 delete lhs; |
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 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2884 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2885 if (parfor) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2886 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2887 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2888 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2889 delete maxproc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2890 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2891 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2892 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
|
2893 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2894 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2895 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
|
2896 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
|
2897 } |
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 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2900 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2901 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2902 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2903 delete maxproc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2904 delete body; |
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 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
|
2907 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2908 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2909 return retval; |
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 // 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
|
2913 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2914 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2915 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
|
2916 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2917 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
|
2918 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
|
2919 |
22785
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2920 if (! lexer.looping) |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2921 { |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2922 bison_error ("break must appear in a loop in the same file as loop command"); |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2923 return 0; |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2924 } |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2925 else |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2926 return new tree_break_command (l, c); |
22196
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2929 // 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
|
2930 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2931 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2932 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
|
2933 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2934 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
|
2935 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
|
2936 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2937 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
|
2938 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2939 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2940 // 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
|
2941 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2942 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2943 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
|
2944 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2945 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
|
2946 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
|
2947 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2948 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
|
2949 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2950 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2951 // 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
|
2952 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2953 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
|
2954 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
|
2955 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
|
2956 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2957 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
|
2958 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2959 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
|
2960 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2961 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
|
2962 } |
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 // 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
|
2965 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2966 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
|
2967 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
|
2968 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
|
2969 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
|
2970 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
|
2971 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2972 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
|
2973 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2974 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
|
2975 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2976 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
|
2977 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2978 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
|
2979 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
|
2980 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2981 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
|
2982 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2983 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
|
2984 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2985 if (elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2986 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2987 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
|
2988 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
|
2989 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2990 } |
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 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
|
2993 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2994 else |
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 delete list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2997 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2998 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
|
2999 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3000 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3001 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3002 } |
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 // 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
|
3005 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3006 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
|
3007 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
|
3008 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
|
3009 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
|
3010 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
|
3011 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3012 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
|
3013 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3014 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
|
3015 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
|
3016 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3017 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
|
3018 } |
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 // 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
|
3021 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3022 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
|
3023 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
|
3024 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
|
3025 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
|
3026 token *end_tok, |
04a7953496a7
create base class for parser; use reference for curr_lexer
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
3027 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
|
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_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
|
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 (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
|
3032 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3033 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
|
3034 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3035 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
|
3036 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
|
3037 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3038 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
|
3039 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3040 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
|
3041 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3042 if (elt) |
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 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
|
3045 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
|
3046 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3047 } |
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 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
|
3050 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3051 else |
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 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3054 delete list; |
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 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
|
3057 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3058 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3059 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3060 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3061 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3062 // 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
|
3063 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3064 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
|
3065 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
|
3066 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
|
3067 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
|
3068 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
|
3069 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3070 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
|
3071 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3072 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
|
3073 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
|
3074 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3075 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
|
3076 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3077 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3078 // 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
|
3079 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3080 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3081 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
|
3082 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
|
3083 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3084 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
|
3085 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3086 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3087 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3088 case '=': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3089 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
|
3090 break; |
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 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
|
3093 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
|
3094 break; |
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 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
|
3097 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
|
3098 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3099 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3100 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
|
3101 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
|
3102 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3103 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3104 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
|
3105 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
|
3106 break; |
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 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
|
3109 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
|
3110 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3111 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3112 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
|
3113 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
|
3114 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3115 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3116 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
|
3117 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
|
3118 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3119 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3120 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
|
3121 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
|
3122 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3123 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3124 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
|
3125 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
|
3126 break; |
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 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
|
3129 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
|
3130 break; |
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 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
|
3133 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
|
3134 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3135 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3136 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
|
3137 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
|
3138 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3139 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3140 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3141 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3142 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3143 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3144 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3145 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
|
3146 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
|
3147 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3148 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
|
3149 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3150 // 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
|
3151 // '=', not '+=', etc. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3152 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3153 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3154 delete rhs; |
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 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
|
3157 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3158 return 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3159 } |
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 (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
|
3162 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3163 // 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
|
3164 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3165 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
|
3166 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3167 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
|
3168 && 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
|
3169 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3170 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
|
3171 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3172 delete tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3173 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3174 delete rhs; |
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 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
|
3177 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3178 return 0; |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3181 delete lhs; |
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 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
|
3184 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3185 else |
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 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
|
3188 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22785
diff
changeset
|
3189 for (const auto& kw : names) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3190 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3191 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
|
3192 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3193 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3194 delete rhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3195 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3196 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
|
3197 l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3198 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3199 return 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3200 } |
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 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
|
3204 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3205 } |
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 // 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
|
3208 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3209 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3210 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
|
3211 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
|
3212 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3213 if (! cmds) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3214 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
|
3215 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3216 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
|
3217 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3218 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
|
3219 = 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
|
3220 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
|
3221 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
|
3222 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3223 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
|
3224 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3225 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
|
3226 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3227 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
|
3228 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3229 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
|
3230 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3231 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3232 // 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
|
3233 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3234 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
|
3235 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
|
3236 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
|
3237 tree_statement *end_fcn_stmt) |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3238 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3239 // 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
|
3240 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3241 if (! body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3242 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
|
3243 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3244 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
|
3245 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3246 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
|
3247 = 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
|
3248 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
|
3249 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3250 if (fcn) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3251 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3252 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
|
3253 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3254 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
|
3255 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
|
3256 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
|
3257 } |
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 return fcn; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3260 } |
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 tree_statement * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3263 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
|
3264 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3265 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
|
3266 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3267 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3268 // 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
|
3269 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3270 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
|
3271 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
|
3272 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
|
3273 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3274 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
|
3275 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3276 // 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
|
3277 // 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
|
3278 // 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
|
3279 // name). |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3280 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
|
3281 && 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
|
3282 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3283 // 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
|
3284 // 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
|
3285 // 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
|
3286 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3287 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
|
3288 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3289 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
|
3290 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3291 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
|
3292 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
|
3293 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3294 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
|
3295 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3296 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
|
3297 ("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
|
3298 "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
|
3299 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
|
3300 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3301 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
|
3302 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3303 } |
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 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
|
3306 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3307 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
|
3308 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3309 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
|
3310 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
|
3311 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
|
3312 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3313 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
|
3314 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
|
3315 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3316 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
|
3317 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3318 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
|
3319 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3320 if (curr_fcn_depth > 1) |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
3321 fcn->stash_parent_fcn_scope (function_scopes.parent_scope ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3322 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3323 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
|
3324 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3325 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3326 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
|
3327 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3328 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
|
3329 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
|
3330 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3331 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
|
3332 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3333 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
|
3334 } |
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 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
|
3337 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3338 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
|
3339 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3340 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
|
3341 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
|
3342 "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
|
3343 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3344 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
|
3345 && ! 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
|
3346 && 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
|
3347 && 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
|
3348 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3349 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
|
3350 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
|
3351 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3352 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3353 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
|
3354 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3355 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
|
3356 && ! parsing_subfunctions) |
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 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
|
3359 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3360 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
|
3361 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3362 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3363 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
|
3364 && ! parsing_subfunctions) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3365 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
|
3366 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3367 return fcn; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3368 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3369 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3370 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
|
3371 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
|
3372 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
|
3373 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
|
3374 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
|
3375 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3376 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
|
3377 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3378 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
|
3379 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
|
3380 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3381 if (fcn) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3382 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3383 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
|
3384 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
|
3385 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3386 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
|
3387 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
|
3388 tmp += ": " + file; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3389 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3390 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
|
3391 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3392 if (lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3393 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
|
3394 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3395 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
|
3396 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3397 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
|
3398 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3399 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
|
3400 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3401 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
|
3402 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3403 symbol_table::scope_id pscope |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
3404 = function_scopes.parent_scope (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3405 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3406 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
|
3407 pscope); |
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 else |
22974
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22880
diff
changeset
|
3410 { |
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22880
diff
changeset
|
3411 fcn->mark_as_subfunction (); |
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22880
diff
changeset
|
3412 subfunction_names.push_back (nm); |
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22880
diff
changeset
|
3413 |
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22880
diff
changeset
|
3414 symbol_table::install_subfunction (nm, octave_value (fcn), |
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22880
diff
changeset
|
3415 primary_fcn_scope); |
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22880
diff
changeset
|
3416 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3417 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3418 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
3419 if (fcn) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
3420 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
3421 if (parsing_local_functions ) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
3422 symbol_table::install_local_function (nm, octave_value (fcn), |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
3423 file); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
3424 else if (curr_fcn_depth == 1) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
3425 symbol_table::update_nest (fcn->scope ()); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
3426 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3427 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3428 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
|
3429 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3430 // 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
|
3431 // 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
|
3432 // 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
|
3433 // 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
|
3434 // 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
|
3435 // 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
|
3436 // 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
|
3437 // 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
|
3438 // 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
|
3439 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3440 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
|
3441 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3442 } |
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 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3445 } |
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 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3448 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
|
3449 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3450 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
|
3451 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3452 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
|
3453 && ! parsing_subfunctions) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3454 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
|
3455 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3456 curr_fcn_depth--; |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
3457 function_scopes.pop (); |
22196
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 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
|
3460 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
|
3461 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
|
3462 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
|
3463 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3464 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3465 tree_funcall * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3466 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
|
3467 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
|
3468 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3469 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
|
3470 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3471 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
|
3472 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
|
3473 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3474 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
|
3475 = 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
|
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 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
|
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_funcall * |
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_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
|
3482 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3483 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
|
3484 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3485 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
|
3486 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3487 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
|
3488 = 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
|
3489 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3490 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
|
3491 } |
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 // 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
|
3494 // 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
|
3495 // 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
|
3496 // 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
|
3497 // 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
|
3498 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3499 tree_classdef * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3500 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
|
3501 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
|
3502 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
|
3503 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
|
3504 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
|
3505 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
|
3506 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3507 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
|
3508 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3509 std::string cls_name = id->name (); |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3510 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
3511 std::string nm = lexer.fcn_file_name; |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3512 |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
3513 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
|
3514 |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3515 if (pos != std::string::npos) |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
3516 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
|
3517 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3518 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
|
3519 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3520 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3521 delete id; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3522 delete sc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3523 delete body; |
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 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
|
3526 |
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 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3529 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3530 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
|
3531 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3532 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
|
3533 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3534 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
|
3535 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
|
3536 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3537 if (! body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3538 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
|
3539 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3540 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
|
3541 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
|
3542 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3543 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3544 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3545 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3546 delete id; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3547 delete sc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3548 delete body; |
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 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
|
3551 } |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3554 return retval; |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3557 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
|
3558 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
|
3559 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
|
3560 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
|
3561 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
|
3562 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
|
3563 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3564 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
|
3565 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3566 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
|
3567 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3568 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
|
3569 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3570 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
|
3571 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
|
3572 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3573 if (! plist) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3574 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
|
3575 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3576 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
|
3577 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3578 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3579 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3580 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3581 delete plist; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3582 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3583 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
|
3584 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3585 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3586 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3587 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3588 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3589 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
|
3590 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
|
3591 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
|
3592 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
|
3593 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
|
3594 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
|
3595 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3596 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
|
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 (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
|
3599 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3600 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
|
3601 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3602 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
|
3603 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
|
3604 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3605 if (! mlist) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3606 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
|
3607 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3608 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
|
3609 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3610 else |
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 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3613 delete mlist; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3614 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3615 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
|
3616 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3617 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3618 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3619 } |
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 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
|
3622 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
|
3623 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
|
3624 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
|
3625 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
|
3626 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
|
3627 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3628 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
|
3629 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3630 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
|
3631 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3632 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
|
3633 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3634 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
|
3635 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
|
3636 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3637 if (! elist) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3638 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
|
3639 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3640 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
|
3641 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3642 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3643 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3644 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3645 delete elist; |
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 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
|
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 return retval; |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3653 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
|
3654 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
|
3655 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
|
3656 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
|
3657 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
|
3658 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
|
3659 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3660 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
|
3661 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3662 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
|
3663 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3664 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
|
3665 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3666 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
|
3667 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
|
3668 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3669 if (! elist) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3670 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
|
3671 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3672 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
|
3673 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3674 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3675 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3676 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3677 delete elist; |
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 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
|
3680 } |
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 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3683 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3684 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3685 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
|
3686 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
|
3687 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
|
3688 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3689 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
|
3690 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3691 // 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
|
3692 // 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
|
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 (! 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
|
3695 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3696 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3697 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
|
3698 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3699 // 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
|
3700 // - 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
|
3701 // - class constructor |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3702 // - `delete' |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3703 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3704 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
|
3705 && mname != "delete" |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3706 && 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
|
3707 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3708 // 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
|
3709 // is loaded. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3710 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3711 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
|
3712 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3713 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
|
3714 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3715 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
|
3716 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
|
3717 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3718 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
|
3719 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3720 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3721 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
|
3722 "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
|
3723 "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
|
3724 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3725 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3726 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
|
3727 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3728 if (! retval) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3729 delete id; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3730 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3731 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3732 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3733 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3734 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
|
3735 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
|
3736 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
|
3737 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
|
3738 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3739 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
|
3740 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
|
3741 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3742 if (cl) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3743 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
|
3744 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3745 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
|
3746 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
|
3747 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3748 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
|
3749 } |
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 // 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
|
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_index_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3754 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
|
3755 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
|
3756 char type) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3757 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3758 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
|
3759 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3760 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
|
3761 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3762 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3763 delete args; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3764 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3765 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
|
3766 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3767 else |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3768 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3769 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
|
3770 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
|
3771 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3772 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
|
3773 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
|
3774 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3775 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
|
3776 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3777 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
|
3778 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
|
3779 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3780 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
|
3781 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3782 retval = tmp; |
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 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3785 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
|
3786 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3787 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3788 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3789 } |
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 // 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
|
3792 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3793 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
|
3794 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
|
3795 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
|
3796 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3797 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
|
3798 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3799 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
|
3800 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
|
3801 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3802 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
|
3803 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
|
3804 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3805 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
|
3806 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3807 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
|
3808 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3809 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
|
3810 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3811 retval = tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3812 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3813 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3814 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
|
3815 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3816 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
|
3817 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3818 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3819 } |
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 // 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
|
3822 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3823 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
|
3824 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
|
3825 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
|
3826 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3827 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
|
3828 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3829 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
|
3830 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
|
3831 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3832 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
|
3833 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
|
3834 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3835 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
|
3836 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3837 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
|
3838 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3839 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
|
3840 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3841 retval = tmp; |
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 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3844 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
|
3845 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3846 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
|
3847 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3848 return retval; |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3851 // 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
|
3852 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3853 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
|
3854 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
|
3855 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
|
3856 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3857 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
|
3858 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3859 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
|
3860 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
|
3861 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3862 switch (tok) |
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 case GLOBAL: |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
3865 { |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
3866 retval = new tree_decl_command ("global", lst, l, c); |
23470
a41fdb801db6
use mark_global and mark_persistent consistently
John W. Eaton <jwe@octave.org>
parents:
23469
diff
changeset
|
3867 retval->mark_global (); |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
3868 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3869 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3870 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3871 case PERSISTENT: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3872 if (curr_fcn_depth > 0) |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
3873 { |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
3874 retval = new tree_decl_command ("persistent", lst, l, c); |
23470
a41fdb801db6
use mark_global and mark_persistent consistently
John W. Eaton <jwe@octave.org>
parents:
23469
diff
changeset
|
3875 retval->mark_persistent (); |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
3876 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3877 else |
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 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
|
3880 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
|
3881 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
|
3882 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3883 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
|
3884 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3885 break; |
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 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3888 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3889 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3890 } |
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 retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3893 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3894 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3895 bool |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3896 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
|
3897 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3898 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
|
3899 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3900 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
|
3901 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22785
diff
changeset
|
3902 for (tree_argument_list* row : *al) |
22196
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 (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
|
3905 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3906 retval = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3907 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3908 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
|
3909 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
|
3910 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3911 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
|
3912 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3913 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3914 } |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3917 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3918 } |
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 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
|
3921 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
|
3922 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3923 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
|
3924 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3925 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
|
3926 { |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
3927 octave::tree_evaluator& tw |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
3928 = __get_evaluator__ ("validate_matrix_for_assignment"); |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
3929 |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
3930 octave_value ov = tw.evaluate (e); |
22196
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 delete e; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3933 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
3934 if (ov.isempty ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3935 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
|
3936 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3937 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
|
3938 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3939 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3940 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3941 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
|
3942 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3943 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
|
3944 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3945 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
|
3946 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3947 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
|
3948 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3949 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
|
3950 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3951 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
|
3952 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
|
3953 delete e; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3954 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
|
3955 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3956 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3957 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3958 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
|
3959 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3960 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
|
3961 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3962 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
|
3963 retval = tmp; |
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 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3966 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3967 delete tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3968 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3969 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
|
3970 } |
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 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
|
3973 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
|
3974 } |
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 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3977 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3978 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3979 // 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
|
3980 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3981 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3982 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
|
3983 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3984 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
|
3985 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3986 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
|
3987 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3988 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
|
3989 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
|
3990 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3991 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
|
3992 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
|
3993 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3994 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
|
3995 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3996 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3997 { |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
3998 octave::tree_evaluator& tw |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
3999 = __get_evaluator__ ("finish_array_list"); |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4000 |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4001 octave_value tmp = tw.evaluate (array_list); |
22196
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 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
|
4004 = 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
|
4005 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
|
4006 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4007 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
|
4008 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4009 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
|
4010 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4011 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
|
4012 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4013 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
|
4014 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4015 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
|
4016 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4017 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
|
4018 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4019 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
|
4020 { |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
4021 octave::interpreter::recover_from_exception (); |
22196
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4025 return retval; |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4028 // 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
|
4029 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4030 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4031 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
|
4032 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4033 return (m |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4034 ? 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
|
4035 : 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
|
4036 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4037 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4038 // 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
|
4039 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4040 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4041 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
|
4042 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4043 return (c |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4044 ? 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
|
4045 : 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
|
4046 } |
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 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4049 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
|
4050 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4051 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
|
4052 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4053 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
|
4054 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4055 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
|
4056 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
|
4057 ("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
|
4058 "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
|
4059 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
|
4060 } |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
4061 } |
1623 | 4062 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4063 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
|
4064 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
|
4065 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
|
4066 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4067 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
|
4068 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4069 switch (sep) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4070 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4071 case ';': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4072 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
|
4073 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4074 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4075 case 0: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4076 case ',': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4077 case '\n': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4078 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
|
4079 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
|
4080 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
|
4081 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4082 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4083 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4084 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
|
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 // 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
|
4089 // 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
|
4090 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4091 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
|
4092 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4093 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
|
4094 delete tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4095 } |
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 return list; |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4100 // 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
|
4101 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
|
4102 tree_statement * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4103 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
|
4104 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4105 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
|
4106 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4107 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
|
4108 } |
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 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
|
4111 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
|
4112 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4113 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
|
4114 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4115 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4116 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
|
4117 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
|
4118 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
|
4119 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
|
4120 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4121 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
|
4122 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4123 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
|
4124 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4125 return list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4126 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4127 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4128 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4129 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
|
4130 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4131 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
|
4132 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
|
4133 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4134 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
|
4135 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4136 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
|
4137 || 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
|
4138 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
|
4139 << " 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
|
4140 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4141 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
|
4142 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4143 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
|
4144 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
|
4145 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4146 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
|
4147 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4148 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
|
4149 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4150 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
|
4151 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4152 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
|
4153 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4154 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
|
4155 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
|
4156 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4157 // 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
|
4158 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4159 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
|
4160 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4161 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
|
4162 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
|
4163 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4164 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
|
4165 output_buf << " "; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4166 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4167 output_buf << "^"; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4168 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4169 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4170 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
|
4171 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4172 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
|
4173 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4174 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4175 int |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4176 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
|
4177 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4178 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
|
4179 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4180 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
|
4181 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4182 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4183 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4184 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
|
4185 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4186 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
|
4187 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4188 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
|
4189 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4190 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
|
4191 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
|
4192 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4193 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
|
4194 } |
23049
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
4195 catch (const octave::exit_exception&) |
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
4196 { |
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
4197 throw; |
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
4198 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4199 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
|
4200 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4201 throw; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4202 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4203 catch (...) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4204 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4205 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
|
4206 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4207 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
|
4208 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
|
4209 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4210 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
|
4211 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4212 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4213 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
|
4214 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
|
4215 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4216 return status; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4217 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4218 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4219 // 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
|
4220 // 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
|
4221 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4222 int |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4223 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
|
4224 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4225 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
|
4226 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4227 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
|
4228 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4229 do |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4230 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4231 YYSTYPE lval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4232 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4233 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
|
4234 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4235 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
|
4236 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4237 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
|
4238 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4239 status = -1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4240 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4241 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4242 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4243 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4244 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
|
4245 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4246 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4247 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4248 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
|
4249 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4250 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
|
4251 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4252 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
|
4253 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4254 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
|
4255 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
|
4256 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4257 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
|
4258 } |
23049
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
4259 catch (const octave::exit_exception&) |
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
4260 { |
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
4261 throw; |
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
4262 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
4263 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
|
4264 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4265 throw; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4266 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4267 catch (...) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4268 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4269 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
|
4270 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4271 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
|
4272 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
|
4273 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4274 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
|
4275 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4276 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4277 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
|
4278 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4279 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
|
4280 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
|
4281 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4282 return status; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4283 } |
16294
0925d1f6875e
push parser/lexer interface
John W. Eaton <jwe@octave.org>
parents:
16293
diff
changeset
|
4284 } |
0925d1f6875e
push parser/lexer interface
John W. Eaton <jwe@octave.org>
parents:
16293
diff
changeset
|
4285 |
3021 | 4286 static void |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
4287 safe_fclose (FILE *f) |
3021 | 4288 { |
4289 if (f) | |
4290 fclose (static_cast<FILE *> (f)); | |
4291 } | |
4292 | |
7336 | 4293 static octave_function * |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4294 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
|
4295 const std::string& dispatch_type, |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
4296 const std::string& package_name, |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
4297 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
|
4298 bool relative_lookup, const std::string& warn_for) |
3021 | 4299 { |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21740
diff
changeset
|
4300 octave::unwind_protect frame; |
3021 | 4301 |
7336 | 4302 octave_function *fcn_ptr = 0; |
3021 | 4303 |
4304 // Open function file and parse. | |
4305 | |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4306 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
|
4307 |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4308 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
|
4309 |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4310 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
|
4311 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
|
4312 |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
4313 octave::command_history::ignore_entries (); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4314 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
4315 FILE *ffile = 0; |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
4316 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4317 if (! full_file.empty ()) |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21861
diff
changeset
|
4318 ffile = std::fopen (full_file.c_str (), "rb"); |
3021 | 4319 |
4320 if (ffile) | |
4321 { | |
19709
5cfb3ccbf24a
style fixes for resource management
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
4322 frame.add_fcn (safe_fclose, ffile); |
5cfb3ccbf24a
style fixes for resource management
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
4323 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4324 octave::parser parser (ffile); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4325 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4326 parser.curr_class_name = dispatch_type; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
4327 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
|
4328 parser.autoloading = autoload; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4329 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
|
4330 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4331 parser.lexer.force_script = force_script; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4332 parser.lexer.prep_for_file (); |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4333 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
|
4334 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4335 parser.lexer.fcn_file_name = file; |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4336 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
|
4337 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4338 int status = parser.run (); |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4339 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
4340 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
|
4341 |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4342 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
|
4343 { |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4344 if (parser.lexer.reading_classdef_file |
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4345 && 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
|
4346 { |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4347 // 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
|
4348 // 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
|
4349 // table?). Return pointer to constructor? |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4350 |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4351 if (fcn_ptr) |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4352 panic_impossible (); |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
4353 |
18263
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18262
diff
changeset
|
4354 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
|
4355 |
23533
8edbc923a7dc
begin refactoring use of interpreter/evaluator in classdef objects
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
4356 octave::interpreter& interp |
8edbc923a7dc
begin refactoring use of interpreter/evaluator in classdef objects
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
4357 = octave::__get_interpreter__ ("parse_fcn_file"); |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4358 |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4359 fcn_ptr |
23533
8edbc923a7dc
begin refactoring use of interpreter/evaluator in classdef objects
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
4360 = parser.classdef_object->make_meta_class (interp, is_at_folder); |
21589
ad90fb5a139f
eliminate memory leaks from classdef parse tree (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
21581
diff
changeset
|
4361 |
ad90fb5a139f
eliminate memory leaks from classdef parse tree (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
21581
diff
changeset
|
4362 delete (parser.classdef_object); |
ad90fb5a139f
eliminate memory leaks from classdef parse tree (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
21581
diff
changeset
|
4363 |
ad90fb5a139f
eliminate memory leaks from classdef parse tree (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
21581
diff
changeset
|
4364 parser.classdef_object = 0; |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
4365 } |
16644
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4366 else if (fcn_ptr) |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4367 { |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4368 fcn_ptr->maybe_relocate_end (); |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4369 |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4370 if (parser.parsing_subfunctions) |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4371 { |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4372 if (! parser.endfunction_found) |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4373 parser.subfunction_names.reverse (); |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4374 |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4375 fcn_ptr->stash_subfunction_names (parser.subfunction_names); |
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
4376 } |
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
|
4377 } |
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
|
4378 } |
10872
988d16d5ae34
correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents:
10659
diff
changeset
|
4379 else |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
4380 error ("parse error while reading file %s", full_file.c_str ()); |
3021 | 4381 } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
4382 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
|
4383 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
|
4384 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
|
4385 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
|
4386 full_file.c_str ()); |
3021 | 4387 |
7336 | 4388 return fcn_ptr; |
3021 | 4389 } |
4390 | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4391 namespace octave |
5592 | 4392 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4393 std::string |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4394 get_help_from_file (const std::string& nm, bool& symbol_found, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4395 std::string& full_file) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4396 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4397 std::string retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4398 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4399 full_file = fcn_file_in_path (nm); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4400 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4401 std::string file = full_file; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4402 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4403 size_t file_len = file.length (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4404 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4405 if ((file_len > 4 && file.substr (file_len-4) == ".oct") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4406 || (file_len > 4 && file.substr (file_len-4) == ".mex") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4407 || (file_len > 2 && file.substr (file_len-2) == ".m")) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4408 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4409 file = octave::sys::env::base_pathname (file); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4410 file = file.substr (0, file.find_last_of ('.')); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4411 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4412 size_t pos = file.find_last_of (octave::sys::file_ops::dir_sep_str ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4413 if (pos != std::string::npos) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4414 file = file.substr (pos+1); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4415 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4416 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4417 if (! file.empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4418 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4419 symbol_found = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4420 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4421 octave_function *fcn |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4422 = parse_fcn_file (full_file, file, "", "", true, false, false, false, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4423 ""); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4424 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4425 if (fcn) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4426 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4427 retval = fcn->doc_string (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4428 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4429 delete fcn; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4430 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4431 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4432 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4433 return retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4434 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4435 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4436 std::string |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4437 get_help_from_file (const std::string& nm, bool& symbol_found) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4438 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4439 std::string file; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4440 return get_help_from_file (nm, symbol_found, file); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4441 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4442 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4443 std::string |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4444 lookup_autoload (const std::string& nm) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4445 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4446 std::string retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4447 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4448 typedef std::map<std::string, std::string>::const_iterator am_iter; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4449 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4450 am_iter p = autoload_map.find (nm); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4451 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4452 if (p != autoload_map.end ()) |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
4453 { |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
4454 load_path& lp = octave::__get_load_path__ ("lookup_autoload"); |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
4455 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
4456 retval = lp.find_file (p->second); |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
4457 } |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4458 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4459 return retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4460 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4461 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4462 string_vector |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4463 autoloaded_functions (void) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4464 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4465 string_vector names (autoload_map.size ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4466 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4467 octave_idx_type i = 0; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4468 for (const auto& fcn_fname : autoload_map) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4469 names[i++] = fcn_fname.first; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4470 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4471 return names; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4472 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4473 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4474 string_vector |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4475 reverse_lookup_autoload (const std::string& nm) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4476 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4477 string_vector names; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4478 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4479 for (const auto& fcn_fname : autoload_map) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4480 if (nm == fcn_fname.second) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4481 names.append (fcn_fname.first); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4482 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4483 return names; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4484 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4485 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4486 octave_function * |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4487 load_fcn_from_file (const std::string& file_name, const std::string& dir_name, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4488 const std::string& dispatch_type, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4489 const std::string& package_name, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4490 const std::string& fcn_name, bool autoload) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4491 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4492 octave_function *retval = 0; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4493 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4494 octave::unwind_protect frame; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4495 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4496 std::string nm = file_name; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4497 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4498 size_t nm_len = nm.length (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4499 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4500 std::string file; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4501 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4502 bool relative_lookup = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4503 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4504 file = nm; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4505 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4506 if ((nm_len > 4 && nm.substr (nm_len-4) == ".oct") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4507 || (nm_len > 4 && nm.substr (nm_len-4) == ".mex") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4508 || (nm_len > 2 && nm.substr (nm_len-2) == ".m")) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4509 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4510 nm = octave::sys::env::base_pathname (file); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4511 nm = nm.substr (0, nm.find_last_of ('.')); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4512 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4513 size_t pos = nm.find_last_of (octave::sys::file_ops::dir_sep_str ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4514 if (pos != std::string::npos) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4515 nm = nm.substr (pos+1); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4516 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4517 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4518 relative_lookup = ! octave::sys::env::absolute_pathname (file); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4519 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4520 file = octave::sys::env::make_absolute (file); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4521 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4522 int len = file.length (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4523 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4524 if (len > 4 && file.substr (len-4, len-1) == ".oct") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4525 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4526 if (autoload && ! fcn_name.empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4527 nm = fcn_name; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4528 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4529 retval = octave::dynamic_loader::load_oct (nm, file, relative_lookup); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4530 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4531 else if (len > 4 && file.substr (len-4, len-1) == ".mex") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4532 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4533 // Temporarily load m-file version of mex-file, if it exists, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4534 // to get the help-string to use. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4535 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4536 octave_function *tmpfcn = parse_fcn_file (file.substr (0, len - 2), |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4537 nm, dispatch_type, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4538 package_name, false, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4539 autoload, autoload, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4540 relative_lookup, ""); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4541 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4542 retval = octave::dynamic_loader::load_mex (nm, file, relative_lookup); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4543 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4544 if (tmpfcn) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4545 retval->document (tmpfcn->doc_string ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4546 delete tmpfcn; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4547 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4548 else if (len > 2) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4549 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4550 retval = parse_fcn_file (file, nm, dispatch_type, package_name, true, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4551 autoload, autoload, relative_lookup, ""); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4552 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4553 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4554 if (retval) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4555 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4556 retval->stash_dir_name (dir_name); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4557 retval->stash_package_name (package_name); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4558 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4559 if (retval->is_user_function ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4560 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4561 symbol_table::scope_id id = retval->scope (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4562 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4563 symbol_table::stash_dir_name_for_subfunctions (id, dir_name); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4564 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4565 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4566 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4567 return retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4568 } |
5312 | 4569 } |
4570 | |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4571 DEFMETHOD (autoload, interp, args, , |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4572 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4573 @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
|
4574 @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
|
4575 @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
|
4576 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
|
4577 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4578 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
|
4579 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
|
4580 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
|
4581 path. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4582 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4583 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
|
4584 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
|
4585 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
|
4586 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
|
4587 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4588 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4589 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
|
4590 @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
|
4591 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4592 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4593 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
|
4594 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
|
4595 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4596 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4597 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
|
4598 @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
|
4599 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4600 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4601 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
|
4602 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4603 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
|
4604 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4605 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
|
4606 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
|
4607 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4608 @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
|
4609 @end deftypefn */) |
5484 | 4610 { |
5626 | 4611 octave_value retval; |
5484 | 4612 |
4613 int nargin = args.length (); | |
4614 | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4615 if (nargin == 1 || nargin > 3) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4616 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4617 |
5626 | 4618 if (nargin == 0) |
4619 { | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
4620 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
|
4621 Cell file_names (dim_vector (autoload_map.size (), 1)); |
5626 | 4622 |
4623 octave_idx_type i = 0; | |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22785
diff
changeset
|
4624 for (const auto& fcn_fname : autoload_map) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4625 { |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22785
diff
changeset
|
4626 func_names(i) = fcn_fname.first; |
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22785
diff
changeset
|
4627 file_names(i) = fcn_fname.second; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4628 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4629 i++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4630 } |
5626 | 4631 |
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
|
4632 octave_map m; |
5626 | 4633 |
4634 m.assign ("function", func_names); | |
4635 m.assign ("file", file_names); | |
4636 | |
4637 retval = m; | |
4638 } | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4639 else |
5484 | 4640 { |
4641 string_vector argv = args.make_argv ("autoload"); | |
4642 | |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4643 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
|
4644 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
4645 if (! octave::sys::env::absolute_pathname (nm)) |
6380 | 4646 { |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4647 octave::call_stack& cs = interp.get_call_stack (); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4648 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4649 octave_user_code *fcn = cs.caller_user_code (); |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4650 |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4651 bool found = false; |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4652 |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4653 if (fcn) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4654 { |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4655 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
|
4656 |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4657 if (! fname.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4658 { |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
4659 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
|
4660 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
|
4661 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
4662 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
|
4663 |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4664 if (fs.exists ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4665 { |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4666 nm = fname + nm; |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4667 found = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4668 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4669 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4670 } |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4671 if (! found) |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4672 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
|
4673 "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
|
4674 nm.c_str ()); |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4675 } |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4676 if (nargin == 2) |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4677 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
|
4678 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
|
4679 { |
21021
a5b99b09f8fd
maint: Use comparison operators rather than compare() for strings.
Rik <rik@octave.org>
parents:
20957
diff
changeset
|
4680 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
|
4681 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
|
4682 "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
|
4683 |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
4684 // 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
|
4685 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
|
4686 autoload_map.erase (argv[1]); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4687 } |
5484 | 4688 } |
4689 | |
4690 return retval; | |
4691 } | |
4692 | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4693 namespace octave |
4486 | 4694 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4695 void |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4696 source_file (const std::string& file_name, const std::string& context, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4697 bool verbose, bool require_file, const std::string& warn_for) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4698 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4699 // Map from absolute name of script file to recursion level. We |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4700 // use a map instead of simply placing a limit on recursion in the |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4701 // source_file function so that two mutually recursive scripts |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4702 // written as |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4703 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4704 // foo1.m: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4705 // ------ |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4706 // foo2 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4707 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4708 // foo2.m: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4709 // ------ |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4710 // foo1 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4711 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4712 // and called with |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4713 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4714 // foo1 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4715 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4716 // (for example) will behave the same if they are written as |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4717 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4718 // foo1.m: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4719 // ------ |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4720 // source ("foo2.m") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4721 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4722 // foo2.m: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4723 // ------ |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4724 // source ("foo1.m") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4725 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4726 // and called with |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4727 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4728 // source ("foo1.m") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4729 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4730 // (for example). |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4731 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4732 static std::map<std::string, int> source_call_depth; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4733 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4734 std::string file_full_name = octave::sys::file_ops::tilde_expand (file_name); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4735 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4736 file_full_name = octave::sys::env::make_absolute (file_full_name); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4737 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4738 octave::unwind_protect frame; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4739 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4740 if (source_call_depth.find (file_full_name) == source_call_depth.end ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4741 source_call_depth[file_full_name] = -1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4742 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4743 frame.protect_var (source_call_depth[file_full_name]); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4744 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4745 source_call_depth[file_full_name]++; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4746 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4747 if (source_call_depth[file_full_name] >= Vmax_recursion_depth) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4748 error ("max_recursion_depth exceeded"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4749 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4750 if (! context.empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4751 { |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4752 octave::call_stack& cs = octave::__get_call_stack__ ("source_file"); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4753 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4754 if (context == "caller") |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4755 cs.goto_caller_frame (); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4756 else if (context == "base") |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4757 cs.goto_base_frame (); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4758 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4759 error ("source: context must be \"caller\" or \"base\""); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4760 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4761 frame.add_method (cs, &octave::call_stack::pop); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4762 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4763 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4764 octave_function *fcn = 0; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4765 // Don't delete a function already in symbol_table |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4766 bool delete_fcn = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4767 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4768 // Find symbol name that would be in symbol_table, if it were loaded. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4769 size_t dir_end = file_name.find_last_of (octave::sys::file_ops::dir_sep_chars ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4770 dir_end = (dir_end == std::string::npos) ? 0 : dir_end + 1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4771 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4772 size_t extension = file_name.find_last_of ('.'); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4773 if (extension == std::string::npos) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4774 extension = file_name.length (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4775 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4776 std::string symbol = file_name.substr (dir_end, extension - dir_end); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4777 std::string full_name = octave::sys::canonicalize_file_name (file_name); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4778 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4779 // Check if this file is already loaded (or in the path) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4780 octave_value loaded_sym = symbol_table::find (symbol); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4781 if (loaded_sym.is_function ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4782 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4783 fcn = loaded_sym.function_value (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4784 if (fcn) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4785 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4786 if (octave::sys::canonicalize_file_name (fcn->fcn_file_name ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4787 != full_name) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4788 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4789 fcn = 0; // wrong file, so load it below |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4790 delete_fcn = true; // and delete it when done. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4791 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4792 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4793 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4794 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4795 // If no symbol of this name, or the symbol is for a different file, load |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4796 if (! fcn) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4797 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4798 try |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4799 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4800 fcn = parse_fcn_file (file_full_name, file_name, "", "", |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4801 require_file, true, false, false, warn_for); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4802 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4803 catch (octave::execution_exception& e) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4804 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4805 error (e, "source: error sourcing file '%s'", |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4806 file_full_name.c_str ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4807 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4808 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4809 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4810 // Return or error if we don't have a valid script |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4811 if (! fcn) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4812 return; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4813 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4814 if (! fcn->is_user_code ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4815 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4816 if (delete_fcn) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4817 delete fcn; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4818 error ("source: %s is not a script", full_name.c_str ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4819 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4820 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4821 if (verbose) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4822 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4823 std::cout << "executing commands from " << full_name << " ... "; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4824 std::cout.flush (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4825 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4826 |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4827 tree_evaluator& tw = __get_evaluator__ ("source"); |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4828 |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4829 fcn->call (tw, 0); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4830 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4831 if (verbose) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4832 std::cout << "done." << std::endl; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4833 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4834 // Delete scripts not on the path, so they don't shadow ones that are. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4835 if (delete_fcn) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4836 delete fcn; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4837 } |
4486 | 4838 } |
4839 | |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4840 DEFMETHOD (mfilename, interp, args, , |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4841 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4842 @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
|
4843 @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
|
4844 @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
|
4845 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
|
4846 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4847 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
|
4848 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4849 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
|
4850 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
|
4851 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4852 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
|
4853 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
|
4854 @end deftypefn */) |
5739 | 4855 { |
4856 octave_value retval; | |
4857 | |
4858 int nargin = args.length (); | |
4859 | |
4860 if (nargin > 1) | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4861 print_usage (); |
5739 | 4862 |
4863 std::string arg; | |
4864 | |
4865 if (nargin == 1) | |
21861
a55f1fa2c94a
oct-parse.in.yy: Shorten lines to < 80 characters where possible.
Rik <rik@octave.org>
parents:
21748
diff
changeset
|
4866 arg = args(0).xstring_value ("mfilename: argument must be a string"); |
5739 | 4867 |
4868 std::string fname; | |
4869 | |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4870 octave::call_stack& cs = interp.get_call_stack (); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4871 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
4872 octave_user_code *fcn = cs.caller_user_code (); |
5743 | 4873 |
4874 if (fcn) | |
4875 { | |
4876 fname = fcn->fcn_file_name (); | |
4877 | |
4878 if (fname.empty ()) | |
4879 fname = fcn->name (); | |
4880 } | |
5739 | 4881 |
4882 if (arg == "fullpathext") | |
4883 retval = fname; | |
4884 else | |
4885 { | |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
4886 size_t dpos = fname.rfind (octave::sys::file_ops::dir_sep_char ()); |
5747 | 4887 size_t epos = fname.rfind ('.'); |
4888 | |
4889 if (epos <= dpos) | |
8021 | 4890 epos = std::string::npos; |
4891 | |
4892 fname = (epos != std::string::npos) ? fname.substr (0, epos) : fname; | |
5739 | 4893 |
4894 if (arg == "fullpath") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4895 retval = fname; |
5739 | 4896 else |
8021 | 4897 retval = (dpos != std::string::npos) ? fname.substr (dpos+1) : fname; |
5739 | 4898 } |
4899 | |
4900 return retval; | |
4901 } | |
4902 | |
3021 | 4903 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
|
4904 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
|
4905 @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
|
4906 @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
|
4907 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
|
4908 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4909 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
|
4910 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
|
4911 @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
|
4912 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
4913 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
|
4914 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
|
4915 (@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
|
4916 @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
|
4917 @end deftypefn */) |
3021 | 4918 { |
4919 octave_value_list retval; | |
4920 | |
4921 int nargin = args.length (); | |
4922 | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4923 if (nargin < 1 || nargin > 2) |
5823 | 4924 print_usage (); |
3021 | 4925 |
21861
a55f1fa2c94a
oct-parse.in.yy: Shorten lines to < 80 characters where possible.
Rik <rik@octave.org>
parents:
21748
diff
changeset
|
4926 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
|
4927 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4928 std::string context; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4929 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4930 if (nargin == 2) |
21861
a55f1fa2c94a
oct-parse.in.yy: Shorten lines to < 80 characters where possible.
Rik <rik@octave.org>
parents:
21748
diff
changeset
|
4931 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
|
4932 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4933 octave::source_file (file_name, context); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
4934 |
3021 | 4935 return retval; |
4936 } | |
4937 | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4938 namespace octave |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4939 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4940 /*! |
22298
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
4941 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
|
4942 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
|
4943 |
22300 | 4944 @param name The name of the function to call. |
4945 @param args The arguments to the function. | |
4946 @param nargout The number of output arguments expected. | |
4947 @return A list of output values. The length of the list is not | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4948 necessarily the same as @c nargout. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4949 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4950 */ |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4951 octave_value_list |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4952 feval (const std::string& name, const octave_value_list& args, int nargout) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4953 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4954 octave_value_list retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4955 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4956 octave_value fcn = symbol_table::find_function (name, args); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4957 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4958 if (fcn.is_defined ()) |
23502
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4959 { |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4960 tree_evaluator& tw = __get_evaluator__ ("feval"); |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4961 |
23502
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4962 octave_function *of = fcn.function_value (); |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4963 |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4964 retval = of->call (tw, nargout, args); |
23502
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4965 } |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4966 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4967 error ("feval: function '%s' not found", name.c_str ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4968 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4969 return retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4970 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4971 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4972 octave_value_list |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4973 feval (octave_function *fcn, const octave_value_list& args, int nargout) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4974 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4975 octave_value_list retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4976 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4977 if (fcn) |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4978 { |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4979 tree_evaluator& tw = __get_evaluator__ ("feval"); |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4980 |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4981 retval = fcn->call (tw, nargout, args); |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
4982 } |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4983 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4984 return retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
4985 } |
23502
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4986 |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4987 octave_value_list |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4988 feval (octave_value& val, const octave_value_list& args, int nargout) |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4989 { |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4990 if (val.is_function ()) |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4991 { |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4992 return octave::feval (val.function_value (), args, nargout); |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4993 } |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4994 else if (val.is_function_handle ()) |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4995 { |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4996 // This covers function handles, inline functions, and anonymous |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4997 // functions. |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4998 |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
4999 std::list<octave_value_list> arg_list; |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5000 arg_list.push_back (args); |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5001 |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5002 return val.subsref ("(", arg_list, nargout); |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5003 } |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5004 else if (val.is_string ()) |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5005 { |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5006 return octave::feval (val.string_value (), args, nargout); |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5007 } |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5008 else |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5009 error ("feval: first argument must be a string, inline function, or a function handle"); |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5010 |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5011 return ovl (); |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5012 } |
4342 | 5013 } |
5014 | |
5015 static octave_value_list | |
5016 get_feval_args (const octave_value_list& args) | |
5017 { | |
10659
8baff2aceabc
fix slicing value lists with name tags (bug #29960)
Jaroslav Hajek <highegg@gmail.com>
parents:
10578
diff
changeset
|
5018 return args.slice (1, args.length () - 1, true); |
4342 | 5019 } |
5020 | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5021 namespace octave |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5022 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5023 /*! |
22298
18535a29a8e8
doc: improve documentation on oct-parse.in.yy(feval) (patch #9082)
Ernst Reissner <rei3ner@arcor.de>
parents:
22196
diff
changeset
|
5024 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
|
5025 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
|
5026 |
22300 | 5027 @param args The first element of @c args is the function to call. |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5028 It may be the name of the function as a string, a function |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5029 handle, or an inline function. The remaining arguments are |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5030 passed to the function. |
22300 | 5031 @param nargout The number of output arguments expected. |
5032 @return A list of output values. The length of the list is not | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5033 necessarily the same as @c nargout. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5034 */ |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5035 octave_value_list |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5036 feval (const octave_value_list& args, int nargout) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5037 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5038 if (args.length () > 0) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5039 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5040 octave_value f_arg = args(0); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5041 |
23502
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5042 octave_value_list tmp_args = get_feval_args (args); |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5043 |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5044 return octave::feval (f_arg, tmp_args, nargout); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5045 } |
23502
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5046 else |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5047 error ("feval: first argument must be a string, inline function, or a function handle"); |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5048 |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
5049 return ovl (); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5050 } |
3021 | 5051 } |
5052 | |
5053 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
|
5054 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
|
5055 @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
|
5056 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
|
5057 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5058 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
|
5059 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
|
5060 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5061 @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 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5063 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
|
5064 @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
|
5065 @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
|
5066 @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
|
5067 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5068 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5069 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
|
5070 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5071 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
|
5072 (@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
|
5073 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
|
5074 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
|
5075 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5076 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5077 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5078 @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
|
5079 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
|
5080 @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
|
5081 @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
|
5082 @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
|
5083 @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
|
5084 @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
|
5085 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5086 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5087 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
|
5088 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
|
5089 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
|
5090 instead. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5091 @end deftypefn */) |
3021 | 5092 { |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20798
diff
changeset
|
5093 if (args.length () == 0) |
5823 | 5094 print_usage (); |
3021 | 5095 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5096 return octave::feval (args, nargout); |
3021 | 5097 } |
5098 | |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
5099 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
|
5100 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
|
5101 @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
|
5102 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
|
5103 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
|
5104 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5105 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
|
5106 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
|
5107 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
|
5108 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5109 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
|
5110 @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
|
5111 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5112 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5113 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5114 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
|
5115 @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
|
5116 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
|
5117 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
|
5118 @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
|
5119 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
|
5120 @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
|
5121 @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
|
5122 @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
|
5123 @end deftypefn */) |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
5124 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
5125 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
|
5126 |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20798
diff
changeset
|
5127 if (args.length () == 0) |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5128 print_usage (); |
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 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
|
5131 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5132 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
|
5133 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5134 if (fcn.is_defined ()) |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5135 retval = octave::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
|
5136 else |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5137 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
|
5138 |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
5139 return retval; |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
5140 } |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
5141 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5142 namespace octave |
3021 | 5143 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5144 octave_value_list |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5145 eval_string (const std::string& eval_str, bool silent, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5146 int& parse_status, int nargout) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5147 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5148 octave_value_list retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5149 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5150 octave::parser parser (eval_str); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5151 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5152 do |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5153 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5154 parser.reset (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5155 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5156 parse_status = parser.run (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5157 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5158 if (parse_status == 0) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5159 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5160 if (parser.stmt_list) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5161 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5162 tree_statement *stmt = 0; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5163 |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
5164 octave::tree_evaluator& tw = __get_evaluator__ ("eval_string"); |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
5165 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5166 if (parser.stmt_list->length () == 1 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5167 && (stmt = parser.stmt_list->front ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5168 && stmt->is_expression ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5169 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5170 tree_expression *expr = stmt->expression (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5171 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5172 if (silent) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5173 expr->set_print_flag (false); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5174 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5175 bool do_bind_ans = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5176 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5177 if (expr->is_identifier ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5178 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5179 tree_identifier *id |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5180 = dynamic_cast<tree_identifier *> (expr); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5181 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5182 do_bind_ans = (! id->is_variable ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5183 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5184 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5185 do_bind_ans = (! expr->is_assignment_expression ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5186 |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
5187 retval = tw.evaluate_n (expr, nargout); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5188 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5189 if (do_bind_ans && ! retval.empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5190 bind_ans (retval(0), expr->print_result ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5191 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5192 if (nargout == 0) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5193 retval = octave_value_list (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5194 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5195 else if (nargout == 0) |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
5196 parser.stmt_list->accept (tw); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5197 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5198 error ("eval: invalid use of statement list"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5199 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5200 if (tree_return_command::returning |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5201 || tree_break_command::breaking |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5202 || tree_continue_command::continuing) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5203 break; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5204 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5205 else if (parser.lexer.end_of_input) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5206 break; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5207 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5208 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5209 while (parse_status == 0); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5210 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5211 return retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5212 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5213 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5214 octave_value |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5215 eval_string (const std::string& eval_str, bool silent, int& parse_status) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5216 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5217 octave_value retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5218 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5219 octave_value_list tmp = eval_string (eval_str, silent, parse_status, 1); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5220 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5221 if (! tmp.empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5222 retval = tmp(0); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5223 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5224 return retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5225 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5226 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5227 static octave_value_list |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5228 eval_string (const octave_value& arg, bool silent, int& parse_status, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5229 int nargout) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5230 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5231 std::string s = arg.xstring_value ("eval: expecting std::string argument"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5232 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5233 return eval_string (s, silent, parse_status, nargout); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5234 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5235 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5236 void |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5237 cleanup_statement_list (tree_statement_list **lst) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5238 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5239 if (*lst) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5240 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5241 delete *lst; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5242 *lst = 0; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5243 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5244 } |
13970 | 5245 } |
5246 | |
3021 | 5247 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
|
5248 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
|
5249 @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
|
5250 @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
|
5251 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
|
5252 program. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5253 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5254 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
|
5255 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5256 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
|
5257 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
|
5258 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5259 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
|
5260 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
|
5261 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5262 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5263 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
|
5264 @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
|
5265 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5266 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
|
5267 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
|
5268 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5269 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5270 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5271 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
|
5272 '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
|
5273 @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
|
5274 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
|
5275 @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
|
5276 @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
|
5277 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5278 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
|
5279 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
|
5280 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
|
5281 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
|
5282 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
|
5283 does. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5284 @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
|
5285 @end deftypefn */) |
3021 | 5286 { |
5287 octave_value_list retval; | |
5288 | |
5289 int nargin = args.length (); | |
5290 | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5291 if (nargin == 0) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5292 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5293 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21740
diff
changeset
|
5294 octave::unwind_protect frame; |
20798
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 if (nargin > 1) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5297 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5298 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
|
5299 buffer_error_messages++; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5300 } |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5301 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5302 int parse_status = 0; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5303 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5304 bool execution_error = false; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5305 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5306 octave_value_list tmp; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5307 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5308 try |
3021 | 5309 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5310 tmp = octave::eval_string (args(0), nargout > 0, parse_status, nargout); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5311 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
5312 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
|
5313 { |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
5314 octave::interpreter::recover_from_exception (); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5315 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5316 execution_error = true; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5317 } |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5318 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5319 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
|
5320 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5321 // 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
|
5322 // 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
|
5323 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5324 buffer_error_messages--; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5325 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5326 tmp = octave::eval_string (args(1), nargout > 0, parse_status, nargout); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5327 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5328 if (nargout > 0) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5329 retval = tmp; |
3021 | 5330 } |
5331 else | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5332 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5333 if (nargout > 0) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5334 retval = tmp; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5335 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5336 // 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
|
5337 // 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
|
5338 if (execution_error) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5339 octave_throw_execution_exception (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5340 } |
3021 | 5341 |
5342 return retval; | |
5343 } | |
5344 | |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5345 /* |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5346 |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5347 %!shared x |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5348 %! x = 1; |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5349 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5350 %!assert (eval ("x"), 1) |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5351 %!assert (eval ("x;")) |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
5352 %!assert (eval ("x;"), 1) |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5353 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5354 %!test |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5355 %! y = eval ("x"); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5356 %! assert (y, 1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5357 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5358 %!test |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5359 %! y = eval ("x;"); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5360 %! assert (y, 1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5361 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5362 %!test |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21416
diff
changeset
|
5363 %! eval ("x = 1;"); |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5364 %! assert (x,1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5365 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5366 %!test |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5367 %! eval ("flipud = 2;"); |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5368 %! assert (flipud, 2); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5369 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5370 %!function y = __f () |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5371 %! eval ("flipud = 2;"); |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5372 %! y = flipud; |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5373 %!endfunction |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
5374 %!assert (__f(), 2) |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5375 |
14533
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
5376 % bug #35645 |
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
5377 %!test |
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
5378 %! [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
|
5379 %! [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
|
5380 |
21581
6fab85c1538f
maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
5381 %!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
|
5382 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5383 */ |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
5384 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5385 DEFMETHOD (assignin, interp, args, , |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5386 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5387 @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
|
5388 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
|
5389 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
|
5390 @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
|
5391 @end deftypefn */) |
4297 | 5392 { |
5393 octave_value_list retval; | |
5394 | |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20798
diff
changeset
|
5395 if (args.length () != 3) |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5396 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5397 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5398 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
|
5399 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21740
diff
changeset
|
5400 octave::unwind_protect frame; |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5401 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5402 octave::call_stack& cs = interp.get_call_stack (); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5403 |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5404 if (context == "caller") |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5405 cs.goto_caller_frame (); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5406 else if (context == "base") |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5407 cs.goto_base_frame (); |
4297 | 5408 else |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5409 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
|
5410 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5411 frame.add_method (cs, &octave::call_stack::pop); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5412 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5413 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
|
5414 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5415 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
|
5416 { |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5417 // 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
|
5418 // 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
|
5419 // already been checked. |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5420 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5421 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
|
5422 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
|
5423 |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5424 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
|
5425 } |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5426 else |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5427 error ("assignin: invalid variable name in argument VARNAME"); |
4297 | 5428 |
5429 return retval; | |
5430 } | |
5431 | |
21369
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5432 /* |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5433 |
21581
6fab85c1538f
maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
5434 %!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
|
5435 |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5436 */ |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
5437 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5438 DEFMETHOD (evalin, interp, args, nargout, |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5439 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5440 @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
|
5441 @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
|
5442 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
|
5443 @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
|
5444 @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
|
5445 @end deftypefn */) |
4245 | 5446 { |
5447 octave_value_list retval; | |
5448 | |
5449 int nargin = args.length (); | |
5450 | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5451 if (nargin < 2) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5452 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5453 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5454 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
|
5455 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21740
diff
changeset
|
5456 octave::unwind_protect frame; |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5457 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5458 octave::call_stack& cs = interp.get_call_stack (); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5459 |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5460 if (context == "caller") |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5461 cs.goto_caller_frame (); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5462 else if (context == "base") |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5463 cs.goto_base_frame (); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5464 else |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5465 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
|
5466 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
5467 frame.add_method (cs, &octave::call_stack::pop); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5468 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5469 if (nargin > 2) |
4245 | 5470 { |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5471 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
|
5472 buffer_error_messages++; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5473 } |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5474 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5475 int parse_status = 0; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5476 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5477 bool execution_error = false; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5478 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5479 octave_value_list tmp; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5480 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5481 try |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5482 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5483 tmp = octave::eval_string (args(1), nargout > 0, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5484 parse_status, nargout); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5485 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
5486 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
|
5487 { |
23110
af48d8be62b3
move recover_from_exception and atexit functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23100
diff
changeset
|
5488 octave::interpreter::recover_from_exception (); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5489 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5490 execution_error = true; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5491 } |
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 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
|
5494 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5495 // 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
|
5496 // 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
|
5497 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5498 buffer_error_messages--; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5499 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5500 tmp = octave::eval_string (args(2), nargout > 0, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5501 parse_status, nargout); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5502 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5503 retval = (nargout > 0) ? tmp : octave_value_list (); |
4245 | 5504 } |
5505 else | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5506 { |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5507 if (nargout > 0) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5508 retval = tmp; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5509 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5510 // 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
|
5511 // 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
|
5512 // execution exception. |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5513 if (execution_error) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5514 octave_throw_execution_exception (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5515 } |
4245 | 5516 |
5517 return retval; | |
5518 } | |
5519 | |
22504
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5520 static void |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5521 maybe_print_last_error_message (bool *doit) |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5522 { |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5523 if (doit && *doit) |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5524 // 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
|
5525 // 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
|
5526 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
|
5527 last_error_message ().c_str ()); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5528 } |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5529 |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5530 static void |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5531 restore_octave_stdout (std::streambuf *buf) |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5532 { |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5533 octave_stdout.flush (); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5534 octave_stdout.rdbuf (buf); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5535 } |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5536 |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5537 static void |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5538 restore_octave_stderr (std::streambuf *buf) |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5539 { |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5540 std::cerr.flush (); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5541 std::cerr.rdbuf (buf); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5542 } |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5543 |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5544 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
|
5545 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
|
5546 @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
|
5547 @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
|
5548 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
|
5549 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
|
5550 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5551 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
|
5552 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5553 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
|
5554 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
|
5555 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
|
5556 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5557 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
|
5558 @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
|
5559 @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
|
5560 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
|
5561 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5562 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5563 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5564 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
|
5565 @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
|
5566 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
5567 @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
|
5568 @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
|
5569 @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
|
5570 @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
|
5571 @end deftypefn */) |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5572 { |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5573 int nargin = args.length (); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5574 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5575 if (nargin == 0 || nargin > 2) |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5576 print_usage (); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5577 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5578 // redirect stdout/stderr to capturing buffer |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5579 std::ostringstream buffer; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5580 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5581 std::ostream& out_stream = octave_stdout; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5582 std::ostream& err_stream = std::cerr; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5583 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5584 out_stream.flush (); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5585 err_stream.flush (); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5586 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5587 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
|
5588 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
|
5589 |
22504
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5590 bool eval_error_occurred = true; |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5591 |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5592 octave::unwind_protect frame; |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5593 |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5594 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
|
5595 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
|
5596 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
|
5597 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5598 // call standard eval function |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5599 octave_value_list retval; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5600 int eval_nargout = std::max (0, nargout - 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5601 |
22504
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5602 retval = Feval (args, eval_nargout); |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
5603 eval_error_occurred = false; |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5604 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5605 retval.prepend (buffer.str ()); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5606 return retval; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5607 } |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5608 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5609 /* |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5610 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5611 %!assert (evalc ("1"), "ans = 1\n") |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5612 %!assert (evalc ("1;"), "") |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5613 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5614 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5615 %! [s, y] = evalc ("1"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5616 %! assert (s, ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5617 %! assert (y, 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5618 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5619 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5620 %! [s, y] = evalc ("1;"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5621 %! assert (s, ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5622 %! assert (y, 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5623 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5624 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5625 %! assert (evalc ("y = 2"), "y = 2\n"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5626 %! assert (y, 2); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5627 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5628 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5629 %! assert (evalc ("y = 3;"), ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5630 %! assert (y, 3); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5631 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5632 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5633 %! [s, a, b] = evalc ("deal (1, 2)"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5634 %! assert (s, ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5635 %! assert (a, 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5636 %! assert (b, 2); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5637 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5638 %!function [a, b] = __f_evalc () |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5639 %! printf ("foo"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5640 %! fprintf (stdout, "bar"); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21416
diff
changeset
|
5641 %! disp (pi); |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5642 %! a = 1; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5643 %! b = 2; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5644 %!endfunction |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5645 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5646 %! [s, a, b] = evalc ("__f_evalc ()"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5647 %! assert (s, "foobar 3.1416\n"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5648 %! assert (a, 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5649 %! assert (b, 2); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5650 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5651 %!error <foo> (evalc ("error ('foo')")) |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5652 %!error <bar> (evalc ("error ('foo')", "error ('bar')")) |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5653 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5654 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5655 %! warning ("off", "quiet", "local"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5656 %! assert (evalc ("warning ('foo')"), "warning: foo\n"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5657 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5658 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5659 %! warning ("off", "quiet", "local"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5660 %! 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
|
5661 |
21581
6fab85c1538f
maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
5662 %!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
|
5663 |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5664 */ |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
5665 |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5666 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
|
5667 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
|
5668 @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
|
5669 @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
|
5670 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
|
5671 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
|
5672 @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
|
5673 @end deftypefn */) |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5674 { |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5675 octave_value retval; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5676 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5677 bool debug_flag = octave_debug; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5678 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5679 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
|
5680 "__parser_debug_flag__"); |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5681 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5682 octave_debug = debug_flag; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5683 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5684 return retval; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
5685 } |
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
|
5686 |
17377
15e2ad6372f7
maint: Tweaks to remove compiler warnings.
Rik <rik@octave.org>
parents:
17342
diff
changeset
|
5687 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
|
5688 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
|
5689 @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
|
5690 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
|
5691 @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
|
5692 { |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5693 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
|
5694 |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5695 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
|
5696 |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5697 if (nargin < 1 || nargin > 2) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5698 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5699 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5700 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
|
5701 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
5702 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
|
5703 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5704 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
|
5705 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5706 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
|
5707 || (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
|
5708 || (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
|
5709 { |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
5710 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
|
5711 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
|
5712 |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
5713 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
|
5714 if (pos != std::string::npos) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5715 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
|
5716 } |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5717 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5718 if (nargin == 2) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5719 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
|
5720 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5721 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
|
5722 true, false, false, |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5723 false, "__parse_file__"); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5724 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5725 if (fcn) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
5726 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
|
5727 |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
5728 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
|
5729 } |