Mercurial > octave
annotate libinterp/parse-tree/oct-parse.in.yy @ 16265:71ee3afedb69
5/10 commits reworking the lexer
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 11 Mar 2013 14:29:19 -0400 |
parents | 9acb86e6ac90 |
children | 36e01847694f c5e5f6ccac5d |
rev | line source |
---|---|
1829 | 1 /* |
1 | 2 |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14084
diff
changeset
|
3 Copyright (C) 1993-2012 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 |
1 | 6 |
7 This file is part of Octave. | |
8 | |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
7016 | 11 Free Software Foundation; either version 3 of the License, or (at your |
12 option) any later version. | |
1 | 13 |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
7016 | 20 along with Octave; see the file COPYING. If not, see |
21 <http://www.gnu.org/licenses/>. | |
1 | 22 |
23 */ | |
24 | |
25 // Parser for Octave. | |
26 | |
767 | 27 // C decarations. |
28 | |
1 | 29 %{ |
30 #define YYDEBUG 1 | |
31 | |
240 | 32 #ifdef HAVE_CONFIG_H |
1229 | 33 #include <config.h> |
240 | 34 #endif |
35 | |
3178 | 36 #include <cassert> |
10463
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
37 #include <cstdio> |
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
38 #include <cstdlib> |
2427 | 39 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
40 #include <iostream> |
5484 | 41 #include <map> |
5765 | 42 #include <sstream> |
5484 | 43 |
3928 | 44 #include "Cell.h" |
1 | 45 #include "Matrix.h" |
3021 | 46 #include "cmd-edit.h" |
47 #include "cmd-hist.h" | |
48 #include "file-ops.h" | |
49 #include "file-stat.h" | |
4243 | 50 #include "oct-env.h" |
3712 | 51 #include "oct-time.h" |
4171 | 52 #include "quit.h" |
1 | 53 |
3665 | 54 #include "comment-list.h" |
4243 | 55 #include "defaults.h" |
2166 | 56 #include "defun.h" |
4243 | 57 #include "dirfns.h" |
3021 | 58 #include "dynamic-ld.h" |
1351 | 59 #include "error.h" |
60 #include "input.h" | |
61 #include "lex.h" | |
5832 | 62 #include "load-path.h" |
1743 | 63 #include "oct-hist.h" |
5626 | 64 #include "oct-map.h" |
4935 | 65 #include "ov-fcn-handle.h" |
2970 | 66 #include "ov-usr-fcn.h" |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
67 #include "ov-null-mat.h" |
1670 | 68 #include "toplev.h" |
1351 | 69 #include "pager.h" |
70 #include "parse.h" | |
14329
8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents:
14294
diff
changeset
|
71 #include "parse-private.h" |
2987 | 72 #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
|
73 #include "pt-eval.h" |
1351 | 74 #include "symtab.h" |
75 #include "token.h" | |
3021 | 76 #include "unwind-prot.h" |
1 | 77 #include "utils.h" |
1351 | 78 #include "variables.h" |
1 | 79 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
80 // oct-parse.h must be included after pt-all.h |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
81 #include <oct-parse.h> |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
82 |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
83 extern int octave_lex (YYSTYPE *, void *); |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
84 |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
85 // Global access to currently active lexer. |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
86 // FIXME -- to be removed after more parser+lexer refactoring. |
16158
7eb614760ddb
rename lexical_feedback to octave_lexer
John W. Eaton <jwe@octave.org>
parents:
16157
diff
changeset
|
87 octave_lexer *CURR_LEXER = 0; |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
88 |
10426
4db7beace28e
oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents:
10411
diff
changeset
|
89 #if defined (GNULIB_NAMESPACE) |
4db7beace28e
oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents:
10411
diff
changeset
|
90 // Calls to the following functions appear in the generated output from |
4db7beace28e
oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents:
10411
diff
changeset
|
91 // Bison without the namespace tag. Redefine them so we will use them |
4db7beace28e
oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents:
10411
diff
changeset
|
92 // via the gnulib namespace. |
4db7beace28e
oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents:
10411
diff
changeset
|
93 #define fclose GNULIB_NAMESPACE::fclose |
4db7beace28e
oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents:
10411
diff
changeset
|
94 #define fprintf GNULIB_NAMESPACE::fprintf |
4db7beace28e
oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents:
10411
diff
changeset
|
95 #define malloc GNULIB_NAMESPACE::malloc |
4db7beace28e
oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents:
10411
diff
changeset
|
96 #endif |
4db7beace28e
oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents:
10411
diff
changeset
|
97 |
3021 | 98 // TRUE means we printed messages about reading startup files. |
99 bool reading_startup_message_printed = false; | |
100 | |
3903 | 101 // Keep track of symbol table information when parsing functions. |
14329
8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents:
14294
diff
changeset
|
102 symtab_context parser_symtab_context; |
4238 | 103 |
5484 | 104 // List of autoloads (function -> file mapping). |
105 static std::map<std::string, std::string> autoload_map; | |
106 | |
496 | 107 // Forward declarations for some functions defined at the bottom of |
108 // the file. | |
109 | |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
110 static void yyerror (octave_parser& curr_parser, const char *s); |
1 | 111 |
8448
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
112 // Finish building a statement. |
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
113 template <class T> |
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
114 static tree_statement * |
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
115 make_statement (T *arg) |
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
116 { |
8471
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
117 octave_comment_list *comment = octave_comment_buffer::get_comment (); |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
118 |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
119 return new tree_statement (arg, comment); |
8448
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
120 } |
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
121 |
1 | 122 #define ABORT_PARSE \ |
123 do \ | |
124 { \ | |
125 yyerrok; \ | |
14329
8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents:
14294
diff
changeset
|
126 if (! parser_symtab_context.empty ()) \ |
8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents:
14294
diff
changeset
|
127 parser_symtab_context.pop (); \ |
14584
3a10d5bdada8
src/symtab.yy (ABORT_PARSE): Prevent multiple parse errors in eval (bug #35154)
Max Brister <max@2bass.com>
parents:
14544
diff
changeset
|
128 if ((interactive || forced_interactive) \ |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
129 && ! (curr_lexer)->input_from_eval_string ()) \ |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
130 YYACCEPT; \ |
1 | 131 else \ |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
132 YYABORT; \ |
1 | 133 } \ |
134 while (0) | |
135 | |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
136 #define curr_lexer curr_parser.curr_lexer |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
137 #define scanner curr_lexer->scanner |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
138 |
1 | 139 %} |
140 | |
666 | 141 // Bison declarations. |
142 | |
4813 | 143 // Don't add spaces around the = here; it causes some versions of |
144 // bison to fail to properly recognize the directive. | |
145 | |
146 %name-prefix="octave_" | |
4753 | 147 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
148 // 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
|
149 // 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
|
150 // 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
|
151 // 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
|
152 // 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
|
153 // 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
|
154 // 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
|
155 // 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
|
156 |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
157 %define api.pure |
16174
39096b290a2f
check syntax used to enable bison push/pull parser
John W. Eaton <jwe@octave.org>
parents:
16167
diff
changeset
|
158 %PUSH_PULL_DECL% |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
159 %parse-param { octave_parser& curr_parser } |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
160 %lex-param { void *scanner } |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
161 |
1 | 162 %union |
163 { | |
2891 | 164 // The type of the basic tokens returned by the lexer. |
143 | 165 token *tok_val; |
166 | |
3665 | 167 // Comment strings that we need to deal with mid-rule. |
168 octave_comment_list *comment_type; | |
169 | |
2891 | 170 // Types for the nonterminals we generate. |
2525 | 171 char sep_type; |
1 | 172 tree *tree_type; |
1829 | 173 tree_matrix *tree_matrix_type; |
3351 | 174 tree_cell *tree_cell_type; |
496 | 175 tree_expression *tree_expression_type; |
2375 | 176 tree_constant *tree_constant_type; |
4342 | 177 tree_fcn_handle *tree_fcn_handle_type; |
5861 | 178 tree_anon_fcn_handle *tree_anon_fcn_handle_type; |
1 | 179 tree_identifier *tree_identifier_type; |
180 tree_index_expression *tree_index_expression_type; | |
181 tree_colon_expression *tree_colon_expression_type; | |
182 tree_argument_list *tree_argument_list_type; | |
183 tree_parameter_list *tree_parameter_list_type; | |
184 tree_command *tree_command_type; | |
185 tree_if_command *tree_if_command_type; | |
578 | 186 tree_if_clause *tree_if_clause_type; |
187 tree_if_command_list *tree_if_command_list_type; | |
2764 | 188 tree_switch_command *tree_switch_command_type; |
189 tree_switch_case *tree_switch_case_type; | |
190 tree_switch_case_list *tree_switch_case_list_type; | |
2846 | 191 tree_decl_elt *tree_decl_elt_type; |
192 tree_decl_init_list *tree_decl_init_list_type; | |
193 tree_decl_command *tree_decl_command_type; | |
578 | 194 tree_statement *tree_statement_type; |
195 tree_statement_list *tree_statement_list_type; | |
2891 | 196 octave_user_function *octave_user_function_type; |
9476 | 197 void *dummy_type; |
1 | 198 } |
199 | |
143 | 200 // Tokens with line and column information. |
201 %token <tok_val> '=' ':' '-' '+' '*' '/' | |
4018 | 202 %token <tok_val> ADD_EQ SUB_EQ MUL_EQ DIV_EQ LEFTDIV_EQ POW_EQ |
203 %token <tok_val> EMUL_EQ EDIV_EQ ELEFTDIV_EQ EPOW_EQ AND_EQ OR_EQ | |
2899 | 204 %token <tok_val> LSHIFT_EQ RSHIFT_EQ LSHIFT RSHIFT |
428 | 205 %token <tok_val> EXPR_AND_AND EXPR_OR_OR |
143 | 206 %token <tok_val> EXPR_AND EXPR_OR EXPR_NOT |
207 %token <tok_val> EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT | |
1276 | 208 %token <tok_val> LEFTDIV EMUL EDIV ELEFTDIV EPLUS EMINUS |
209 %token <tok_val> QUOTE TRANSPOSE | |
143 | 210 %token <tok_val> PLUS_PLUS MINUS_MINUS POW EPOW |
211 %token <tok_val> NUM IMAG_NUM | |
2970 | 212 %token <tok_val> STRUCT_ELT |
2883 | 213 %token <tok_val> NAME |
143 | 214 %token <tok_val> END |
5279 | 215 %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
|
216 %token <tok_val> FOR PARFOR WHILE DO UNTIL |
1491 | 217 %token <tok_val> IF ELSEIF ELSE |
2764 | 218 %token <tok_val> SWITCH CASE OTHERWISE |
1491 | 219 %token <tok_val> BREAK CONTINUE FUNC_RET |
924 | 220 %token <tok_val> UNWIND CLEANUP |
1489 | 221 %token <tok_val> TRY CATCH |
14294
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14293
diff
changeset
|
222 %token <tok_val> GLOBAL PERSISTENT |
4342 | 223 %token <tok_val> FCN_HANDLE |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
224 %token <tok_val> PROPERTIES METHODS EVENTS ENUMERATION |
9476 | 225 %token <tok_val> METAQUERY |
226 %token <tok_val> SUPERCLASSREF | |
227 %token <tok_val> GET SET | |
1 | 228 |
143 | 229 // Other tokens. |
2970 | 230 %token END_OF_INPUT LEXICAL_ERROR |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
231 %token FCN INPUT_FILE CLASSDEF |
7587
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7562
diff
changeset
|
232 // %token VARARGIN VARARGOUT |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
233 %token CHOOSE_ASSIGNMENT |
1 | 234 |
143 | 235 // Nonterminals we construct. |
9476 | 236 %type <comment_type> stash_comment function_beg classdef_beg |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
237 %type <comment_type> properties_beg methods_beg events_beg enum_beg |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
238 %type <sep_type> sep_no_nl opt_sep_no_nl nl opt_nl sep opt_sep |
578 | 239 %type <tree_type> input |
5861 | 240 %type <tree_constant_type> string constant magic_colon |
241 %type <tree_anon_fcn_handle_type> anon_fcn_handle | |
4342 | 242 %type <tree_fcn_handle_type> fcn_handle |
3351 | 243 %type <tree_matrix_type> matrix_rows matrix_rows1 |
244 %type <tree_cell_type> cell_rows cell_rows1 | |
5102 | 245 %type <tree_expression_type> matrix cell |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
246 %type <tree_expression_type> primary_expr oper_expr |
4207 | 247 %type <tree_expression_type> simple_expr colon_expr assign_expr expression |
10206
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10188
diff
changeset
|
248 %type <tree_identifier_type> identifier fcn_name magic_tilde |
9476 | 249 %type <tree_identifier_type> superclass_identifier meta_identifier |
250 %type <octave_user_function_type> function1 function2 classdef1 | |
2970 | 251 %type <tree_index_expression_type> word_list_cmd |
252 %type <tree_colon_expression_type> colon_expr1 | |
3351 | 253 %type <tree_argument_list_type> arg_list word_list assign_lhs |
254 %type <tree_argument_list_type> cell_or_matrix_row | |
4935 | 255 %type <tree_parameter_list_type> param_list param_list1 param_list2 |
723 | 256 %type <tree_parameter_list_type> return_list return_list1 |
9476 | 257 %type <tree_parameter_list_type> superclasses opt_superclasses |
2970 | 258 %type <tree_command_type> command select_command loop_command |
9476 | 259 %type <tree_command_type> jump_command except_command function |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
260 %type <tree_command_type> file classdef |
578 | 261 %type <tree_if_command_type> if_command |
262 %type <tree_if_clause_type> elseif_clause else_clause | |
263 %type <tree_if_command_list_type> if_cmd_list1 if_cmd_list | |
2764 | 264 %type <tree_switch_command_type> switch_command |
265 %type <tree_switch_case_type> switch_case default_case | |
266 %type <tree_switch_case_list_type> case_list1 case_list | |
2846 | 267 %type <tree_decl_elt_type> decl2 |
268 %type <tree_decl_init_list_type> decl1 | |
269 %type <tree_decl_command_type> declaration | |
9476 | 270 %type <tree_statement_type> statement function_end classdef_end |
627 | 271 %type <tree_statement_list_type> simple_list simple_list1 list list1 |
7336 | 272 %type <tree_statement_list_type> opt_list input1 |
9476 | 273 // These types need to be specified. |
274 %type <dummy_type> attr | |
275 %type <dummy_type> class_event | |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
276 %type <dummy_type> class_enum |
9476 | 277 %type <dummy_type> class_property |
278 %type <dummy_type> properties_list | |
279 %type <dummy_type> properties_block | |
280 %type <dummy_type> methods_list | |
281 %type <dummy_type> methods_block | |
282 %type <dummy_type> opt_attr_list | |
283 %type <dummy_type> attr_list | |
284 %type <dummy_type> events_list | |
285 %type <dummy_type> events_block | |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
286 %type <dummy_type> enum_list |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
287 %type <dummy_type> enum_block |
9476 | 288 %type <dummy_type> class_body |
1 | 289 |
143 | 290 // Precedence and associativity. |
4018 | 291 %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 LSHIFT_EQ RSHIFT_EQ |
4023 | 292 %left EXPR_OR_OR |
293 %left EXPR_AND_AND | |
294 %left EXPR_OR | |
295 %left EXPR_AND | |
1 | 296 %left EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT |
2899 | 297 %left LSHIFT RSHIFT |
1 | 298 %left ':' |
1276 | 299 %left '-' '+' EPLUS EMINUS |
1 | 300 %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
|
301 %right UNARY EXPR_NOT |
5667 | 302 %left POW EPOW QUOTE TRANSPOSE |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
303 %right PLUS_PLUS MINUS_MINUS |
3351 | 304 %left '(' '.' '{' |
1 | 305 |
143 | 306 // Where to start. |
1 | 307 %start input |
308 | |
309 %% | |
310 | |
2970 | 311 // ============================== |
312 // Statements and statement lists | |
313 // ============================== | |
314 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
315 input : input1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
316 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
317 curr_parser.stmt_list = $1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
318 YYACCEPT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
319 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
320 | simple_list parse_error |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
321 { ABORT_PARSE; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
322 | parse_error |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
323 { ABORT_PARSE; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
324 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
325 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
326 input1 : '\n' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
327 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
328 | END_OF_INPUT |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
329 { |
16164
c5bfdc4c0963
move end_of_input flag from octve_parser class to octave_lexer class
John W. Eaton <jwe@octave.org>
parents:
16158
diff
changeset
|
330 curr_lexer->end_of_input = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
331 $$ = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
332 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
333 | simple_list |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
334 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
335 | simple_list '\n' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
336 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
337 | simple_list END_OF_INPUT |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
338 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
339 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
340 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
341 simple_list : simple_list1 opt_sep_no_nl |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
342 { $$ = curr_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
|
343 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
344 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
345 simple_list1 : statement |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
346 { $$ = curr_parser.make_statement_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
347 | simple_list1 sep_no_nl statement |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
348 { $$ = curr_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
|
349 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
350 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
351 opt_list : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
352 { $$ = new tree_statement_list (); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
353 | list |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
354 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
355 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
356 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
357 list : list1 opt_sep |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
358 { $$ = curr_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
|
359 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
360 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
361 list1 : statement |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
362 { $$ = curr_parser.make_statement_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
363 | list1 sep statement |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
364 { $$ = curr_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
|
365 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
366 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
367 statement : expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
368 { $$ = make_statement ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
369 | command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
370 { $$ = make_statement ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
371 | word_list_cmd |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
372 { $$ = make_statement ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
373 ; |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
374 |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
375 // ================= |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
376 // Word-list command |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
377 // ================= |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
378 |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
379 // 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
|
380 // 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
|
381 // WHILE, etc. |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
382 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
383 word_list_cmd : identifier word_list |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
384 { $$ = curr_parser.make_index_expression ($1, $2, '('); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
385 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
386 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
387 word_list : string |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
388 { $$ = new tree_argument_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
389 | word_list string |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
390 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
391 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
392 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
393 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
394 ; |
1 | 395 |
2970 | 396 // =========== |
397 // Expressions | |
398 // =========== | |
399 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
400 identifier : NAME |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
401 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
402 symbol_table::symbol_record *sr = $1->sym_rec (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
403 $$ = new tree_identifier (*sr, $1->line (), $1->column ()); |
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 ; |
2970 | 406 |
9476 | 407 superclass_identifier |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
408 : SUPERCLASSREF |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
409 { $$ = new tree_identifier ($1->line (), $1->column ()); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
410 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
411 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
412 meta_identifier : METAQUERY |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
413 { $$ = new tree_identifier ($1->line (), $1->column ()); } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
414 ; |
10315
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 string : DQ_STRING |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
417 { $$ = curr_parser.make_constant (DQ_STRING, $1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
418 | SQ_STRING |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
419 { $$ = curr_parser.make_constant (SQ_STRING, $1); } |
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 constant : NUM |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
423 { $$ = curr_parser.make_constant (NUM, $1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
424 | IMAG_NUM |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
425 { $$ = curr_parser.make_constant (IMAG_NUM, $1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
426 | string |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
427 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
428 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
429 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
430 matrix : '[' ']' |
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 $$ = new tree_constant (octave_null_matrix::instance); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
433 curr_lexer->pending_local_variables.clear (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
434 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
435 | '[' ';' ']' |
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 $$ = new tree_constant (octave_null_matrix::instance); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
438 curr_lexer->pending_local_variables.clear (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
439 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
440 | '[' ',' ']' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
441 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
442 $$ = new tree_constant (octave_null_matrix::instance); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
443 curr_lexer->pending_local_variables.clear (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
444 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
445 | '[' matrix_rows ']' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
446 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
447 $$ = curr_parser.finish_matrix ($2); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
448 curr_lexer->pending_local_variables.clear (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
449 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
450 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
451 |
16251
37af399267b2
undo previous change to add optional semicolon non-terminal in the parser
John W. Eaton <jwe@octave.org>
parents:
16238
diff
changeset
|
452 matrix_rows : matrix_rows1 |
37af399267b2
undo previous change to add optional semicolon non-terminal in the parser
John W. Eaton <jwe@octave.org>
parents:
16238
diff
changeset
|
453 { $$ = $1; } |
37af399267b2
undo previous change to add optional semicolon non-terminal in the parser
John W. Eaton <jwe@octave.org>
parents:
16238
diff
changeset
|
454 | matrix_rows1 ';' // Ignore trailing semicolon. |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
455 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
456 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
457 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
458 matrix_rows1 : cell_or_matrix_row |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
459 { $$ = new tree_matrix ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
460 | matrix_rows1 ';' cell_or_matrix_row |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
461 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
462 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
463 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
464 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
465 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
466 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
467 cell : '{' '}' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
468 { $$ = new tree_constant (octave_value (Cell ())); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
469 | '{' ';' '}' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
470 { $$ = new tree_constant (octave_value (Cell ())); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
471 | '{' cell_rows '}' |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
472 { $$ = curr_parser.finish_cell ($2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
473 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
474 |
16251
37af399267b2
undo previous change to add optional semicolon non-terminal in the parser
John W. Eaton <jwe@octave.org>
parents:
16238
diff
changeset
|
475 cell_rows : cell_rows1 |
37af399267b2
undo previous change to add optional semicolon non-terminal in the parser
John W. Eaton <jwe@octave.org>
parents:
16238
diff
changeset
|
476 { $$ = $1; } |
37af399267b2
undo previous change to add optional semicolon non-terminal in the parser
John W. Eaton <jwe@octave.org>
parents:
16238
diff
changeset
|
477 | cell_rows1 ';' // Ignore trailing semicolon. |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
478 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
479 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
480 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
481 cell_rows1 : cell_or_matrix_row |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
482 { $$ = new tree_cell ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
483 | cell_rows1 ';' cell_or_matrix_row |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
484 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
485 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
486 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
487 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
488 ; |
3351 | 489 |
490 cell_or_matrix_row | |
16251
37af399267b2
undo previous change to add optional semicolon non-terminal in the parser
John W. Eaton <jwe@octave.org>
parents:
16238
diff
changeset
|
491 : arg_list |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
492 { $$ = $1; } |
16251
37af399267b2
undo previous change to add optional semicolon non-terminal in the parser
John W. Eaton <jwe@octave.org>
parents:
16238
diff
changeset
|
493 | arg_list ',' // Ignore trailing comma. |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
494 { $$ = $1; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
495 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
496 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
497 fcn_handle : '@' FCN_HANDLE |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
498 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
499 $$ = curr_parser.make_fcn_handle ($2); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
500 curr_lexer->looking_at_function_handle--; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
501 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
502 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
503 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
504 anon_fcn_handle : '@' param_list statement |
16265
71ee3afedb69
5/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16263
diff
changeset
|
505 { |
71ee3afedb69
5/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16263
diff
changeset
|
506 $$ = curr_parser.make_anon_fcn_handle ($2, $3); |
71ee3afedb69
5/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16263
diff
changeset
|
507 curr_lexer->nesting_level.remove (); |
71ee3afedb69
5/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16263
diff
changeset
|
508 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
509 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
510 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
511 primary_expr : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
512 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
513 | constant |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
514 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
515 | fcn_handle |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
516 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
517 | matrix |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
518 { |
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
519 curr_lexer->looking_at_matrix_or_assign_lhs = false; |
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
520 $$ = $1; |
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
521 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
522 | cell |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
523 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
524 | meta_identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
525 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
526 | superclass_identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
527 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
528 | '(' expression ')' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
529 { $$ = $2->mark_in_parens (); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
530 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
531 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
532 magic_colon : ':' |
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 octave_value tmp (octave_value::magic_colon_t); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
535 $$ = new tree_constant (tmp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
536 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
537 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
538 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
539 magic_tilde : EXPR_NOT |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
540 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
541 $$ = new tree_black_hole (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
542 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
543 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
544 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
545 arg_list : expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
546 { $$ = new tree_argument_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
547 | magic_colon |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
548 { $$ = new tree_argument_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
549 | magic_tilde |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
550 { $$ = new tree_argument_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
551 | arg_list ',' magic_colon |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
552 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
553 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
554 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
555 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
556 | arg_list ',' magic_tilde |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
557 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
558 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
559 $$ = $1; |
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 | arg_list ',' expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
562 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
563 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
564 $$ = $1; |
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 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
567 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
568 indirect_ref_op : '.' |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
569 { curr_lexer->looking_at_indirect_ref = true; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
570 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
571 |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
572 oper_expr : primary_expr |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
573 { $$ = $1; } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
574 | oper_expr PLUS_PLUS |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
575 { $$ = curr_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
|
576 | oper_expr MINUS_MINUS |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
577 { $$ = curr_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
|
578 | oper_expr '(' ')' |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
579 { $$ = curr_parser.make_index_expression ($1, 0, '('); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
580 | oper_expr '(' arg_list ')' |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
581 { $$ = curr_parser.make_index_expression ($1, $3, '('); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
582 | oper_expr '{' '}' |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
583 { $$ = curr_parser.make_index_expression ($1, 0, '{'); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
584 | oper_expr '{' arg_list '}' |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
585 { $$ = curr_parser.make_index_expression ($1, $3, '{'); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
586 | oper_expr QUOTE |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
587 { $$ = curr_parser.make_postfix_op (QUOTE, $1, $2); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
588 | oper_expr TRANSPOSE |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
589 { $$ = curr_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
|
590 | oper_expr indirect_ref_op STRUCT_ELT |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
591 { $$ = curr_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
|
592 | oper_expr indirect_ref_op '(' expression ')' |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
593 { $$ = curr_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
|
594 | PLUS_PLUS oper_expr %prec UNARY |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
595 { $$ = curr_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
|
596 | MINUS_MINUS oper_expr %prec UNARY |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
597 { $$ = curr_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
|
598 | EXPR_NOT oper_expr %prec UNARY |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
599 { $$ = curr_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
|
600 | '+' oper_expr %prec UNARY |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
601 { $$ = curr_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
|
602 | '-' oper_expr %prec UNARY |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
603 { $$ = curr_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
|
604 | oper_expr POW oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
605 { $$ = curr_parser.make_binary_op (POW, $1, $2, $3); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
606 | oper_expr EPOW oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
607 { $$ = curr_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
|
608 | oper_expr '+' oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
609 { $$ = curr_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
|
610 | oper_expr '-' oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
611 { $$ = curr_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
|
612 | oper_expr '*' oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
613 { $$ = curr_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
|
614 | oper_expr '/' oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
615 { $$ = curr_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
|
616 | oper_expr EPLUS oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
617 { $$ = curr_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
|
618 | oper_expr EMINUS oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
619 { $$ = curr_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
|
620 | oper_expr EMUL oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
621 { $$ = curr_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
|
622 | oper_expr EDIV oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
623 { $$ = curr_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
|
624 | oper_expr LEFTDIV oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
625 { $$ = curr_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
|
626 | oper_expr ELEFTDIV oper_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
627 { $$ = curr_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
|
628 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
629 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
630 colon_expr : colon_expr1 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
631 { $$ = curr_parser.finish_colon_expression ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
632 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
633 |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
634 colon_expr1 : oper_expr |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
635 { $$ = new tree_colon_expression ($1); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
636 | colon_expr1 ':' oper_expr |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
637 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
638 if (! ($$ = $1->append ($3))) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
639 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
640 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
641 ; |
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 simple_expr : colon_expr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
644 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
645 | simple_expr LSHIFT simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
646 { $$ = curr_parser.make_binary_op (LSHIFT, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
647 | simple_expr RSHIFT simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
648 { $$ = curr_parser.make_binary_op (RSHIFT, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
649 | simple_expr EXPR_LT simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
650 { $$ = curr_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
|
651 | simple_expr EXPR_LE simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
652 { $$ = curr_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
|
653 | simple_expr EXPR_EQ simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
654 { $$ = curr_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
|
655 | simple_expr EXPR_GE simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
656 { $$ = curr_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
|
657 | simple_expr EXPR_GT simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
658 { $$ = curr_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
|
659 | simple_expr EXPR_NE simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
660 { $$ = curr_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
|
661 | simple_expr EXPR_AND simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
662 { $$ = curr_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
|
663 | simple_expr EXPR_OR simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
664 { $$ = curr_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
|
665 | simple_expr EXPR_AND_AND simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
666 { $$ = curr_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
|
667 | simple_expr EXPR_OR_OR simple_expr |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
668 { $$ = curr_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
|
669 ; |
2970 | 670 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
671 assign_lhs : simple_expr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
672 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
673 $$ = new tree_argument_list ($1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
674 $$->mark_as_simple_assign_lhs (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
675 } |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
676 | matrix CHOOSE_ASSIGNMENT |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
677 { |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
678 tree_matrix *tmp = dynamic_cast<tree_matrix *> ($1); |
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
679 $$ = tmp->front (); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
680 curr_lexer->looking_at_matrix_or_assign_lhs = false; |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
681 for (std::set<std::string>::const_iterator p = curr_lexer->pending_local_variables.begin (); |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
682 p != curr_lexer->pending_local_variables.end (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
683 p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
684 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
685 symbol_table::force_variable (*p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
686 } |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
687 curr_lexer->pending_local_variables.clear (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
688 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
689 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
690 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
691 assign_expr : assign_lhs '=' expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
692 { $$ = curr_parser.make_assign_op ('=', $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
693 | assign_lhs ADD_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
694 { $$ = curr_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
|
695 | assign_lhs SUB_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
696 { $$ = curr_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
|
697 | assign_lhs MUL_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
698 { $$ = curr_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
|
699 | assign_lhs DIV_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
700 { $$ = curr_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
|
701 | assign_lhs LEFTDIV_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
702 { $$ = curr_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
|
703 | assign_lhs POW_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
704 { $$ = curr_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
|
705 | assign_lhs LSHIFT_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
706 { $$ = curr_parser.make_assign_op (LSHIFT_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
707 | assign_lhs RSHIFT_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
708 { $$ = curr_parser.make_assign_op (RSHIFT_EQ, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
709 | assign_lhs EMUL_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
710 { $$ = curr_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
|
711 | assign_lhs EDIV_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
712 { $$ = curr_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
|
713 | assign_lhs ELEFTDIV_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
714 { $$ = curr_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
|
715 | assign_lhs EPOW_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
716 { $$ = curr_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
|
717 | assign_lhs AND_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
718 { $$ = curr_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
|
719 | assign_lhs OR_EQ expression |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
720 { $$ = curr_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
|
721 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
722 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
723 expression : simple_expr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
724 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
725 | assign_expr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
726 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
727 | anon_fcn_handle |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
728 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
729 ; |
2970 | 730 |
731 // ================================================ | |
732 // Commands, declarations, and function definitions | |
733 // ================================================ | |
734 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
735 command : declaration |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
736 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
737 | select_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
738 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
739 | loop_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
740 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
741 | jump_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
742 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
743 | except_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
744 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
745 | function |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
746 { $$ = $1; } |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
747 | file |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
748 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
749 | classdef |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
750 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
751 ; |
2970 | 752 |
753 // ===================== | |
754 // Declaration statemnts | |
755 // ===================== | |
756 | |
16263
9acb86e6ac90
4/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16259
diff
changeset
|
757 declaration : GLOBAL decl1 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
758 { |
16263
9acb86e6ac90
4/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16259
diff
changeset
|
759 $$ = curr_parser.make_decl_command (GLOBAL, $1, $2); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
760 curr_lexer->looking_at_decl_list = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
761 } |
16263
9acb86e6ac90
4/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16259
diff
changeset
|
762 | PERSISTENT decl1 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
763 { |
16263
9acb86e6ac90
4/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16259
diff
changeset
|
764 $$ = curr_parser.make_decl_command (PERSISTENT, $1, $2); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
765 curr_lexer->looking_at_decl_list = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
766 } |
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 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
769 decl1 : decl2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
770 { $$ = new tree_decl_init_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
771 | decl1 decl2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
772 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
773 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
774 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
775 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
776 ; |
2970 | 777 |
7634
ae90e05ad299
fix parameter list initializer bug
John W. Eaton <jwe@octave.org>
parents:
7587
diff
changeset
|
778 decl_param_init : // empty |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
779 { curr_lexer->looking_at_initializer_expression = true; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
780 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
781 decl2 : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
782 { $$ = new tree_decl_elt ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
783 | identifier '=' decl_param_init expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
784 { |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
785 curr_lexer->looking_at_initializer_expression = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
786 $$ = new tree_decl_elt ($1, $4); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
787 } |
10206
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10188
diff
changeset
|
788 | magic_tilde |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10188
diff
changeset
|
789 { |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10188
diff
changeset
|
790 $$ = new tree_decl_elt ($1); |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10188
diff
changeset
|
791 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
792 ; |
2970 | 793 |
794 // ==================== | |
795 // Selection statements | |
796 // ==================== | |
797 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
798 select_command : if_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
799 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
800 | switch_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
801 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
802 ; |
2970 | 803 |
804 // ============ | |
805 // If statement | |
806 // ============ | |
807 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
808 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
|
809 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
810 if (! ($$ = curr_parser.finish_if_command ($1, $3, $4, $2))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
811 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
812 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
813 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
814 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
815 if_cmd_list : if_cmd_list1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
816 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
817 | if_cmd_list1 else_clause |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
818 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
819 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
820 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
821 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
822 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
823 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
824 if_cmd_list1 : expression opt_sep opt_list |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
825 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
826 $1->mark_braindead_shortcircuit (curr_lexer->fcn_file_full_name); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
827 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
828 $$ = curr_parser.start_if_command ($1, $3); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
829 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
830 | if_cmd_list1 elseif_clause |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
831 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
832 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
833 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
834 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
835 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
836 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
837 elseif_clause : ELSEIF stash_comment opt_sep expression opt_sep opt_list |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
838 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
839 $4->mark_braindead_shortcircuit (curr_lexer->fcn_file_full_name); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
840 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
841 $$ = curr_parser.make_elseif_clause ($1, $4, $6, $2); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
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 else_clause : ELSE stash_comment opt_sep opt_list |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
846 { $$ = new tree_if_clause ($4, $2); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
847 ; |
2970 | 848 |
849 // ================ | |
850 // Switch statement | |
851 // ================ | |
852 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
853 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
|
854 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
855 if (! ($$ = curr_parser.finish_switch_command ($1, $3, $5, $6, $2))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
856 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
857 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
858 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
859 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
860 case_list : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
861 { $$ = new tree_switch_case_list (); } |
11317
2da532d0f41c
accept otherwise clause in switch statement without preceding case statements
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
862 | default_case |
2da532d0f41c
accept otherwise clause in switch statement without preceding case statements
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
863 { $$ = new tree_switch_case_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
864 | case_list1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
865 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
866 | case_list1 default_case |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
867 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
868 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
869 $$ = $1; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
870 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
871 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
872 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
873 case_list1 : switch_case |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
874 { $$ = new tree_switch_case_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
875 | case_list1 switch_case |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
876 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
877 $1->append ($2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
878 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
879 } |
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 switch_case : CASE stash_comment opt_sep expression opt_sep opt_list |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
883 { $$ = curr_parser.make_switch_case ($1, $4, $6, $2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
884 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
885 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
886 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
|
887 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
888 $$ = new tree_switch_case ($4, $2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
889 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
890 ; |
2970 | 891 |
892 // ======= | |
893 // Looping | |
894 // ======= | |
895 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
896 loop_command : WHILE stash_comment expression opt_sep opt_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
897 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
898 $3->mark_braindead_shortcircuit (curr_lexer->fcn_file_full_name); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
899 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
900 if (! ($$ = curr_parser.make_while_command ($1, $3, $5, $6, $2))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
901 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
902 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
903 | 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
|
904 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
905 if (! ($$ = curr_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
|
906 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
907 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
908 | 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
|
909 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
910 if (! ($$ = curr_parser.make_for_command (FOR, $1, $3, $5, 0, |
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
|
911 $7, $8, $2))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
912 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
913 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
914 | 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
|
915 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
916 if (! ($$ = curr_parser.make_for_command (FOR, $1, $4, $6, 0, |
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
|
917 $9, $10, $2))) |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
918 ABORT_PARSE; |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
919 } |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
920 | PARFOR stash_comment assign_lhs '=' 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
|
921 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
922 if (! ($$ = curr_parser.make_for_command (PARFOR, $1, $3, $5, |
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
|
923 0, $7, $8, $2))) |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
924 ABORT_PARSE; |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
925 } |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
926 | 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
|
927 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
928 if (! ($$ = curr_parser.make_for_command (PARFOR, $1, $4, $6, |
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
|
929 $8, $11, $12, $2))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
930 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
931 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
932 ; |
2970 | 933 |
934 // ======= | |
935 // Jumping | |
936 // ======= | |
937 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
938 jump_command : BREAK |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
939 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
940 if (! ($$ = curr_parser.make_break_command ($1))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
941 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
942 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
943 | CONTINUE |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
944 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
945 if (! ($$ = curr_parser.make_continue_command ($1))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
946 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
947 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
948 | FUNC_RET |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
949 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
950 if (! ($$ = curr_parser.make_return_command ($1))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
951 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
952 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
953 ; |
2970 | 954 |
955 // ========== | |
956 // Exceptions | |
957 // ========== | |
958 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
959 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
|
960 stash_comment opt_sep opt_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
961 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
962 if (! ($$ = curr_parser.make_unwind_command ($1, $4, $8, $9, $2, $6))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
963 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
964 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
965 | TRY stash_comment opt_sep opt_list CATCH |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
966 stash_comment opt_sep opt_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
967 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
968 if (! ($$ = curr_parser.make_try_command ($1, $4, $8, $9, $2, $6))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
969 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
970 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
971 | TRY stash_comment opt_sep opt_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
972 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
973 if (! ($$ = curr_parser.make_try_command ($1, $4, 0, $5, $2, 0))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
974 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
975 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
976 ; |
2970 | 977 |
978 // =========================================== | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
979 // Some 'subroutines' for function definitions |
2970 | 980 // =========================================== |
981 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
982 push_fcn_symtab : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
983 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
984 curr_parser.curr_fcn_depth++; |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
985 |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
986 if (curr_parser.max_fcn_depth < curr_parser.curr_fcn_depth) |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
987 curr_parser.max_fcn_depth = curr_parser.curr_fcn_depth; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
988 |
14329
8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents:
14294
diff
changeset
|
989 parser_symtab_context.push (); |
8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents:
14294
diff
changeset
|
990 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
991 symbol_table::set_scope (symbol_table::alloc_scope ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
992 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
993 curr_parser.function_scopes.push_back (symbol_table::current_scope ()); |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
994 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
995 if (! curr_lexer->reading_script_file |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
996 && curr_parser.curr_fcn_depth == 1 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
997 && ! curr_parser.parsing_subfunctions) |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
998 curr_parser.primary_fcn_scope = symbol_table::current_scope (); |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
999 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1000 if (curr_lexer->reading_script_file |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1001 && curr_parser.curr_fcn_depth > 1) |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1002 curr_parser.bison_error ("nested functions not implemented in this context"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1003 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1004 ; |
2970 | 1005 |
1006 // =========================== | |
1007 // List of function parameters | |
1008 // =========================== | |
1009 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1010 param_list_beg : '(' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1011 { |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1012 curr_lexer->looking_at_parameter_list = true; |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1013 |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1014 if (curr_lexer->looking_at_function_handle) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1015 { |
14329
8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents:
14294
diff
changeset
|
1016 parser_symtab_context.push (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1017 symbol_table::set_scope (symbol_table::alloc_scope ()); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1018 curr_lexer->looking_at_function_handle--; |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1019 curr_lexer->looking_at_anon_fcn_args = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1020 } |
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 param_list_end : ')' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1025 { |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1026 curr_lexer->looking_at_parameter_list = false; |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1027 curr_lexer->looking_for_object_index = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1028 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1029 ; |
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 param_list : param_list_beg param_list1 param_list_end |
16259
0b5ab09dfce4
2/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16257
diff
changeset
|
1032 { $$ = $2; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1033 | param_list_beg error |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1034 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1035 curr_parser.bison_error ("invalid parameter list"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1036 $$ = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1037 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1038 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1039 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1040 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1041 param_list1 : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1042 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1043 | param_list2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1044 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1045 $1->mark_as_formal_parameters (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1046 if ($1->validate (tree_parameter_list::in)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1047 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1048 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1049 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1050 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1051 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1052 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1053 param_list2 : decl2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1054 { $$ = new tree_parameter_list ($1); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1055 | param_list2 ',' decl2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1056 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1057 $1->append ($3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1058 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1059 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1060 ; |
2970 | 1061 |
1062 // =================================== | |
1063 // List of function return value names | |
1064 // =================================== | |
1065 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1066 return_list : '[' ']' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1067 { |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1068 curr_lexer->looking_at_return_list = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1069 $$ = new tree_parameter_list (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1070 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1071 | return_list1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1072 { |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1073 curr_lexer->looking_at_return_list = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1074 if ($1->validate (tree_parameter_list::out)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1075 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1076 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1077 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1078 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1079 | '[' return_list1 ']' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1080 { |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1081 curr_lexer->looking_at_return_list = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1082 if ($2->validate (tree_parameter_list::out)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1083 $$ = $2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1084 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1085 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1086 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1087 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1088 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1089 return_list1 : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1090 { $$ = new tree_parameter_list (new tree_decl_elt ($1)); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1091 | return_list1 ',' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1092 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1093 $1->append (new tree_decl_elt ($3)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1094 $$ = $1; |
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 ; |
2970 | 1097 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1098 // ======================= |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1099 // Script or function file |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1100 // ======================= |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1101 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1102 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
|
1103 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1104 if (! curr_lexer->reading_fcn_file) |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1105 { |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1106 tree_statement *end_of_script |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1107 = curr_parser.make_end ("endscript", |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1108 curr_lexer->input_line_number, |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1109 curr_lexer->current_input_column); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1110 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1111 curr_parser.make_script ($3, end_of_script); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
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 $$ = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1115 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1116 ; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
1117 |
2970 | 1118 // =================== |
1119 // Function definition | |
1120 // =================== | |
1121 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1122 function_beg : push_fcn_symtab FCN stash_comment |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1123 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1124 $$ = $3; |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1125 if (curr_lexer->reading_classdef_file |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1126 || curr_lexer->parsing_classdef) |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1127 curr_lexer->maybe_classdef_get_set_method = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1128 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1129 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1130 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1131 function : function_beg function1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1132 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1133 $$ = curr_parser.finish_function (0, $2, $1); |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1134 curr_parser.recover_from_parsing_function (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1135 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1136 | function_beg return_list '=' function1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1137 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1138 $$ = curr_parser.finish_function ($2, $4, $1); |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1139 curr_parser.recover_from_parsing_function (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1140 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1141 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1142 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1143 fcn_name : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1144 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1145 std::string id_name = $1->name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1146 |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1147 curr_lexer->parsed_function_name.top () = true; |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1148 curr_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
|
1149 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1150 $$ = $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1151 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1152 | GET '.' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1153 { |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1154 curr_lexer->parsed_function_name.top () = true; |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1155 curr_lexer->maybe_classdef_get_set_method = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1156 $$ = $3; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1157 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1158 | SET '.' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1159 { |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1160 curr_lexer->parsed_function_name.top () = true; |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1161 curr_lexer->maybe_classdef_get_set_method = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1162 $$ = $3; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1163 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1164 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1165 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1166 function1 : fcn_name function2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1167 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1168 std::string fname = $1->name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1169 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1170 delete $1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1171 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1172 if (! ($$ = curr_parser.frob_function (fname, $2))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1173 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1174 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1175 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1176 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1177 function2 : param_list opt_sep opt_list function_end |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1178 { $$ = curr_parser.start_function ($1, $3, $4); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1179 | opt_sep opt_list function_end |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1180 { $$ = curr_parser.start_function (0, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1181 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1182 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1183 function_end : END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1184 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1185 curr_parser.endfunction_found = true; |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1186 if (curr_parser.end_token_ok ($1, token::function_end)) |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1187 $$ = curr_parser.make_end ("endfunction", $1->line (), $1->column ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1188 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1189 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1190 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1191 | END_OF_INPUT |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1192 { |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
1193 // A lot of tests are based on the assumption that this is OK |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16198
diff
changeset
|
1194 // if (curr_lexer->reading_script_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1195 // { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1196 // curr_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
|
1197 // YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1198 // } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1199 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1200 if (curr_parser.endfunction_found) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1201 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1202 curr_parser.bison_error ("inconsistent function endings -- " |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1203 "if one function is explicitly ended, " |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1204 "so must all the others"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1205 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1206 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1207 |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16198
diff
changeset
|
1208 if (! (curr_lexer->reading_fcn_file || curr_lexer->reading_script_file |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
1209 || (curr_lexer)->input_from_eval_string ())) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1210 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1211 curr_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
|
1212 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1213 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1214 |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16198
diff
changeset
|
1215 if (curr_lexer->reading_classdef_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1216 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1217 curr_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
|
1218 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1219 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1220 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1221 $$ = curr_parser.make_end ("endfunction", |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1222 curr_lexer->input_line_number, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1223 curr_lexer->current_input_column); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1224 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1225 ; |
2970 | 1226 |
9476 | 1227 // ======== |
1228 // Classdef | |
1229 // ======== | |
1230 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1231 classdef_beg : CLASSDEF stash_comment |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1232 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1233 $$ = 0; |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1234 curr_lexer->parsing_classdef = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1235 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1236 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1237 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1238 classdef_end : END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1239 { |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1240 curr_lexer->parsing_classdef = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1241 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1242 if (curr_parser.end_token_ok ($1, token::classdef_end)) |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1243 $$ = curr_parser.make_end ("endclassdef", $1->line (), $1->column ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1244 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1245 ABORT_PARSE; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1246 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1247 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1248 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1249 classdef1 : classdef_beg opt_attr_list identifier opt_superclasses |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1250 { $$ = 0; } |
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 |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1253 classdef : classdef1 opt_sep class_body opt_sep stash_comment classdef_end |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1254 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1255 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1256 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1257 opt_attr_list : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1258 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1259 | '(' attr_list ')' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1260 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1261 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1262 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1263 attr_list : attr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1264 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1265 | attr_list ',' attr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1266 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1267 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1268 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1269 attr : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1270 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1271 | identifier '=' decl_param_init expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1272 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1273 | EXPR_NOT identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1274 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1275 ; |
9476 | 1276 |
1277 opt_superclasses | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1278 : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1279 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1280 | superclasses |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1281 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1282 ; |
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 superclasses : EXPR_LT identifier '.' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1285 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1286 | EXPR_LT identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1287 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1288 | superclasses EXPR_AND identifier '.' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1289 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1290 | superclasses EXPR_AND identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1291 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1292 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1293 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1294 class_body : properties_block |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1295 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1296 | methods_block |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1297 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1298 | events_block |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1299 { $$ = 0; } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1300 | enum_block |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1301 { $$ = 0; } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1302 | class_body opt_sep properties_block |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1303 { $$ = 0; } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1304 | class_body opt_sep methods_block |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1305 { $$ = 0; } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1306 | class_body opt_sep events_block |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1307 { $$ = 0; } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1308 | class_body opt_sep enum_block |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1309 { $$ = 0; } |
10315
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 properties_beg : PROPERTIES stash_comment |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1313 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1314 ; |
9476 | 1315 |
1316 properties_block | |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1317 : properties_beg opt_attr_list opt_sep properties_list opt_sep END |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1318 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1319 ; |
9476 | 1320 |
1321 properties_list | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1322 : class_property |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1323 { $$ = 0; } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1324 | properties_list opt_sep class_property |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1325 { $$ = 0; } |
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 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1328 class_property : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1329 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1330 | identifier '=' decl_param_init expression ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1331 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1332 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1333 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1334 methods_beg : METHODS stash_comment |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1335 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1336 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1337 |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1338 methods_block : methods_beg opt_attr_list opt_sep methods_list opt_sep END |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1339 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1340 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1341 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1342 methods_list : function |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1343 { $$ = 0; } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1344 | methods_list opt_sep function |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1345 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1346 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1347 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1348 events_beg : EVENTS stash_comment |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1349 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1350 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1351 |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1352 events_block : events_beg opt_attr_list opt_sep events_list opt_sep END |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1353 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1354 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1355 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1356 events_list : class_event |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1357 { $$ = 0; } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1358 | events_list opt_sep class_event |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1359 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1360 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1361 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1362 class_event : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1363 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1364 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1365 |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1366 enum_beg : ENUMERATION stash_comment |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1367 { $$ = 0; } |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1368 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1369 |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1370 enum_block : enum_beg opt_attr_list opt_sep enum_list opt_sep END |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1371 { $$ = 0; } |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1372 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1373 |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1374 enum_list : class_enum |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1375 { $$ = 0; } |
13250
f6bbdea030b2
use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents:
13249
diff
changeset
|
1376 | enum_list opt_sep class_enum |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1377 { $$ = 0; } |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1378 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1379 |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1380 class_enum : identifier '(' expression ')' |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1381 { $$ = 0; } |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1382 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1383 |
2970 | 1384 // ============= |
1385 // Miscellaneous | |
1386 // ============= | |
1387 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1388 stash_comment : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1389 { $$ = octave_comment_buffer::get_comment (); } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1390 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1391 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1392 parse_error : LEXICAL_ERROR |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1393 { curr_parser.bison_error ("parse error"); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1394 | error |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1395 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1396 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1397 sep_no_nl : ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1398 { $$ = ','; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1399 | ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1400 { $$ = ';'; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1401 | sep_no_nl ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1402 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1403 | sep_no_nl ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1404 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1405 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1406 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1407 opt_sep_no_nl : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1408 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1409 | sep_no_nl |
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 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1413 opt_nl : // empty |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1414 { $$ = 0; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1415 | nl |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1416 { $$ = $1; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1417 ; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1418 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1419 nl : '\n' |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1420 { $$ = '\n'; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1421 | nl '\n' |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1422 { $$ = $1; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1423 ; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1424 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1425 sep : ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1426 { $$ = ','; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1427 | ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1428 { $$ = ';'; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1429 | '\n' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1430 { $$ = '\n'; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1431 | sep ',' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1432 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1433 | sep ';' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1434 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1435 | sep '\n' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1436 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1437 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1438 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1439 opt_sep : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1440 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1441 | sep |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1442 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1443 ; |
2525 | 1444 |
1 | 1445 %% |
1446 | |
666 | 1447 // Generic error messages. |
1448 | |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
1449 #undef curr_lexer |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
1450 |
1 | 1451 static void |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1452 yyerror (octave_parser& curr_parser, const char *s) |
1 | 1453 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1454 curr_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
|
1455 } |
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
|
1456 |
16157
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1457 octave_parser::~octave_parser (void) |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1458 { |
16167
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1459 #if defined (OCTAVE_USE_PUSH_PARSER) |
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1460 yypstate_delete (static_cast<yypstate *> (parser_state)); |
16157
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1461 #endif |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1462 |
16177
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1463 delete stmt_list; |
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1464 |
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1465 delete curr_lexer; |
16157
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1466 } |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1467 void octave_parser::init (void) |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1468 { |
16167
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1469 #if defined (OCTAVE_USE_PUSH_PARSER) |
16157
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1470 parser_state = yypstate_new (); |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1471 #endif |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1472 |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1473 CURR_LEXER = curr_lexer; |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1474 } |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1475 |
16177
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1476 void |
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1477 octave_parser::reset (void) |
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1478 { |
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1479 delete stmt_list; |
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1480 |
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1481 stmt_list = 0; |
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1482 |
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1483 curr_lexer->reset (); |
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1484 } |
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
1485 |
16138
284e2ca86ef7
execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16136
diff
changeset
|
1486 int |
284e2ca86ef7
execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16136
diff
changeset
|
1487 octave_parser::run (void) |
284e2ca86ef7
execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16136
diff
changeset
|
1488 { |
16157
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1489 int status = 0; |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1490 |
16167
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1491 #if defined (OCTAVE_USE_PUSH_PARSER) |
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1492 |
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1493 do |
16157
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1494 { |
16167
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1495 YYSTYPE lval; |
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1496 |
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1497 int token = octave_lex (&lval, scanner); |
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1498 |
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1499 yypstate *pstate = static_cast<yypstate *> (parser_state); |
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1500 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1501 status = octave_push_parse (pstate, token, &lval, *this); |
16157
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1502 } |
16167
22bb3aa9f025
make push parser interface partially work
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1503 while (status == YYPUSH_MORE); |
16157
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1504 |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1505 #else |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1506 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
1507 status = octave_parse (*this); |
16157
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1508 |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1509 #endif |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1510 |
335041cc657a
optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents:
16153
diff
changeset
|
1511 return status; |
16138
284e2ca86ef7
execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16136
diff
changeset
|
1512 } |
284e2ca86ef7
execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16136
diff
changeset
|
1513 |
666 | 1514 // Error mesages for mismatched end tokens. |
1515 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1516 void |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1517 octave_parser::end_error (const char *type, token::end_tok_type ettype, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1518 int l, int c) |
496 | 1519 { |
2805 | 1520 static const char *fmt |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
1521 = "'%s' command matched by '%s' near line %d column %d"; |
496 | 1522 |
1523 switch (ettype) | |
1524 { | |
1525 case token::simple_end: | |
1526 error (fmt, type, "end", l, c); | |
1527 break; | |
777 | 1528 |
496 | 1529 case token::for_end: |
1530 error (fmt, type, "endfor", l, c); | |
1531 break; | |
777 | 1532 |
496 | 1533 case token::function_end: |
1534 error (fmt, type, "endfunction", l, c); | |
1535 break; | |
777 | 1536 |
9476 | 1537 case token::classdef_end: |
1538 error (fmt, type, "endclassdef", l, c); | |
1539 break; | |
1540 | |
496 | 1541 case token::if_end: |
1542 error (fmt, type, "endif", l, c); | |
1543 break; | |
777 | 1544 |
3233 | 1545 case token::switch_end: |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1546 error (fmt, type, "endswitch", l, c); |
3233 | 1547 break; |
1548 | |
496 | 1549 case token::while_end: |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1550 error (fmt, type, "endwhile", l, c); |
496 | 1551 break; |
777 | 1552 |
5400 | 1553 case token::try_catch_end: |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1554 error (fmt, type, "end_try_catch", l, c); |
5400 | 1555 break; |
1556 | |
1371 | 1557 case token::unwind_protect_end: |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1558 error (fmt, type, "end_unwind_protect", l, c); |
1371 | 1559 break; |
1560 | |
496 | 1561 default: |
1562 panic_impossible (); | |
1563 break; | |
1564 } | |
1565 } | |
1566 | |
666 | 1567 // Check to see that end tokens are properly matched. |
1568 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1569 bool |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1570 octave_parser::end_token_ok (token *tok, token::end_tok_type expected) |
143 | 1571 { |
2857 | 1572 bool retval = true; |
1573 | |
143 | 1574 token::end_tok_type ettype = tok->ettype (); |
2857 | 1575 |
143 | 1576 if (ettype != expected && ettype != token::simple_end) |
1577 { | |
2857 | 1578 retval = false; |
1579 | |
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
|
1580 bison_error ("parse error"); |
143 | 1581 |
1582 int l = tok->line (); | |
1583 int c = tok->column (); | |
1584 | |
1585 switch (expected) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1586 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1587 case token::classdef_end: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1588 end_error ("classdef", ettype, l, c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1589 break; |
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 case token::for_end: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1592 end_error ("for", ettype, l, c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1593 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1594 |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1595 case token::enumeration_end: |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1596 end_error ("enumeration", ettype, l, c); |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1597 break; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1598 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1599 case token::function_end: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1600 end_error ("function", ettype, l, c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1601 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1602 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1603 case token::if_end: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1604 end_error ("if", ettype, l, c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1605 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1606 |
13246 | 1607 case token::parfor_end: |
1608 end_error ("parfor", ettype, l, c); | |
1609 break; | |
1610 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1611 case token::try_catch_end: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1612 end_error ("try", ettype, l, c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1613 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1614 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1615 case token::switch_end: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1616 end_error ("switch", ettype, l, c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1617 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1618 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1619 case token::unwind_protect_end: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1620 end_error ("unwind_protect", ettype, l, c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1621 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1622 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1623 case token::while_end: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1624 end_error ("while", ettype, l, c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1625 break; |
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 default: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1628 panic_impossible (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1629 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1630 } |
143 | 1631 } |
2857 | 1632 |
1633 return retval; | |
143 | 1634 } |
1635 | |
666 | 1636 // Maybe print a warning if an assignment expression is used as the |
1637 // test in a logical expression. | |
1638 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1639 void |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1640 octave_parser::maybe_warn_assign_as_truth_value (tree_expression *expr) |
1 | 1641 { |
5781 | 1642 if (expr->is_assignment_expression () |
2961 | 1643 && expr->paren_count () < 2) |
1 | 1644 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1645 if (curr_lexer->fcn_file_full_name.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1646 warning_with_id |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1647 ("Octave:assign-as-truth-value", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1648 "suggest parenthesis around assignment used as truth value"); |
8974
fde2a916b2ac
include line and file info in parser warnings
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
1649 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1650 warning_with_id |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1651 ("Octave:assign-as-truth-value", |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
1652 "suggest parenthesis around assignment used as truth value near line %d, column %d in file '%s'", |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1653 expr->line (), expr->column (), curr_lexer->fcn_file_full_name.c_str ()); |
1 | 1654 } |
1655 } | |
578 | 1656 |
2764 | 1657 // Maybe print a warning about switch labels that aren't constants. |
1658 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1659 void |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1660 octave_parser::maybe_warn_variable_switch_label (tree_expression *expr) |
2764 | 1661 { |
5781 | 1662 if (! expr->is_constant ()) |
8974
fde2a916b2ac
include line and file info in parser warnings
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
1663 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1664 if (curr_lexer->fcn_file_full_name.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1665 warning_with_id ("Octave:variable-switch-label", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1666 "variable switch label"); |
8974
fde2a916b2ac
include line and file info in parser warnings
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
1667 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1668 warning_with_id |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1669 ("Octave:variable-switch-label", |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
1670 "variable switch label near line %d, column %d in file '%s'", |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1671 expr->line (), expr->column (), curr_lexer->fcn_file_full_name.c_str ()); |
8974
fde2a916b2ac
include line and file info in parser warnings
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
1672 } |
2764 | 1673 } |
1674 | |
2533 | 1675 static tree_expression * |
1676 fold (tree_binary_expression *e) | |
1677 { | |
3110 | 1678 tree_expression *retval = e; |
1679 | |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1680 unwind_protect frame; |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1681 |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1682 frame.protect_var (error_state); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1683 frame.protect_var (warning_state); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1684 |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1685 frame.protect_var (discard_error_messages); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1686 frame.protect_var (discard_warning_messages); |
4452 | 1687 |
3815 | 1688 discard_error_messages = true; |
4452 | 1689 discard_warning_messages = true; |
2533 | 1690 |
1691 tree_expression *op1 = e->lhs (); | |
1692 tree_expression *op2 = e->rhs (); | |
1693 | |
13844
e48529b3dbd4
eliminate warnings for changes in operator precedence made years ago
John W. Eaton <jwe@octave.org>
parents:
13250
diff
changeset
|
1694 if (op1->is_constant () && op2->is_constant ()) |
2533 | 1695 { |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
1696 octave_value tmp = e->rvalue1 (); |
2533 | 1697 |
3489 | 1698 if (! (error_state || warning_state)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1699 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1700 tree_constant *tc_retval |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1701 = new tree_constant (tmp, op1->line (), op1->column ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1702 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1703 std::ostringstream buf; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1704 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1705 tree_print_code tpc (buf); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1706 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1707 e->accept (tpc); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1708 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1709 tc_retval->stash_original_text (buf.str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1710 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1711 delete e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1712 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1713 retval = tc_retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1714 } |
2533 | 1715 } |
3110 | 1716 |
3292 | 1717 return retval; |
1718 } | |
1719 | |
1720 static tree_expression * | |
1721 fold (tree_unary_expression *e) | |
1722 { | |
1723 tree_expression *retval = e; | |
1724 | |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1725 unwind_protect frame; |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1726 |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1727 frame.protect_var (error_state); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1728 frame.protect_var (warning_state); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1729 |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1730 frame.protect_var (discard_error_messages); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1731 frame.protect_var (discard_warning_messages); |
4452 | 1732 |
3815 | 1733 discard_error_messages = true; |
4452 | 1734 discard_warning_messages = true; |
3292 | 1735 |
1736 tree_expression *op = e->operand (); | |
1737 | |
1738 if (op->is_constant ()) | |
1739 { | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
1740 octave_value tmp = e->rvalue1 (); |
3292 | 1741 |
3489 | 1742 if (! (error_state || warning_state)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1743 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1744 tree_constant *tc_retval |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1745 = new tree_constant (tmp, op->line (), op->column ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1746 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1747 std::ostringstream buf; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1748 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1749 tree_print_code tpc (buf); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1750 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1751 e->accept (tpc); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1752 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1753 tc_retval->stash_original_text (buf.str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1754 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1755 delete e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1756 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1757 retval = tc_retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1758 } |
3292 | 1759 } |
1760 | |
2533 | 1761 return retval; |
1762 } | |
1763 | |
1623 | 1764 // Finish building a range. |
1765 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1766 tree_expression * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1767 octave_parser::finish_colon_expression (tree_colon_expression *e) |
1623 | 1768 { |
3110 | 1769 tree_expression *retval = e; |
1770 | |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1771 unwind_protect frame; |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1772 |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1773 frame.protect_var (error_state); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1774 frame.protect_var (warning_state); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1775 |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1776 frame.protect_var (discard_error_messages); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
1777 frame.protect_var (discard_warning_messages); |
4452 | 1778 |
3815 | 1779 discard_error_messages = true; |
4452 | 1780 discard_warning_messages = true; |
1623 | 1781 |
2533 | 1782 tree_expression *base = e->base (); |
1783 tree_expression *limit = e->limit (); | |
1784 tree_expression *incr = e->increment (); | |
1785 | |
2970 | 1786 if (base) |
1623 | 1787 { |
2970 | 1788 if (limit) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1789 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1790 if (base->is_constant () && limit->is_constant () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1791 && (! incr || (incr && incr->is_constant ()))) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1792 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1793 octave_value tmp = e->rvalue1 (); |
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 if (! (error_state || warning_state)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1796 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1797 tree_constant *tc_retval |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1798 = new tree_constant (tmp, base->line (), base->column ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1799 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1800 std::ostringstream buf; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1801 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1802 tree_print_code tpc (buf); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1803 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1804 e->accept (tpc); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1805 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1806 tc_retval->stash_original_text (buf.str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1807 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1808 delete e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1809 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1810 retval = tc_retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1811 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1812 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1813 } |
2533 | 1814 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1815 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1816 e->preserve_base (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1817 delete e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1818 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1819 // FIXME -- need to attempt constant folding here |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1820 // too (we need a generic way to do that). |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1821 retval = base; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1822 } |
1623 | 1823 } |
1824 | |
1825 return retval; | |
1826 } | |
1827 | |
1607 | 1828 // Make a constant. |
1829 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1830 tree_constant * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1831 octave_parser::make_constant (int op, token *tok_val) |
1607 | 1832 { |
1833 int l = tok_val->line (); | |
1834 int c = tok_val->column (); | |
1835 | |
3216 | 1836 tree_constant *retval = 0; |
1607 | 1837 |
1838 switch (op) | |
1839 { | |
1840 case NUM: | |
2533 | 1841 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1842 octave_value tmp (tok_val->number ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1843 retval = new tree_constant (tmp, l, c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1844 retval->stash_original_text (tok_val->text_rep ()); |
2533 | 1845 } |
1607 | 1846 break; |
1847 | |
1848 case IMAG_NUM: | |
1849 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1850 octave_value tmp (Complex (0.0, tok_val->number ())); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1851 retval = new tree_constant (tmp, l, c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1852 retval->stash_original_text (tok_val->text_rep ()); |
1607 | 1853 } |
1854 break; | |
1855 | |
5279 | 1856 case DQ_STRING: |
1857 case SQ_STRING: | |
2883 | 1858 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1859 std::string txt = tok_val->text (); |
7699
27a5f578750c
make_constant: handle escape sequences in dq-strings
John W. Eaton <jwe@octave.org>
parents:
7690
diff
changeset
|
1860 |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
1861 char delim = op == DQ_STRING ? '"' : '\''; |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
1862 octave_value tmp (txt, delim); |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
1863 |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
1864 if (txt.empty ()) |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
1865 { |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
1866 if (op == DQ_STRING) |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
1867 tmp = octave_null_str::instance; |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
1868 else |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
1869 tmp = octave_null_sq_str::instance; |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
1870 } |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
1871 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1872 retval = new tree_constant (tmp, l, c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1873 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1874 if (op == DQ_STRING) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1875 txt = undo_string_escapes (txt); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1876 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1877 // FIXME -- maybe this should also be handled by |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1878 // tok_val->text_rep () for character strings? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1879 retval->stash_original_text (delim + txt + delim); |
2883 | 1880 } |
1607 | 1881 break; |
1882 | |
1883 default: | |
1884 panic_impossible (); | |
1885 break; | |
1886 } | |
1887 | |
1888 return retval; | |
1889 } | |
1890 | |
4342 | 1891 // Make a function handle. |
1892 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1893 tree_fcn_handle * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1894 octave_parser::make_fcn_handle (token *tok_val) |
4342 | 1895 { |
1896 int l = tok_val->line (); | |
1897 int c = tok_val->column (); | |
1898 | |
1899 tree_fcn_handle *retval = new tree_fcn_handle (tok_val->text (), l, c); | |
1900 | |
1901 return retval; | |
1902 } | |
1903 | |
4935 | 1904 // Make an anonymous function handle. |
1905 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1906 tree_anon_fcn_handle * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1907 octave_parser::make_anon_fcn_handle (tree_parameter_list *param_list, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1908 tree_statement *stmt) |
4935 | 1909 { |
5775 | 1910 // FIXME -- need to get these from the location of the @ symbol. |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1911 int l = curr_lexer->input_line_number; |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
1912 int c = curr_lexer->current_input_column; |
4935 | 1913 |
1914 tree_parameter_list *ret_list = 0; | |
1915 | |
7336 | 1916 symbol_table::scope_id fcn_scope = symbol_table::current_scope (); |
5861 | 1917 |
14329
8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents:
14294
diff
changeset
|
1918 if (parser_symtab_context.empty ()) |
5861 | 1919 panic_impossible (); |
1920 | |
14329
8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents:
14294
diff
changeset
|
1921 parser_symtab_context.pop (); |
5861 | 1922 |
7351 | 1923 stmt->set_print_flag (false); |
4935 | 1924 |
1925 tree_statement_list *body = new tree_statement_list (stmt); | |
1926 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
1927 body->mark_as_anon_function_body (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
1928 |
5861 | 1929 tree_anon_fcn_handle *retval |
7336 | 1930 = new tree_anon_fcn_handle (param_list, ret_list, body, fcn_scope, l, c); |
13125
34a49d076155
Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents:
13029
diff
changeset
|
1931 // FIXME: Stash the filename. This does not work and produces |
34a49d076155
Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents:
13029
diff
changeset
|
1932 // errors when executed. |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1933 //retval->stash_file_name (curr_lexer->fcn_file_name); |
4935 | 1934 |
1935 return retval; | |
1936 } | |
1937 | |
666 | 1938 // Build a binary expression. |
1939 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1940 tree_expression * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1941 octave_parser::make_binary_op (int op, tree_expression *op1, token *tok_val, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
1942 tree_expression *op2) |
578 | 1943 { |
2883 | 1944 octave_value::binary_op t = octave_value::unknown_binary_op; |
1623 | 1945 |
578 | 1946 switch (op) |
1947 { | |
1948 case POW: | |
3525 | 1949 t = octave_value::op_pow; |
578 | 1950 break; |
777 | 1951 |
578 | 1952 case EPOW: |
3525 | 1953 t = octave_value::op_el_pow; |
578 | 1954 break; |
777 | 1955 |
578 | 1956 case '+': |
3525 | 1957 t = octave_value::op_add; |
578 | 1958 break; |
777 | 1959 |
578 | 1960 case '-': |
3525 | 1961 t = octave_value::op_sub; |
578 | 1962 break; |
777 | 1963 |
578 | 1964 case '*': |
3525 | 1965 t = octave_value::op_mul; |
578 | 1966 break; |
777 | 1967 |
578 | 1968 case '/': |
3525 | 1969 t = octave_value::op_div; |
578 | 1970 break; |
777 | 1971 |
578 | 1972 case EMUL: |
3525 | 1973 t = octave_value::op_el_mul; |
578 | 1974 break; |
777 | 1975 |
578 | 1976 case EDIV: |
3525 | 1977 t = octave_value::op_el_div; |
578 | 1978 break; |
777 | 1979 |
578 | 1980 case LEFTDIV: |
3525 | 1981 t = octave_value::op_ldiv; |
578 | 1982 break; |
777 | 1983 |
578 | 1984 case ELEFTDIV: |
3525 | 1985 t = octave_value::op_el_ldiv; |
578 | 1986 break; |
777 | 1987 |
2899 | 1988 case LSHIFT: |
3525 | 1989 t = octave_value::op_lshift; |
2899 | 1990 break; |
1991 | |
1992 case RSHIFT: | |
3525 | 1993 t = octave_value::op_rshift; |
2899 | 1994 break; |
1995 | |
578 | 1996 case EXPR_LT: |
3525 | 1997 t = octave_value::op_lt; |
578 | 1998 break; |
777 | 1999 |
578 | 2000 case EXPR_LE: |
3525 | 2001 t = octave_value::op_le; |
578 | 2002 break; |
777 | 2003 |
578 | 2004 case EXPR_EQ: |
3525 | 2005 t = octave_value::op_eq; |
578 | 2006 break; |
777 | 2007 |
578 | 2008 case EXPR_GE: |
3525 | 2009 t = octave_value::op_ge; |
578 | 2010 break; |
777 | 2011 |
578 | 2012 case EXPR_GT: |
3525 | 2013 t = octave_value::op_gt; |
578 | 2014 break; |
777 | 2015 |
578 | 2016 case EXPR_NE: |
3525 | 2017 t = octave_value::op_ne; |
578 | 2018 break; |
777 | 2019 |
578 | 2020 case EXPR_AND: |
3525 | 2021 t = octave_value::op_el_and; |
578 | 2022 break; |
777 | 2023 |
578 | 2024 case EXPR_OR: |
3525 | 2025 t = octave_value::op_el_or; |
578 | 2026 break; |
777 | 2027 |
578 | 2028 default: |
2029 panic_impossible (); | |
2030 break; | |
2031 } | |
2032 | |
2033 int l = tok_val->line (); | |
2034 int c = tok_val->column (); | |
2035 | |
2533 | 2036 tree_binary_expression *e |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7787
diff
changeset
|
2037 = maybe_compound_binary_expression (op1, op2, l, c, t); |
1623 | 2038 |
2533 | 2039 return fold (e); |
578 | 2040 } |
2041 | |
2375 | 2042 // Build a boolean expression. |
666 | 2043 |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2044 tree_expression * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2045 octave_parser::make_boolean_op (int op, tree_expression *op1, token *tok_val, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2046 tree_expression *op2) |
578 | 2047 { |
2375 | 2048 tree_boolean_expression::type t; |
2049 | |
578 | 2050 switch (op) |
2051 { | |
2375 | 2052 case EXPR_AND_AND: |
2805 | 2053 t = tree_boolean_expression::bool_and; |
578 | 2054 break; |
777 | 2055 |
2375 | 2056 case EXPR_OR_OR: |
2805 | 2057 t = tree_boolean_expression::bool_or; |
578 | 2058 break; |
777 | 2059 |
578 | 2060 default: |
2061 panic_impossible (); | |
2062 break; | |
2063 } | |
2064 | |
2065 int l = tok_val->line (); | |
2066 int c = tok_val->column (); | |
2067 | |
2533 | 2068 tree_boolean_expression *e |
2069 = new tree_boolean_expression (op1, op2, l, c, t); | |
2375 | 2070 |
2533 | 2071 return fold (e); |
578 | 2072 } |
2073 | |
2375 | 2074 // Build a prefix expression. |
666 | 2075 |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2076 tree_expression * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2077 octave_parser::make_prefix_op (int op, tree_expression *op1, token *tok_val) |
578 | 2078 { |
3203 | 2079 octave_value::unary_op t = octave_value::unknown_unary_op; |
2375 | 2080 |
578 | 2081 switch (op) |
2082 { | |
2960 | 2083 case EXPR_NOT: |
3525 | 2084 t = octave_value::op_not; |
2960 | 2085 break; |
2086 | |
4965 | 2087 case '+': |
2088 t = octave_value::op_uplus; | |
2089 break; | |
2090 | |
2960 | 2091 case '-': |
3525 | 2092 t = octave_value::op_uminus; |
2960 | 2093 break; |
2094 | |
578 | 2095 case PLUS_PLUS: |
3525 | 2096 t = octave_value::op_incr; |
578 | 2097 break; |
777 | 2098 |
578 | 2099 case MINUS_MINUS: |
3525 | 2100 t = octave_value::op_decr; |
578 | 2101 break; |
777 | 2102 |
578 | 2103 default: |
2104 panic_impossible (); | |
2105 break; | |
2106 } | |
2107 | |
2108 int l = tok_val->line (); | |
2109 int c = tok_val->column (); | |
2110 | |
3292 | 2111 tree_prefix_expression *e |
2112 = new tree_prefix_expression (op1, l, c, t); | |
2113 | |
2114 return fold (e); | |
578 | 2115 } |
2116 | |
2375 | 2117 // Build a postfix expression. |
666 | 2118 |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2119 tree_expression * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2120 octave_parser::make_postfix_op (int op, tree_expression *op1, token *tok_val) |
578 | 2121 { |
3203 | 2122 octave_value::unary_op t = octave_value::unknown_unary_op; |
1623 | 2123 |
578 | 2124 switch (op) |
2125 { | |
2960 | 2126 case QUOTE: |
3525 | 2127 t = octave_value::op_hermitian; |
2960 | 2128 break; |
2129 | |
2130 case TRANSPOSE: | |
3525 | 2131 t = octave_value::op_transpose; |
2960 | 2132 break; |
2133 | |
2375 | 2134 case PLUS_PLUS: |
3525 | 2135 t = octave_value::op_incr; |
578 | 2136 break; |
777 | 2137 |
2375 | 2138 case MINUS_MINUS: |
3525 | 2139 t = octave_value::op_decr; |
578 | 2140 break; |
777 | 2141 |
578 | 2142 default: |
2143 panic_impossible (); | |
2144 break; | |
2145 } | |
2146 | |
2147 int l = tok_val->line (); | |
2148 int c = tok_val->column (); | |
2149 | |
3292 | 2150 tree_postfix_expression *e |
2151 = new tree_postfix_expression (op1, l, c, t); | |
2152 | |
2153 return fold (e); | |
1623 | 2154 } |
2155 | |
2156 // Build an unwind-protect command. | |
2157 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2158 tree_command * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2159 octave_parser::make_unwind_command (token *unwind_tok, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2160 tree_statement_list *body, |
16136
ed36d5543b27
don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents:
16134
diff
changeset
|
2161 tree_statement_list *cleanup_stmts, |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2162 token *end_tok, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2163 octave_comment_list *lc, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2164 octave_comment_list *mc) |
1623 | 2165 { |
2166 tree_command *retval = 0; | |
2167 | |
2857 | 2168 if (end_token_ok (end_tok, token::unwind_protect_end)) |
1623 | 2169 { |
3665 | 2170 octave_comment_list *tc = octave_comment_buffer::get_comment (); |
2171 | |
1623 | 2172 int l = unwind_tok->line (); |
2173 int c = unwind_tok->column (); | |
2174 | |
16136
ed36d5543b27
don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents:
16134
diff
changeset
|
2175 retval = new tree_unwind_protect_command (body, cleanup_stmts, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2176 lc, mc, tc, l, c); |
1623 | 2177 } |
2178 | |
2179 return retval; | |
2180 } | |
2181 | |
2182 // Build a try-catch command. | |
2183 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2184 tree_command * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2185 octave_parser::make_try_command (token *try_tok, tree_statement_list *body, |
16136
ed36d5543b27
don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents:
16134
diff
changeset
|
2186 tree_statement_list *cleanup_stmts, |
ed36d5543b27
don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents:
16134
diff
changeset
|
2187 token *end_tok, |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2188 octave_comment_list *lc, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2189 octave_comment_list *mc) |
1623 | 2190 { |
2191 tree_command *retval = 0; | |
2192 | |
2857 | 2193 if (end_token_ok (end_tok, token::try_catch_end)) |
1623 | 2194 { |
3665 | 2195 octave_comment_list *tc = octave_comment_buffer::get_comment (); |
2196 | |
1623 | 2197 int l = try_tok->line (); |
2198 int c = try_tok->column (); | |
2199 | |
16136
ed36d5543b27
don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents:
16134
diff
changeset
|
2200 retval = new tree_try_catch_command (body, cleanup_stmts, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2201 lc, mc, tc, l, c); |
1623 | 2202 } |
2203 | |
2204 return retval; | |
2205 } | |
2206 | |
2207 // Build a while command. | |
2208 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2209 tree_command * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2210 octave_parser::make_while_command (token *while_tok, tree_expression *expr, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2211 tree_statement_list *body, token *end_tok, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2212 octave_comment_list *lc) |
1623 | 2213 { |
2214 tree_command *retval = 0; | |
2215 | |
2216 maybe_warn_assign_as_truth_value (expr); | |
2217 | |
2857 | 2218 if (end_token_ok (end_tok, token::while_end)) |
1623 | 2219 { |
3665 | 2220 octave_comment_list *tc = octave_comment_buffer::get_comment (); |
2221 | |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2222 curr_lexer->looping--; |
1623 | 2223 |
2224 int l = while_tok->line (); | |
2225 int c = while_tok->column (); | |
2226 | |
3665 | 2227 retval = new tree_while_command (expr, body, lc, tc, l, c); |
1623 | 2228 } |
2229 | |
2230 return retval; | |
2231 } | |
2232 | |
3484 | 2233 // Build a do-until command. |
2234 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2235 tree_command * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2236 octave_parser::make_do_until_command (token *until_tok, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2237 tree_statement_list *body, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2238 tree_expression *expr, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2239 octave_comment_list *lc) |
3484 | 2240 { |
2241 tree_command *retval = 0; | |
2242 | |
2243 maybe_warn_assign_as_truth_value (expr); | |
2244 | |
3665 | 2245 octave_comment_list *tc = octave_comment_buffer::get_comment (); |
2246 | |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2247 curr_lexer->looping--; |
3484 | 2248 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2249 int l = until_tok->line (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2250 int c = until_tok->column (); |
3484 | 2251 |
3665 | 2252 retval = new tree_do_until_command (expr, body, lc, tc, l, c); |
3484 | 2253 |
2254 return retval; | |
2255 } | |
2256 | |
1623 | 2257 // Build a for command. |
2258 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2259 tree_command * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2260 octave_parser::make_for_command (int tok_id, token *for_tok, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2261 tree_argument_list *lhs, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2262 tree_expression *expr, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2263 tree_expression *maxproc, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2264 tree_statement_list *body, token *end_tok, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2265 octave_comment_list *lc) |
1623 | 2266 { |
2267 tree_command *retval = 0; | |
2268 | |
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
|
2269 bool parfor = tok_id == PARFOR; |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
2270 |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
2271 if (end_token_ok (end_tok, parfor ? token::parfor_end : token::for_end)) |
1623 | 2272 { |
3665 | 2273 octave_comment_list *tc = octave_comment_buffer::get_comment (); |
2274 | |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2275 curr_lexer->looping--; |
1623 | 2276 |
2277 int l = for_tok->line (); | |
2278 int c = for_tok->column (); | |
2279 | |
2970 | 2280 if (lhs->length () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2281 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2282 tree_expression *tmp = lhs->remove_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2283 |
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
|
2284 retval = new tree_simple_for_command (parfor, tmp, expr, maxproc, |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
2285 body, lc, tc, l, c); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2286 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2287 delete lhs; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2288 } |
2970 | 2289 else |
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
|
2290 { |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
2291 if (parfor) |
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
|
2292 bison_error ("invalid syntax for parfor statement"); |
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
|
2293 else |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
2294 retval = new tree_complex_for_command (lhs, expr, body, |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
2295 lc, tc, l, c); |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
2296 } |
1623 | 2297 } |
2298 | |
2299 return retval; | |
2300 } | |
2301 | |
4207 | 2302 // Build a break command. |
2303 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2304 tree_command * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2305 octave_parser::make_break_command (token *break_tok) |
1623 | 2306 { |
4207 | 2307 tree_command *retval = 0; |
1623 | 2308 |
2620 | 2309 int l = break_tok->line (); |
2310 int c = break_tok->column (); | |
2311 | |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
2312 retval = new tree_break_command (l, c); |
1623 | 2313 |
2314 return retval; | |
2315 } | |
2316 | |
4207 | 2317 // Build a continue command. |
2318 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2319 tree_command * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2320 octave_parser::make_continue_command (token *continue_tok) |
1623 | 2321 { |
4207 | 2322 tree_command *retval = 0; |
1623 | 2323 |
2620 | 2324 int l = continue_tok->line (); |
2325 int c = continue_tok->column (); | |
2326 | |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
2327 retval = new tree_continue_command (l, c); |
1623 | 2328 |
2329 return retval; | |
2330 } | |
2331 | |
4207 | 2332 // Build a return command. |
2333 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2334 tree_command * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2335 octave_parser::make_return_command (token *return_tok) |
1623 | 2336 { |
4207 | 2337 tree_command *retval = 0; |
1623 | 2338 |
2620 | 2339 int l = return_tok->line (); |
2340 int c = return_tok->column (); | |
2341 | |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
2342 retval = new tree_return_command (l, c); |
1623 | 2343 |
2344 return retval; | |
2345 } | |
2346 | |
2347 // Start an if command. | |
2348 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2349 tree_if_command_list * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2350 octave_parser::start_if_command (tree_expression *expr, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2351 tree_statement_list *list) |
1623 | 2352 { |
2353 maybe_warn_assign_as_truth_value (expr); | |
2354 | |
2355 tree_if_clause *t = new tree_if_clause (expr, list); | |
2356 | |
2357 return new tree_if_command_list (t); | |
2358 } | |
2359 | |
2360 // Finish an if command. | |
2361 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2362 tree_if_command * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2363 octave_parser::finish_if_command (token *if_tok, tree_if_command_list *list, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2364 token *end_tok, octave_comment_list *lc) |
1623 | 2365 { |
2366 tree_if_command *retval = 0; | |
2367 | |
2857 | 2368 if (end_token_ok (end_tok, token::if_end)) |
1623 | 2369 { |
3665 | 2370 octave_comment_list *tc = octave_comment_buffer::get_comment (); |
2371 | |
1623 | 2372 int l = if_tok->line (); |
2373 int c = if_tok->column (); | |
2374 | |
8842
be7b30a24938
line/column info for switch and if statements
John W. Eaton <jwe@octave.org>
parents:
8828
diff
changeset
|
2375 if (list && ! list->empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2376 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2377 tree_if_clause *elt = list->front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2378 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2379 if (elt) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2380 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2381 elt->line (l); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2382 elt->column (c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2383 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2384 } |
8842
be7b30a24938
line/column info for switch and if statements
John W. Eaton <jwe@octave.org>
parents:
8828
diff
changeset
|
2385 |
3665 | 2386 retval = new tree_if_command (list, lc, tc, l, c); |
1623 | 2387 } |
2388 | |
2389 return retval; | |
2390 } | |
2391 | |
2392 // Build an elseif clause. | |
2393 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2394 tree_if_clause * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2395 octave_parser::make_elseif_clause (token *elseif_tok, tree_expression *expr, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2396 tree_statement_list *list, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2397 octave_comment_list *lc) |
1623 | 2398 { |
2399 maybe_warn_assign_as_truth_value (expr); | |
2400 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2401 int l = elseif_tok->line (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2402 int c = elseif_tok->column (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2403 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2404 return new tree_if_clause (expr, list, lc, l, c); |
1623 | 2405 } |
2406 | |
2764 | 2407 // Finish a switch command. |
2408 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2409 tree_switch_command * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2410 octave_parser::finish_switch_command (token *switch_tok, tree_expression *expr, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2411 tree_switch_case_list *list, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2412 token *end_tok, octave_comment_list *lc) |
2764 | 2413 { |
2414 tree_switch_command *retval = 0; | |
2415 | |
2857 | 2416 if (end_token_ok (end_tok, token::switch_end)) |
2764 | 2417 { |
3665 | 2418 octave_comment_list *tc = octave_comment_buffer::get_comment (); |
2419 | |
2764 | 2420 int l = switch_tok->line (); |
2421 int c = switch_tok->column (); | |
2422 | |
8842
be7b30a24938
line/column info for switch and if statements
John W. Eaton <jwe@octave.org>
parents:
8828
diff
changeset
|
2423 if (list && ! list->empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2424 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2425 tree_switch_case *elt = list->front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2426 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2427 if (elt) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2428 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2429 elt->line (l); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2430 elt->column (c); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2431 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2432 } |
8842
be7b30a24938
line/column info for switch and if statements
John W. Eaton <jwe@octave.org>
parents:
8828
diff
changeset
|
2433 |
3665 | 2434 retval = new tree_switch_command (expr, list, lc, tc, l, c); |
2764 | 2435 } |
2436 | |
2437 return retval; | |
2438 } | |
2439 | |
2440 // Build a switch case. | |
2441 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2442 tree_switch_case * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2443 octave_parser::make_switch_case (token *case_tok, tree_expression *expr, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2444 tree_statement_list *list, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2445 octave_comment_list *lc) |
2764 | 2446 { |
2447 maybe_warn_variable_switch_label (expr); | |
2448 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2449 int l = case_tok->line (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2450 int c = case_tok->column (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2451 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2452 return new tree_switch_case (expr, list, lc, l, c); |
2764 | 2453 } |
2454 | |
1623 | 2455 // Build an assignment to a variable. |
2456 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2457 tree_expression * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2458 octave_parser::make_assign_op (int op, tree_argument_list *lhs, token *eq_tok, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2459 tree_expression *rhs) |
1623 | 2460 { |
2970 | 2461 tree_expression *retval = 0; |
2462 | |
2883 | 2463 octave_value::assign_op t = octave_value::unknown_assign_op; |
2464 | |
2465 switch (op) | |
2466 { | |
2467 case '=': | |
3525 | 2468 t = octave_value::op_asn_eq; |
2883 | 2469 break; |
2470 | |
2471 case ADD_EQ: | |
3525 | 2472 t = octave_value::op_add_eq; |
2883 | 2473 break; |
2474 | |
2475 case SUB_EQ: | |
3525 | 2476 t = octave_value::op_sub_eq; |
2883 | 2477 break; |
2478 | |
2479 case MUL_EQ: | |
3525 | 2480 t = octave_value::op_mul_eq; |
2883 | 2481 break; |
2482 | |
2483 case DIV_EQ: | |
3525 | 2484 t = octave_value::op_div_eq; |
2883 | 2485 break; |
2486 | |
3204 | 2487 case LEFTDIV_EQ: |
3525 | 2488 t = octave_value::op_ldiv_eq; |
3204 | 2489 break; |
2490 | |
4018 | 2491 case POW_EQ: |
2492 t = octave_value::op_pow_eq; | |
2493 break; | |
2494 | |
2899 | 2495 case LSHIFT_EQ: |
3525 | 2496 t = octave_value::op_lshift_eq; |
2899 | 2497 break; |
2498 | |
2499 case RSHIFT_EQ: | |
3525 | 2500 t = octave_value::op_rshift_eq; |
2899 | 2501 break; |
2502 | |
2883 | 2503 case EMUL_EQ: |
3525 | 2504 t = octave_value::op_el_mul_eq; |
2883 | 2505 break; |
2506 | |
2507 case EDIV_EQ: | |
3525 | 2508 t = octave_value::op_el_div_eq; |
2883 | 2509 break; |
2510 | |
3204 | 2511 case ELEFTDIV_EQ: |
3525 | 2512 t = octave_value::op_el_ldiv_eq; |
3204 | 2513 break; |
2514 | |
4018 | 2515 case EPOW_EQ: |
2516 t = octave_value::op_el_pow_eq; | |
2517 break; | |
2518 | |
2883 | 2519 case AND_EQ: |
3525 | 2520 t = octave_value::op_el_and_eq; |
2883 | 2521 break; |
2522 | |
2523 case OR_EQ: | |
3525 | 2524 t = octave_value::op_el_or_eq; |
2883 | 2525 break; |
2526 | |
2527 default: | |
2528 panic_impossible (); | |
2529 break; | |
2530 } | |
2531 | |
1623 | 2532 int l = eq_tok->line (); |
2533 int c = eq_tok->column (); | |
2534 | |
5841 | 2535 if (lhs->is_simple_assign_lhs ()) |
666 | 2536 { |
2970 | 2537 tree_expression *tmp = lhs->remove_front (); |
2538 | |
2539 retval = new tree_simple_assignment (tmp, rhs, false, l, c, t); | |
2540 | |
2541 delete lhs; | |
666 | 2542 } |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10207
diff
changeset
|
2543 else if (t == octave_value::op_asn_eq) |
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10207
diff
changeset
|
2544 return new tree_multi_assignment (lhs, rhs, false, l, c); |
666 | 2545 else |
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
|
2546 bison_error ("computed multiple assignment not allowed"); |
666 | 2547 |
2548 return retval; | |
2549 } | |
751 | 2550 |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2551 // Define a script. |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2552 |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2553 void |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2554 octave_parser::make_script (tree_statement_list *cmds, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2555 tree_statement *end_script) |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2556 { |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2557 if (! cmds) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2558 cmds = new tree_statement_list (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2559 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2560 cmds->append (end_script); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2561 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2562 octave_user_script *script |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2563 = new octave_user_script (curr_lexer->fcn_file_full_name, |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2564 curr_lexer->fcn_file_name, |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2565 cmds, curr_lexer->help_text); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2566 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2567 curr_lexer->help_text = ""; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2568 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2569 octave_time now; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2570 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2571 script->stash_fcn_file_time (now); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2572 |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2573 primary_fcn_ptr = script; |
8881
8ed42c679af5
after defining a script or function, clear local variables created for parsing
John W. Eaton <jwe@octave.org>
parents:
8842
diff
changeset
|
2574 |
9009
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8974
diff
changeset
|
2575 // Unmark any symbols that may have been tagged as local variables |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8974
diff
changeset
|
2576 // while parsing (for example, by force_local_variable in lex.l). |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8974
diff
changeset
|
2577 |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8974
diff
changeset
|
2578 symbol_table::unmark_forced_variables (); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2579 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2580 |
1623 | 2581 // Begin defining a function. |
2582 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2583 octave_user_function * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2584 octave_parser::start_function (tree_parameter_list *param_list, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2585 tree_statement_list *body, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2586 tree_statement *end_fcn_stmt) |
1623 | 2587 { |
2891 | 2588 // We'll fill in the return list later. |
2589 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2590 if (! body) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2591 body = new tree_statement_list (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2592 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2593 body->append (end_fcn_stmt); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2594 |
2891 | 2595 octave_user_function *fcn |
7336 | 2596 = new octave_user_function (symbol_table::current_scope (), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2597 param_list, 0, body); |
1623 | 2598 |
3665 | 2599 if (fcn) |
2600 { | |
2601 octave_comment_list *tc = octave_comment_buffer::get_comment (); | |
2602 | |
2603 fcn->stash_trailing_comment (tc); | |
2604 } | |
2605 | |
1623 | 2606 return fcn; |
2607 } | |
2608 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2609 tree_statement * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2610 octave_parser::make_end (const std::string& type, int l, int c) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2611 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2612 return make_statement (new tree_no_op_command (type, l, c)); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2613 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
2614 |
1623 | 2615 // Do most of the work for defining a function. |
2616 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2617 octave_user_function * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2618 octave_parser::frob_function (const std::string& fname, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2619 octave_user_function *fcn) |
1623 | 2620 { |
4872 | 2621 std::string id_name = fname; |
1623 | 2622 |
2623 // If input is coming from a file, issue a warning if the name of | |
2624 // the file does not match the name of the function stated in the | |
2625 // file. Matlab doesn't provide a diagnostic (it ignores the stated | |
2626 // name). | |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16198
diff
changeset
|
2627 if (! autoloading && curr_lexer->reading_fcn_file |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
2628 && curr_fcn_depth == 1 && ! parsing_subfunctions) |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2629 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2630 // FIXME -- should curr_lexer->fcn_file_name already be |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2631 // preprocessed when we get here? It seems to only be a |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2632 // problem with relative file names. |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2633 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2634 std::string nm = curr_lexer->fcn_file_name; |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2635 |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2636 size_t pos = nm.find_last_of (file_ops::dir_sep_chars ()); |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2637 |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2638 if (pos != std::string::npos) |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2639 nm = curr_lexer->fcn_file_name.substr (pos+1); |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2640 |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2641 if (nm != id_name) |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2642 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2643 warning_with_id |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2644 ("Octave:function-name-clash", |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
2645 "function name '%s' does not agree with function file name '%s'", |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2646 id_name.c_str (), curr_lexer->fcn_file_full_name.c_str ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2647 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2648 id_name = nm; |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2649 } |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2650 } |
1623 | 2651 |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16198
diff
changeset
|
2652 if (curr_lexer->reading_fcn_file || curr_lexer->reading_classdef_file || autoloading) |
1623 | 2653 { |
3712 | 2654 octave_time now; |
3162 | 2655 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2656 fcn->stash_fcn_file_name (curr_lexer->fcn_file_full_name); |
3162 | 2657 fcn->stash_fcn_file_time (now); |
1623 | 2658 fcn->mark_as_system_fcn_file (); |
3162 | 2659 |
6323 | 2660 if (fcn_file_from_relative_lookup) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2661 fcn->mark_relative (); |
6323 | 2662 |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
2663 if (curr_fcn_depth > 1 || parsing_subfunctions) |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7903
diff
changeset
|
2664 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2665 fcn->stash_parent_fcn_name (curr_lexer->fcn_file_name); |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2666 |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
2667 if (curr_fcn_depth > 1) |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14584
diff
changeset
|
2668 fcn->stash_parent_fcn_scope (function_scopes[function_scopes.size ()-2]); |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2669 else |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2670 fcn->stash_parent_fcn_scope (primary_fcn_scope); |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2671 } |
6323 | 2672 |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2673 if (curr_lexer->parsing_class_method) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2674 { |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
2675 if (curr_class_name == id_name) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2676 fcn->mark_as_class_constructor (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2677 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2678 fcn->mark_as_class_method (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2679 |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
2680 fcn->stash_dispatch_class (curr_class_name); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2681 } |
7336 | 2682 |
5781 | 2683 std::string nm = fcn->fcn_file_name (); |
2684 | |
2685 file_stat fs (nm); | |
2686 | |
2687 if (fs && fs.is_newer (now)) | |
2688 warning_with_id ("Octave:future-time-stamp", | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
2689 "time stamp for '%s' is in the future", nm.c_str ()); |
1623 | 2690 } |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2691 else if (! input_from_tmp_history_file |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2692 && ! curr_lexer->force_script |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16198
diff
changeset
|
2693 && curr_lexer->reading_script_file |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2694 && curr_lexer->fcn_file_name == id_name) |
1623 | 2695 { |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
2696 warning ("function '%s' defined within script file '%s'", |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2697 id_name.c_str (), curr_lexer->fcn_file_full_name.c_str ()); |
1623 | 2698 } |
2699 | |
4872 | 2700 fcn->stash_function_name (id_name); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2701 fcn->stash_fcn_location (curr_lexer->input_line_number, |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2702 curr_lexer->current_input_column); |
4872 | 2703 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2704 if (! curr_lexer->help_text.empty () && curr_fcn_depth == 1 |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2705 && ! parsing_subfunctions) |
7336 | 2706 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2707 fcn->document (curr_lexer->help_text); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2708 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2709 curr_lexer->help_text = ""; |
7336 | 2710 } |
2711 | |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16198
diff
changeset
|
2712 if (curr_lexer->reading_fcn_file && curr_fcn_depth == 1 |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2713 && ! parsing_subfunctions) |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2714 primary_fcn_ptr = fcn; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2715 |
1623 | 2716 return fcn; |
2717 } | |
2718 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2719 tree_function_def * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2720 octave_parser::finish_function (tree_parameter_list *ret_list, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2721 octave_user_function *fcn, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2722 octave_comment_list *lc) |
1623 | 2723 { |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2724 tree_function_def *retval = 0; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2725 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2726 if (ret_list) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2727 ret_list->mark_as_formal_parameters (); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2728 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2729 if (fcn) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2730 { |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7755
diff
changeset
|
2731 std::string nm = fcn->name (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7755
diff
changeset
|
2732 std::string file = fcn->fcn_file_name (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7755
diff
changeset
|
2733 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7755
diff
changeset
|
2734 std::string tmp = nm; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7755
diff
changeset
|
2735 if (! file.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2736 tmp += ": " + file; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7755
diff
changeset
|
2737 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7755
diff
changeset
|
2738 symbol_table::cache_name (fcn->scope (), tmp); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7755
diff
changeset
|
2739 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2740 if (lc) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2741 fcn->stash_leading_comment (lc); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2742 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2743 fcn->define_ret_list (ret_list); |
7755
ea9cb4d68dbf
avoid installing subfunctions twice
John W. Eaton <jwe@octave.org>
parents:
7750
diff
changeset
|
2744 |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
2745 if (curr_fcn_depth > 1 || parsing_subfunctions) |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2746 { |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11388
diff
changeset
|
2747 fcn->mark_as_subfunction (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2748 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2749 if (endfunction_found && function_scopes.size () > 1) |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2750 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2751 symbol_table::scope_id pscope |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14584
diff
changeset
|
2752 = function_scopes[function_scopes.size ()-2]; |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2753 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2754 symbol_table::install_nestfunction (nm, octave_value (fcn), |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2755 pscope); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2756 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2757 else |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2758 symbol_table::install_subfunction (nm, octave_value (fcn), |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2759 primary_fcn_scope); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2760 } |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2761 |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
2762 if (curr_fcn_depth == 1 && fcn) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2763 symbol_table::update_nest (fcn->scope ()); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2764 |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16198
diff
changeset
|
2765 if (! curr_lexer->reading_fcn_file && curr_fcn_depth == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2766 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2767 // We are either reading a script file or defining a function |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2768 // at the command line, so this definition creates a |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2769 // tree_function object that is placed in the parse tree. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2770 // Otherwise, it is just inserted in the symbol table, |
14512
e0d66b8b0c63
Avoid double delete for nested functions in commandline
Max Brister <max@2bass.com>
parents:
14507
diff
changeset
|
2771 // either as a subfunction or nested function (see above), |
e0d66b8b0c63
Avoid double delete for nested functions in commandline
Max Brister <max@2bass.com>
parents:
14507
diff
changeset
|
2772 // or as the primary function for the file, via |
e0d66b8b0c63
Avoid double delete for nested functions in commandline
Max Brister <max@2bass.com>
parents:
14507
diff
changeset
|
2773 // primary_fcn_ptr (see also load_fcn_from_file,, |
e0d66b8b0c63
Avoid double delete for nested functions in commandline
Max Brister <max@2bass.com>
parents:
14507
diff
changeset
|
2774 // parse_fcn_file, and |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2775 // symbol_table::fcn_info::fcn_info_rep::find_user_function). |
9761
5f8971be8e12
parse.y (finish_function): retrun function object unless parsing function file
John W. Eaton <jwe@octave.org>
parents:
9506
diff
changeset
|
2776 |
5f8971be8e12
parse.y (finish_function): retrun function object unless parsing function file
John W. Eaton <jwe@octave.org>
parents:
9506
diff
changeset
|
2777 retval = new tree_function_def (fcn); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2778 } |
8282
47a3d2f829e4
clear local symbol table after parsing function
John W. Eaton <jwe@octave.org>
parents:
8150
diff
changeset
|
2779 |
9009
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8974
diff
changeset
|
2780 // Unmark any symbols that may have been tagged as local |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8974
diff
changeset
|
2781 // variables while parsing (for example, by force_local_variable |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8974
diff
changeset
|
2782 // in lex.l). |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8974
diff
changeset
|
2783 |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8974
diff
changeset
|
2784 symbol_table::unmark_forced_variables (fcn->scope ()); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2785 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2786 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
2787 return retval; |
1623 | 2788 } |
2789 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2790 void |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2791 octave_parser::recover_from_parsing_function (void) |
2883 | 2792 { |
14329
8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents:
14294
diff
changeset
|
2793 if (parser_symtab_context.empty ()) |
3903 | 2794 panic_impossible (); |
2795 | |
14329
8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents:
14294
diff
changeset
|
2796 parser_symtab_context.pop (); |
2883 | 2797 |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16198
diff
changeset
|
2798 if (curr_lexer->reading_fcn_file && curr_fcn_depth == 1 |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2799 && ! parsing_subfunctions) |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2800 parsing_subfunctions = true; |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2801 |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
2802 curr_fcn_depth--; |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14533
diff
changeset
|
2803 function_scopes.pop_back (); |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
2804 |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2805 curr_lexer->defining_func--; |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2806 curr_lexer->parsed_function_name.pop (); |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2807 curr_lexer->looking_at_return_list = false; |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2808 curr_lexer->looking_at_parameter_list = false; |
2883 | 2809 } |
2810 | |
2846 | 2811 // Make an index expression. |
2812 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2813 tree_index_expression * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2814 octave_parser::make_index_expression (tree_expression *expr, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2815 tree_argument_list *args, char type) |
751 | 2816 { |
2817 tree_index_expression *retval = 0; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2818 |
10206
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10188
diff
changeset
|
2819 if (args && args->has_magic_tilde ()) |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10188
diff
changeset
|
2820 { |
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
|
2821 bison_error ("invalid use of empty argument (~) in index expression"); |
10206
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10188
diff
changeset
|
2822 return retval; |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10188
diff
changeset
|
2823 } |
751 | 2824 |
2970 | 2825 int l = expr->line (); |
2826 int c = expr->column (); | |
2827 | |
2828 expr->mark_postfix_indexed (); | |
2829 | |
3933 | 2830 if (expr->is_index_expression ()) |
2831 { | |
2832 tree_index_expression *tmp = static_cast<tree_index_expression *> (expr); | |
2833 | |
2834 tmp->append (args, type); | |
2835 | |
2836 retval = tmp; | |
2837 } | |
2838 else | |
2839 retval = new tree_index_expression (expr, args, l, c, type); | |
2970 | 2840 |
2841 return retval; | |
2842 } | |
2843 | |
2844 // Make an indirect reference expression. | |
2845 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2846 tree_index_expression * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2847 octave_parser::make_indirect_ref (tree_expression *expr, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2848 const std::string& elt) |
2970 | 2849 { |
3930 | 2850 tree_index_expression *retval = 0; |
2970 | 2851 |
2852 int l = expr->line (); | |
2853 int c = expr->column (); | |
2854 | |
3933 | 2855 if (expr->is_index_expression ()) |
2856 { | |
2857 tree_index_expression *tmp = static_cast<tree_index_expression *> (expr); | |
2858 | |
2859 tmp->append (elt); | |
2860 | |
2861 retval = tmp; | |
2862 } | |
2863 else | |
2864 retval = new tree_index_expression (expr, elt, l, c); | |
2970 | 2865 |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2866 curr_lexer->looking_at_indirect_ref = false; |
751 | 2867 |
2868 return retval; | |
2869 } | |
1511 | 2870 |
4131 | 2871 // Make an indirect reference expression with dynamic field name. |
2872 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2873 tree_index_expression * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2874 octave_parser::make_indirect_ref (tree_expression *expr, tree_expression *elt) |
4131 | 2875 { |
2876 tree_index_expression *retval = 0; | |
2877 | |
2878 int l = expr->line (); | |
2879 int c = expr->column (); | |
2880 | |
2881 if (expr->is_index_expression ()) | |
2882 { | |
2883 tree_index_expression *tmp = static_cast<tree_index_expression *> (expr); | |
2884 | |
2885 tmp->append (elt); | |
2886 | |
2887 retval = tmp; | |
2888 } | |
2889 else | |
2890 retval = new tree_index_expression (expr, elt, l, c); | |
2891 | |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16109
diff
changeset
|
2892 curr_lexer->looking_at_indirect_ref = false; |
4131 | 2893 |
2894 return retval; | |
2895 } | |
2896 | |
2846 | 2897 // Make a declaration command. |
2898 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2899 tree_decl_command * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2900 octave_parser::make_decl_command (int tok, token *tok_val, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2901 tree_decl_init_list *lst) |
2846 | 2902 { |
2903 tree_decl_command *retval = 0; | |
2904 | |
2905 int l = tok_val->line (); | |
2906 int c = tok_val->column (); | |
2907 | |
2908 switch (tok) | |
2909 { | |
2910 case GLOBAL: | |
2911 retval = new tree_global_command (lst, l, c); | |
2912 break; | |
2913 | |
14294
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14293
diff
changeset
|
2914 case PERSISTENT: |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
2915 if (curr_fcn_depth > 0) |
14294
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14293
diff
changeset
|
2916 retval = new tree_persistent_command (lst, l, c); |
2846 | 2917 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2918 { |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16198
diff
changeset
|
2919 if (curr_lexer->reading_script_file) |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
2920 warning ("ignoring persistent declaration near line %d of file '%s'", |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2921 l, curr_lexer->fcn_file_full_name.c_str ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2922 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2923 warning ("ignoring persistent declaration near line %d", l); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2924 } |
2846 | 2925 break; |
2926 | |
2927 default: | |
2928 panic_impossible (); | |
2929 break; | |
2930 } | |
2931 | |
2932 return retval; | |
2933 } | |
2934 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2935 tree_argument_list * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2936 octave_parser::validate_matrix_row (tree_argument_list *row) |
10207
76a880a588ce
error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents:
10206
diff
changeset
|
2937 { |
76a880a588ce
error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents:
10206
diff
changeset
|
2938 if (row && row->has_magic_tilde ()) |
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
|
2939 bison_error ("invalid use of tilde (~) in matrix expression"); |
10207
76a880a588ce
error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents:
10206
diff
changeset
|
2940 return row; |
76a880a588ce
error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents:
10206
diff
changeset
|
2941 } |
76a880a588ce
error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents:
10206
diff
changeset
|
2942 |
16237
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2943 // Finish building an array_list. |
1623 | 2944 |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2945 tree_expression * |
16237
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2946 octave_parser::finish_array_list (tree_array_list *array_list) |
1623 | 2947 { |
16237
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2948 tree_expression *retval = array_list; |
3110 | 2949 |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
2950 unwind_protect frame; |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
2951 |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
2952 frame.protect_var (error_state); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
2953 frame.protect_var (warning_state); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
2954 |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
2955 frame.protect_var (discard_error_messages); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
2956 frame.protect_var (discard_warning_messages); |
4452 | 2957 |
3815 | 2958 discard_error_messages = true; |
4452 | 2959 discard_warning_messages = true; |
1623 | 2960 |
16237
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2961 if (array_list->all_elements_are_constant ()) |
1829 | 2962 { |
16237
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2963 octave_value tmp = array_list->rvalue1 (); |
1623 | 2964 |
3489 | 2965 if (! (error_state || warning_state)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2966 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2967 tree_constant *tc_retval |
16237
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2968 = new tree_constant (tmp, array_list->line (), |
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2969 array_list->column ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2970 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2971 std::ostringstream buf; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2972 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2973 tree_print_code tpc (buf); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2974 |
16237
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2975 array_list->accept (tpc); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2976 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2977 tc_retval->stash_original_text (buf.str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2978 |
16237
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2979 delete array_list; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2980 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2981 retval = tc_retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2982 } |
1623 | 2983 } |
3110 | 2984 |
1623 | 2985 return retval; |
2986 } | |
2987 | |
16237
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2988 // Finish building a matrix list. |
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2989 |
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2990 tree_expression * |
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2991 octave_parser::finish_matrix (tree_matrix *m) |
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2992 { |
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2993 return finish_array_list (m); |
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2994 } |
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
2995 |
3351 | 2996 // Finish building a cell list. |
2997 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2998 tree_expression * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
2999 octave_parser::finish_cell (tree_cell *c) |
3351 | 3000 { |
16237
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
3001 return finish_array_list (c); |
3351 | 3002 } |
3003 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
3004 void |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
3005 octave_parser::maybe_warn_missing_semi (tree_statement_list *t) |
1511 | 3006 { |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3007 if (curr_fcn_depth > 0) |
1511 | 3008 { |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14584
diff
changeset
|
3009 tree_statement *tmp = t->back (); |
1607 | 3010 |
1511 | 3011 if (tmp->is_expression ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3012 warning_with_id |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3013 ("Octave:missing-semicolon", |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
3014 "missing semicolon near line %d, column %d in file '%s'", |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3015 tmp->line (), tmp->column (), curr_lexer->fcn_file_full_name.c_str ()); |
1511 | 3016 } |
3017 } | |
1994 | 3018 |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
3019 tree_statement_list * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
3020 octave_parser::set_stmt_print_flag (tree_statement_list *list, char sep, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
3021 bool warn_missing_semi) |
2525 | 3022 { |
8471
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3023 tree_statement *tmp = list->back (); |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3024 |
2525 | 3025 switch (sep) |
3026 { | |
3027 case ';': | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
3028 tmp->set_print_flag (false); |
2525 | 3029 break; |
3030 | |
3031 case 0: | |
3032 case ',': | |
3033 case '\n': | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
3034 tmp->set_print_flag (true); |
2525 | 3035 if (warn_missing_semi) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3036 maybe_warn_missing_semi (list); |
2525 | 3037 break; |
3038 | |
3039 default: | |
3040 warning ("unrecognized separator type!"); | |
3041 break; | |
3042 } | |
8471
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3043 |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3044 // Even if a statement is null, we add it to the list then remove it |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3045 // here so that the print flag is applied to the correct statement. |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3046 |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3047 if (tmp->is_null_statement ()) |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3048 { |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3049 list->pop_back (); |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3050 delete tmp; |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3051 } |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3052 |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3053 return list; |
2525 | 3054 } |
3055 | |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
3056 tree_statement_list * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
3057 octave_parser::make_statement_list (tree_statement *stmt) |
8448
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
3058 { |
8471
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3059 return new tree_statement_list (stmt); |
8448
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
3060 } |
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
3061 |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
3062 tree_statement_list * |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
3063 octave_parser::append_statement_list (tree_statement_list *list, char sep, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
3064 tree_statement *stmt, |
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16133
diff
changeset
|
3065 bool warn_missing_semi) |
8448
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
3066 { |
8471
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3067 set_stmt_print_flag (list, sep, warn_missing_semi); |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3068 |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3069 list->append (stmt); |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3070 |
02de6775f1fe
parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents:
8448
diff
changeset
|
3071 return list; |
8448
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
3072 } |
d6c0d5f208de
parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents:
8447
diff
changeset
|
3073 |
16145
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3074 void |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3075 octave_parser::bison_error (const char *s) |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3076 { |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3077 int err_col = curr_lexer->current_input_column - 1; |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3078 |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3079 std::ostringstream output_buf; |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3080 |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16198
diff
changeset
|
3081 if (curr_lexer->reading_fcn_file || curr_lexer->reading_script_file || curr_lexer->reading_classdef_file) |
16145
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3082 output_buf << "parse error near line " << curr_lexer->input_line_number |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3083 << " of file " << curr_lexer->fcn_file_full_name; |
16145
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3084 else |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3085 output_buf << "parse error:"; |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3086 |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3087 if (s && strcmp (s, "parse error") != 0) |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3088 output_buf << "\n\n " << s; |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3089 |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3090 output_buf << "\n\n"; |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3091 |
16207
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
3092 std::string curr_line = curr_lexer->current_input_line; |
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
3093 |
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
3094 if (! curr_line.empty ()) |
16145
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3095 { |
16207
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
3096 size_t len = curr_line.length (); |
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
3097 |
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
3098 if (curr_line[len-1] == '\n') |
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
3099 curr_line.resize (len-1); |
16145
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3100 |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3101 // Print the line, maybe with a pointer near the error token. |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3102 |
16207
0467d68ca891
move current_input_line to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
3103 output_buf << ">>> " << curr_line << "\n"; |
16145
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3104 |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3105 if (err_col == 0) |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3106 err_col = len; |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3107 |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3108 for (int i = 0; i < err_col + 3; i++) |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3109 output_buf << " "; |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3110 |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3111 output_buf << "^"; |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3112 } |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3113 |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3114 output_buf << "\n"; |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3115 |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3116 std::string msg = output_buf.str (); |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3117 |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3118 parse_error ("%s", msg.c_str ()); |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3119 } |
edddf8903f15
maint: reorder functions in oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
16142
diff
changeset
|
3120 |
3021 | 3121 static void |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
3122 safe_fclose (FILE *f) |
3021 | 3123 { |
5775 | 3124 // FIXME -- comments at the end of an input file are |
3765 | 3125 // discarded (otherwise, they would be appended to the next |
3126 // statement, possibly from the command line or another file, which | |
3127 // can be quite confusing). | |
3128 | |
5308 | 3129 octave_comment_list *tc = octave_comment_buffer::get_comment (); |
3130 | |
3131 delete tc; | |
3765 | 3132 |
3021 | 3133 if (f) |
3134 fclose (static_cast<FILE *> (f)); | |
3135 } | |
3136 | |
7336 | 3137 static octave_function * |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3138 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
|
3139 const std::string& dispatch_type, |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3140 bool require_file, bool force_script, bool autoload, |
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3141 bool relative_lookup, const std::string& warn_for) |
3021 | 3142 { |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
3143 unwind_protect frame; |
3021 | 3144 |
7336 | 3145 octave_function *fcn_ptr = 0; |
3021 | 3146 |
3147 // Open function file and parse. | |
3148 | |
3149 FILE *in_stream = command_editor::get_input_stream (); | |
3150 | |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
3151 frame.add_fcn (command_editor::set_input_stream, in_stream); |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
3152 |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12973
diff
changeset
|
3153 frame.add_fcn (command_history::ignore_entries, |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12973
diff
changeset
|
3154 command_history::ignoring_entries ()); |
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12973
diff
changeset
|
3155 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3156 command_history::ignore_entries (); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3157 |
16198
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
3158 FILE *ffile = 0; |
2c5c538be353
clean up input.cc and eliminate ff_instream global variable
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
3159 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3160 if (! full_file.empty ()) |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3161 ffile = gnulib::fopen (full_file.c_str (), "rb"); |
3021 | 3162 |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
3163 frame.add_fcn (safe_fclose, ffile); |
3021 | 3164 |
3165 if (ffile) | |
3166 { | |
7720
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
3167 bool eof; |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
3168 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
3169 // octave_parser constructor sets this for us. |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
3170 frame.protect_var (CURR_LEXER); |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
3171 |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
3172 octave_parser curr_parser (ffile); |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
3173 |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
3174 curr_parser.curr_class_name = dispatch_type; |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
3175 curr_parser.autoloading = autoload; |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
3176 curr_parser.fcn_file_from_relative_lookup = relative_lookup; |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3177 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3178 // Do this with an unwind-protect cleanup function so that |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3179 // the forced variables will be unmarked in the event of an |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3180 // interrupt. |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3181 symbol_table::scope_id scope = symbol_table::top_scope (); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3182 frame.add_fcn (symbol_table::unmark_forced_variables, scope); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3183 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3184 curr_parser.curr_lexer->force_script = force_script; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3185 curr_parser.curr_lexer->prep_for_file (); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3186 curr_parser.curr_lexer->parsing_class_method = ! dispatch_type.empty (); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3187 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3188 curr_parser.curr_lexer->fcn_file_name = file; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3189 curr_parser.curr_lexer->fcn_file_full_name = full_file; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3190 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3191 int status = curr_parser.run (); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3192 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3193 fcn_ptr = curr_parser.primary_fcn_ptr; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3194 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3195 if (status != 0) |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3196 error ("parse error while reading file %s", full_file.c_str ()); |
3021 | 3197 } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3198 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
|
3199 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
|
3200 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
|
3201 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
|
3202 full_file.c_str ()); |
3021 | 3203 |
7336 | 3204 return fcn_ptr; |
3021 | 3205 } |
3206 | |
5484 | 3207 std::string |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3208 get_help_from_file (const std::string& nm, bool& symbol_found, |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3209 std::string& full_file) |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3210 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3211 std::string retval; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3212 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3213 full_file = fcn_file_in_path (nm); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3214 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3215 std::string file = full_file; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3216 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3217 size_t file_len = file.length (); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3218 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3219 if ((file_len > 4 && file.substr (file_len-4) == ".oct") |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3220 || (file_len > 4 && file.substr (file_len-4) == ".mex") |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3221 || (file_len > 2 && file.substr (file_len-2) == ".m")) |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3222 { |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3223 file = octave_env::base_pathname (file); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3224 file = file.substr (0, file.find_last_of ('.')); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3225 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3226 size_t pos = file.find_last_of (file_ops::dir_sep_str ()); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3227 if (pos != std::string::npos) |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3228 file = file.substr (pos+1); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3229 } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3230 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3231 if (! file.empty ()) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3232 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3233 symbol_found = true; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3234 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3235 octave_function *fcn |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3236 = parse_fcn_file (full_file, file, "", true, false, false, false, ""); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3237 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3238 if (fcn) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3239 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3240 retval = fcn->doc_string (); |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3241 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3242 delete fcn; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3243 } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3244 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3245 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3246 return retval; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3247 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3248 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3249 std::string |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3250 get_help_from_file (const std::string& nm, bool& symbol_found) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3251 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3252 std::string file; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3253 return get_help_from_file (nm, symbol_found, file); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3254 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3255 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3256 std::string |
5484 | 3257 lookup_autoload (const std::string& nm) |
3258 { | |
5626 | 3259 std::string retval; |
3260 | |
3261 typedef std::map<std::string, std::string>::const_iterator am_iter; | |
3262 | |
3263 am_iter p = autoload_map.find (nm); | |
3264 | |
3265 if (p != autoload_map.end ()) | |
6323 | 3266 retval = load_path::find_file (p->second); |
5626 | 3267 |
3268 return retval; | |
5484 | 3269 } |
3270 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
3271 string_vector |
5592 | 3272 autoloaded_functions (void) |
3273 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14584
diff
changeset
|
3274 string_vector names (autoload_map.size ()); |
5592 | 3275 |
3276 octave_idx_type i = 0; | |
5626 | 3277 typedef std::map<std::string, std::string>::const_iterator am_iter; |
3278 for (am_iter p = autoload_map.begin (); p != autoload_map.end (); p++) | |
5592 | 3279 names[i++] = p->first; |
3280 | |
3281 return names; | |
3282 } | |
3283 | |
3284 string_vector | |
3285 reverse_lookup_autoload (const std::string& nm) | |
3286 { | |
3287 string_vector names; | |
3288 | |
5626 | 3289 typedef std::map<std::string, std::string>::const_iterator am_iter; |
3290 for (am_iter p = autoload_map.begin (); p != autoload_map.end (); p++) | |
5592 | 3291 if (nm == p->second) |
3292 names.append (p->first); | |
3293 | |
3294 return names; | |
3295 } | |
3296 | |
7336 | 3297 octave_function * |
3298 load_fcn_from_file (const std::string& file_name, const std::string& dir_name, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3299 const std::string& dispatch_type, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3300 const std::string& fcn_name, bool autoload) |
3021 | 3301 { |
7336 | 3302 octave_function *retval = 0; |
3303 | |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
3304 unwind_protect frame; |
5484 | 3305 |
7336 | 3306 std::string nm = file_name; |
6238 | 3307 |
3308 size_t nm_len = nm.length (); | |
5472 | 3309 |
3310 std::string file; | |
3311 | |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3312 bool relative_lookup = false; |
6323 | 3313 |
7336 | 3314 file = nm; |
3315 | |
3316 if ((nm_len > 4 && nm.substr (nm_len-4) == ".oct") | |
3317 || (nm_len > 4 && nm.substr (nm_len-4) == ".mex") | |
3318 || (nm_len > 2 && nm.substr (nm_len-2) == ".m")) | |
5472 | 3319 { |
6238 | 3320 nm = octave_env::base_pathname (file); |
3321 nm = nm.substr (0, nm.find_last_of ('.')); | |
11136
a51ac4198e1c
oct-parse.yy (load_fcn_from_file): also strip directory when computing function name from filename
John W. Eaton <jwe@octave.org>
parents:
11091
diff
changeset
|
3322 |
a51ac4198e1c
oct-parse.yy (load_fcn_from_file): also strip directory when computing function name from filename
John W. Eaton <jwe@octave.org>
parents:
11091
diff
changeset
|
3323 size_t pos = nm.find_last_of (file_ops::dir_sep_str ()); |
a51ac4198e1c
oct-parse.yy (load_fcn_from_file): also strip directory when computing function name from filename
John W. Eaton <jwe@octave.org>
parents:
11091
diff
changeset
|
3324 if (pos != std::string::npos) |
11138
40206fe759db
oct-parse.yy: fix typo in previous change
John W. Eaton <jwe@octave.org>
parents:
11136
diff
changeset
|
3325 nm = nm.substr (pos+1); |
5472 | 3326 } |
7336 | 3327 |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3328 relative_lookup = ! octave_env::absolute_pathname (file); |
7749
14e05160b99f
reference counting for functions loaded from shared libraries
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
3329 |
10250 | 3330 file = octave_env::make_absolute (file); |
4243 | 3331 |
3332 int len = file.length (); | |
3333 | |
4244 | 3334 if (len > 4 && file.substr (len-4, len-1) == ".oct") |
3021 | 3335 { |
7336 | 3336 if (autoload && ! fcn_name.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3337 nm = fcn_name; |
7336 | 3338 |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3339 retval = octave_dynamic_loader::load_oct (nm, file, relative_lookup); |
5864 | 3340 } |
3341 else if (len > 4 && file.substr (len-4, len-1) == ".mex") | |
10570
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
3342 { |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
3343 // Temporarily load m-file version of mex-file, if it exists, |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
3344 // to get the help-string to use. |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
3345 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
3346 octave_function *tmpfcn = parse_fcn_file (file.substr (0, len - 2), |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3347 nm, dispatch_type, false, |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3348 autoload, autoload, |
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3349 relative_lookup, ""); |
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3350 |
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3351 retval = octave_dynamic_loader::load_mex (nm, file, relative_lookup); |
10570
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
3352 |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
3353 if (tmpfcn) |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
3354 retval->document (tmpfcn->doc_string ()); |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
3355 delete tmpfcn; |
a61d7248627c
When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents:
10521
diff
changeset
|
3356 } |
4244 | 3357 else if (len > 2) |
3021 | 3358 { |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3359 retval = parse_fcn_file (file, nm, dispatch_type, true, autoload, |
16153
a57c2c8c8163
move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents:
16151
diff
changeset
|
3360 autoload, relative_lookup, ""); |
3021 | 3361 } |
3362 | |
7336 | 3363 if (retval) |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
3364 { |
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
3365 retval->stash_dir_name (dir_name); |
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
3366 |
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
3367 if (retval->is_user_function ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3368 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3369 symbol_table::scope_id id = retval->scope (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3370 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3371 symbol_table::stash_dir_name_for_subfunctions (id, dir_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3372 } |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
3373 } |
7336 | 3374 |
3375 return retval; | |
5312 | 3376 } |
3377 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
3378 DEFUN (autoload, args, , |
5484 | 3379 "-*- texinfo -*-\n\ |
3380 @deftypefn {Built-in Function} {} autoload (@var{function}, @var{file})\n\ | |
3381 Define @var{function} to autoload from @var{file}.\n\ | |
5626 | 3382 \n\ |
6926 | 3383 The second argument, @var{file}, should be an absolute file name or\n\ |
3384 a file name in the same directory as the function or script from which\n\ | |
9038
fca0dc2fb042
Cleanup documentation files stmt.texi and func.texi
Rik <rdrider0-list@yahoo.com>
parents:
8974
diff
changeset
|
3385 the autoload command was run. @var{file} should not depend on the\n\ |
6926 | 3386 Octave load path.\n\ |
6380 | 3387 \n\ |
3388 Normally, calls to @code{autoload} appear in PKG_ADD script files that\n\ | |
3389 are evaluated when a directory is added to the Octave's load path. To\n\ | |
6926 | 3390 avoid having to hardcode directory names in @var{file}, if @var{file}\n\ |
3391 is in the same directory as the PKG_ADD script then\n\ | |
6380 | 3392 \n\ |
3393 @example\n\ | |
6926 | 3394 autoload (\"foo\", \"bar.oct\");\n\ |
6380 | 3395 @end example\n\ |
3396 \n\ | |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
3397 @noindent\n\ |
9038
fca0dc2fb042
Cleanup documentation files stmt.texi and func.texi
Rik <rdrider0-list@yahoo.com>
parents:
8974
diff
changeset
|
3398 will load the function @code{foo} from the file @code{bar.oct}. The above\n\ |
6926 | 3399 when @code{bar.oct} is not in the same directory or uses like\n\ |
6380 | 3400 \n\ |
3401 @example\n\ | |
6637 | 3402 autoload (\"foo\", file_in_loadpath (\"bar.oct\"))\n\ |
6380 | 3403 @end example\n\ |
3404 \n\ | |
3405 @noindent\n\ | |
6926 | 3406 are strongly discouraged, as their behavior might be unpredictable.\n\ |
6380 | 3407 \n\ |
6637 | 3408 With no arguments, return a structure containing the current autoload map.\n\ |
6380 | 3409 @seealso{PKG_ADD}\n\ |
5484 | 3410 @end deftypefn") |
3411 { | |
5626 | 3412 octave_value retval; |
5484 | 3413 |
3414 int nargin = args.length (); | |
3415 | |
5626 | 3416 if (nargin == 0) |
3417 { | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
3418 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
|
3419 Cell file_names (dim_vector (autoload_map.size (), 1)); |
5626 | 3420 |
3421 octave_idx_type i = 0; | |
3422 typedef std::map<std::string, std::string>::const_iterator am_iter; | |
3423 for (am_iter p = autoload_map.begin (); p != autoload_map.end (); p++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3424 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3425 func_names(i) = p->first; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3426 file_names(i) = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3427 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3428 i++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3429 } |
5626 | 3430 |
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
|
3431 octave_map m; |
5626 | 3432 |
3433 m.assign ("function", func_names); | |
3434 m.assign ("file", file_names); | |
3435 | |
3436 retval = m; | |
3437 } | |
3438 else if (nargin == 2) | |
5484 | 3439 { |
3440 string_vector argv = args.make_argv ("autoload"); | |
3441 | |
3442 if (! error_state) | |
6380 | 3443 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3444 std::string nm = argv[2]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3445 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3446 if (! octave_env::absolute_pathname (nm)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3447 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3448 octave_user_code *fcn = octave_call_stack::caller_user_code (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3449 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3450 bool found = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3451 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3452 if (fcn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3453 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3454 std::string fname = fcn->fcn_file_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3455 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3456 if (! fname.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3457 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3458 fname = octave_env::make_absolute (fname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3459 fname = fname.substr (0, fname.find_last_of (file_ops::dir_sep_str ()) + 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3460 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3461 file_stat fs (fname + nm); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3462 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3463 if (fs.exists ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3464 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3465 nm = fname + nm; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3466 found = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3467 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3468 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3469 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3470 if (! found) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3471 warning_with_id ("Octave:autoload-relative-file-name", |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
3472 "autoload: '%s' is not an absolute file name", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3473 nm.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3474 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3475 autoload_map[argv[1]] = nm; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3476 } |
5484 | 3477 } |
3478 else | |
5823 | 3479 print_usage (); |
5484 | 3480 |
3481 return retval; | |
3482 } | |
3483 | |
4486 | 3484 void |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3485 source_file (const std::string& file_name, const std::string& context, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3486 bool verbose, bool require_file, const std::string& warn_for) |
4486 | 3487 { |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3488 // Map from absolute name of script file to recursion level. We |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3489 // use a map instead of simply placing a limit on recursion in the |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3490 // source_file function so that two mutually recursive scripts |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3491 // written as |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3492 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3493 // foo1.m: |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3494 // ------ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3495 // foo2 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3496 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3497 // foo2.m: |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3498 // ------ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3499 // foo1 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3500 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3501 // and called with |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3502 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3503 // foo1 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3504 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3505 // (for example) will behave the same if they are written as |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3506 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3507 // foo1.m: |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3508 // ------ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3509 // source ("foo2.m") |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3510 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3511 // foo2.m: |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3512 // ------ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3513 // source ("foo1.m") |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3514 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3515 // and called with |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3516 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3517 // source ("foo1.m") |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3518 // |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3519 // (for example). |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3520 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3521 static std::map<std::string, int> source_call_depth; |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3522 |
4486 | 3523 std::string file_full_name = file_ops::tilde_expand (file_name); |
3524 | |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3525 file_full_name = octave_env::make_absolute (file_full_name); |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3526 |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
3527 unwind_protect frame; |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
3528 |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3529 if (source_call_depth.find (file_full_name) == source_call_depth.end ()) |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3530 source_call_depth[file_full_name] = -1; |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3531 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3532 frame.protect_var (source_call_depth[file_full_name]); |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3533 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3534 source_call_depth[file_full_name]++; |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3535 |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3536 if (source_call_depth[file_full_name] >= Vmax_recursion_depth) |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3537 { |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3538 error ("max_recursion_depth exceeded"); |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3539 return; |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3540 } |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10570
diff
changeset
|
3541 |
5975 | 3542 if (! context.empty ()) |
3543 { | |
3544 if (context == "caller") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3545 octave_call_stack::goto_caller_frame (); |
5975 | 3546 else if (context == "base") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3547 octave_call_stack::goto_base_frame (); |
5975 | 3548 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3549 error ("source: context must be \"caller\" or \"base\""); |
7336 | 3550 |
3551 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3552 frame.add_fcn (octave_call_stack::pop); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
3553 } |
5975 | 3554 |
3555 if (! error_state) | |
3556 { | |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3557 octave_function *fcn = parse_fcn_file (file_full_name, file_name, |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3558 "", require_file, true, |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
3559 false, false, warn_for); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3560 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3561 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3562 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3563 if (fcn && fcn->is_user_script ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3564 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3565 octave_value_list args; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3566 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3567 if (verbose) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3568 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3569 std::cout << "executing commands from " << file_full_name << " ... "; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3570 reading_startup_message_printed = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3571 std::cout.flush (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3572 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3573 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3574 fcn->do_multi_index_op (0, args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3575 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3576 if (verbose) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3577 std::cout << "done." << std::endl; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3578 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3579 delete fcn; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3580 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3581 } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
3582 else |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
3583 error ("source: error sourcing file '%s'", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3584 file_full_name.c_str ()); |
5975 | 3585 } |
4486 | 3586 } |
3587 | |
5739 | 3588 DEFUN (mfilename, args, , |
3589 "-*- texinfo -*-\n\ | |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
3590 @deftypefn {Built-in Function} {} mfilename ()\n\ |
12719
7b5bfd6a8e28
doc: Don't use @code macro within @deftypefn macro
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
3591 @deftypefnx {Built-in Function} {} mfilename (\"fullpath\")\n\ |
7b5bfd6a8e28
doc: Don't use @code macro within @deftypefn macro
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
3592 @deftypefnx {Built-in Function} {} mfilename (\"fullpathext\")\n\ |
5739 | 3593 Return the name of the currently executing file. At the top-level,\n\ |
3594 return the empty string. Given the argument @code{\"fullpath\"},\n\ | |
3595 include the directory part of the file name, but not the extension.\n\ | |
3596 Given the argument @code{\"fullpathext\"}, include the directory part\n\ | |
3597 of the file name and the extension.\n\ | |
5774 | 3598 @end deftypefn") |
5739 | 3599 { |
3600 octave_value retval; | |
3601 | |
3602 int nargin = args.length (); | |
3603 | |
3604 if (nargin > 1) | |
3605 { | |
5823 | 3606 print_usage (); |
5739 | 3607 return retval; |
3608 } | |
3609 | |
3610 std::string arg; | |
3611 | |
3612 if (nargin == 1) | |
3613 { | |
3614 arg = args(0).string_value (); | |
3615 | |
3616 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3617 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3618 error ("mfilename: expecting argument to be a character string"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3619 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3620 } |
5739 | 3621 } |
3622 | |
3623 std::string fname; | |
3624 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
3625 octave_user_code *fcn = octave_call_stack::caller_user_code (); |
5743 | 3626 |
3627 if (fcn) | |
3628 { | |
3629 fname = fcn->fcn_file_name (); | |
3630 | |
3631 if (fname.empty ()) | |
3632 fname = fcn->name (); | |
3633 } | |
5739 | 3634 |
3635 if (arg == "fullpathext") | |
3636 retval = fname; | |
3637 else | |
3638 { | |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
8001
diff
changeset
|
3639 size_t dpos = fname.rfind (file_ops::dir_sep_char ()); |
5747 | 3640 size_t epos = fname.rfind ('.'); |
3641 | |
3642 if (epos <= dpos) | |
8021 | 3643 epos = std::string::npos; |
3644 | |
3645 fname = (epos != std::string::npos) ? fname.substr (0, epos) : fname; | |
5739 | 3646 |
3647 if (arg == "fullpath") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3648 retval = fname; |
5739 | 3649 else |
8021 | 3650 retval = (dpos != std::string::npos) ? fname.substr (dpos+1) : fname; |
5739 | 3651 } |
3652 | |
3653 return retval; | |
3654 } | |
3655 | |
3656 | |
3021 | 3657 DEFUN (source, args, , |
3371 | 3658 "-*- texinfo -*-\n\ |
3659 @deftypefn {Built-in Function} {} source (@var{file})\n\ | |
3660 Parse and execute the contents of @var{file}. This is equivalent to\n\ | |
3661 executing commands from a script file, but without requiring the file to\n\ | |
3662 be named @file{@var{file}.m}.\n\ | |
3663 @end deftypefn") | |
3021 | 3664 { |
3665 octave_value_list retval; | |
3666 | |
3667 int nargin = args.length (); | |
3668 | |
5975 | 3669 if (nargin == 1 || nargin == 2) |
3021 | 3670 { |
3523 | 3671 std::string file_name = args(0).string_value (); |
3021 | 3672 |
3673 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3674 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3675 std::string context; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3676 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3677 if (nargin == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3678 context = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3679 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3680 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3681 source_file (file_name, context); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3682 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3683 error ("source: expecting context to be character string"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3684 } |
3021 | 3685 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3686 error ("source: expecting file name as argument"); |
3021 | 3687 } |
3688 else | |
5823 | 3689 print_usage (); |
3021 | 3690 |
3691 return retval; | |
3692 } | |
3693 | |
3726 | 3694 // Evaluate an Octave function (built-in or interpreted) and return |
3844 | 3695 // the list of result values. NAME is the name of the function to |
3696 // call. ARGS are the arguments to the function. NARGOUT is the | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
3697 // number of output arguments expected. |
3726 | 3698 |
3021 | 3699 octave_value_list |
3523 | 3700 feval (const std::string& name, const octave_value_list& args, int nargout) |
3156 | 3701 { |
3702 octave_value_list retval; | |
3703 | |
7336 | 3704 octave_value fcn = symbol_table::find_function (name, args); |
3705 | |
3706 if (fcn.is_defined ()) | |
3707 retval = fcn.do_multi_index_op (nargout, args); | |
3708 else | |
10443
34e51d4e199b
implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents:
10426
diff
changeset
|
3709 { |
34e51d4e199b
implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents:
10426
diff
changeset
|
3710 maybe_missing_function_hook (name); |
34e51d4e199b
implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents:
10426
diff
changeset
|
3711 if (! error_state) |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
3712 error ("feval: function '%s' not found", name.c_str ()); |
10443
34e51d4e199b
implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents:
10426
diff
changeset
|
3713 } |
3156 | 3714 |
3715 return retval; | |
3716 } | |
3717 | |
4342 | 3718 octave_value_list |
3719 feval (octave_function *fcn, const octave_value_list& args, int nargout) | |
3720 { | |
3721 octave_value_list retval; | |
3722 | |
3723 if (fcn) | |
3724 retval = fcn->do_multi_index_op (nargout, args); | |
3725 | |
3726 return retval; | |
3727 } | |
3728 | |
3729 static octave_value_list | |
3730 get_feval_args (const octave_value_list& args) | |
3731 { | |
10659
8baff2aceabc
fix slicing value lists with name tags (bug #29960)
Jaroslav Hajek <highegg@gmail.com>
parents:
10578
diff
changeset
|
3732 return args.slice (1, args.length () - 1, true); |
4342 | 3733 } |
3734 | |
3735 | |
3726 | 3736 // Evaluate an Octave function (built-in or interpreted) and return |
3737 // the list of result values. The first element of ARGS should be a | |
3738 // string containing the name of the function to call, then the rest | |
3739 // are the actual arguments to the function. NARGOUT is the number of | |
3740 // output arguments expected. | |
3741 | |
3156 | 3742 octave_value_list |
3021 | 3743 feval (const octave_value_list& args, int nargout) |
3744 { | |
3745 octave_value_list retval; | |
3746 | |
4342 | 3747 int nargin = args.length (); |
3748 | |
3749 if (nargin > 0) | |
3021 | 3750 { |
4342 | 3751 octave_value f_arg = args(0); |
3752 | |
3753 if (f_arg.is_string ()) | |
3754 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3755 std::string name = f_arg.string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3756 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3757 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3758 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3759 octave_value_list tmp_args = get_feval_args (args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3760 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3761 retval = feval (name, tmp_args, nargout); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3762 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3763 } |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
13237
diff
changeset
|
3764 else if (f_arg.is_function_handle () |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
13237
diff
changeset
|
3765 || f_arg.is_anonymous_function () |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
13237
diff
changeset
|
3766 || f_arg.is_inline_function ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3767 { |
10492
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10463
diff
changeset
|
3768 const octave_value_list tmp_args = get_feval_args (args); |
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10463
diff
changeset
|
3769 |
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10463
diff
changeset
|
3770 retval = f_arg.do_multi_index_op (nargout, tmp_args); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3771 } |
10492
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10463
diff
changeset
|
3772 else |
a6b64a7a3769
make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10463
diff
changeset
|
3773 error ("feval: first argument must be a string, inline function or a function handle"); |
3021 | 3774 } |
3775 | |
3776 return retval; | |
3777 } | |
3778 | |
3779 DEFUN (feval, args, nargout, | |
3371 | 3780 "-*- texinfo -*-\n\ |
3781 @deftypefn {Built-in Function} {} feval (@var{name}, @dots{})\n\ | |
3782 Evaluate the function named @var{name}. Any arguments after the first\n\ | |
3783 are passed on to the named function. For example,\n\ | |
3784 \n\ | |
3785 @example\n\ | |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
3786 @group\n\ |
3371 | 3787 feval (\"acos\", -1)\n\ |
3788 @result{} 3.1416\n\ | |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
3789 @end group\n\ |
3371 | 3790 @end example\n\ |
3021 | 3791 \n\ |
3371 | 3792 @noindent\n\ |
3793 calls the function @code{acos} with the argument @samp{-1}.\n\ | |
3794 \n\ | |
12946
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3795 The function @code{feval} can also be used with function handles of\n\ |
13019
1653d3a86fca
doc: Fix warnings and errors in Texinfo required for building docs on stable branch.
Rik <octave@nomad.inbox5.com>
parents:
12946
diff
changeset
|
3796 any sort (@pxref{Function Handles}). Historically, @code{feval} was\n\ |
12946
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3797 the only way to call user-supplied functions in strings, but\n\ |
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3798 function handles are now preferred due to the cleaner syntax they\n\ |
13019
1653d3a86fca
doc: Fix warnings and errors in Texinfo required for building docs on stable branch.
Rik <octave@nomad.inbox5.com>
parents:
12946
diff
changeset
|
3799 offer. For example,\n\ |
12946
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3800 \n\ |
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3801 @example\n\ |
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3802 @group\n\ |
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3803 @var{f} = @@exp;\n\ |
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3804 feval (@var{f}, 1)\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14329
diff
changeset
|
3805 @result{} 2.7183\n\ |
12946
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3806 @var{f} (1)\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14329
diff
changeset
|
3807 @result{} 2.7183\n\ |
12946
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3808 @end group\n\ |
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3809 @end example\n\ |
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3810 \n\ |
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3811 @noindent\n\ |
13019
1653d3a86fca
doc: Fix warnings and errors in Texinfo required for building docs on stable branch.
Rik <octave@nomad.inbox5.com>
parents:
12946
diff
changeset
|
3812 are equivalent ways to call the function referred to by @var{f}. If it\n\ |
12946
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3813 cannot be predicted beforehand that @var{f} is a function handle or the\n\ |
8b5b85e26246
octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12918
diff
changeset
|
3814 function name in a string, @code{feval} can be used instead.\n\ |
3371 | 3815 @end deftypefn") |
3021 | 3816 { |
3817 octave_value_list retval; | |
3818 | |
3819 int nargin = args.length (); | |
3820 | |
3821 if (nargin > 0) | |
3822 retval = feval (args, nargout); | |
3823 else | |
5823 | 3824 print_usage (); |
3021 | 3825 |
3826 return retval; | |
3827 } | |
3828 | |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3829 DEFUN (builtin, args, nargout, |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3830 "-*- texinfo -*-\n\ |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3831 @deftypefn {Loadable Function} {[@dots{}]} builtin (@var{f}, @dots{})\n\ |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3832 Call the base function @var{f} even if @var{f} is overloaded to\n\ |
11388
027fbc389898
Remove seealso reference to deprecated function dispatch.
Rik <octave@nomad.inbox5.com>
parents:
11367
diff
changeset
|
3833 another function for the given type signature.\n\ |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3834 @end deftypefn") |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3835 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
3836 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
|
3837 |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3838 int nargin = args.length (); |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3839 |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3840 if (nargin > 0) |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3841 { |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3842 const std::string name (args(0).string_value ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
3843 |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3844 if (! error_state) |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3845 { |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3846 octave_value fcn = symbol_table::builtin_find (name); |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3847 |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3848 if (fcn.is_defined ()) |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3849 retval = feval (fcn.function_value (), args.splice (0, 1), |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3850 nargout); |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3851 else |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
3852 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
|
3853 } |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3854 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12400
diff
changeset
|
3855 error ("builtin: function name (F) must be a string"); |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3856 } |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3857 else |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3858 print_usage (); |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3859 |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3860 return retval; |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3861 } |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
3862 |
3099 | 3863 octave_value_list |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
3864 eval_string (const std::string& eval_str, bool silent, |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
3865 int& parse_status, int nargout) |
3021 | 3866 { |
3877 | 3867 octave_value_list retval; |
3868 | |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
3869 unwind_protect frame; |
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
3870 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
3871 // octave_parser constructor sets this for us. |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
3872 frame.protect_var (CURR_LEXER); |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
3873 |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
3874 octave_parser curr_parser (eval_str); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
3875 |
3877 | 3876 do |
3877 { | |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
3878 curr_parser.reset (); |
4318 | 3879 |
9260
9c2349a51218
properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents:
9144
diff
changeset
|
3880 // Do this with an unwind-protect cleanup function so that the |
9c2349a51218
properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents:
9144
diff
changeset
|
3881 // forced variables will be unmarked in the event of an |
9c2349a51218
properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents:
9144
diff
changeset
|
3882 // interrupt. |
9c2349a51218
properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents:
9144
diff
changeset
|
3883 symbol_table::scope_id scope = symbol_table::top_scope (); |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
3884 frame.add_fcn (symbol_table::unmark_forced_variables, scope); |
9260
9c2349a51218
properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents:
9144
diff
changeset
|
3885 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
3886 parse_status = curr_parser.run (); |
3877 | 3887 |
9260
9c2349a51218
properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents:
9144
diff
changeset
|
3888 // Unmark forced variables. |
16177
a7669b4d27f6
eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents:
16174
diff
changeset
|
3889 frame.run (1); |
7903
8018e10d2b87
save and restore global_command as needed
John W. Eaton <jwe@octave.org>
parents:
7901
diff
changeset
|
3890 |
3883 | 3891 if (parse_status == 0) |
3877 | 3892 { |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
3893 if (curr_parser.stmt_list) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3894 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3895 tree_statement *stmt = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3896 |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
3897 if (curr_parser.stmt_list->length () == 1 |
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
3898 && (stmt = curr_parser.stmt_list->front ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3899 && stmt->is_expression ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3900 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3901 tree_expression *expr = stmt->expression (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3902 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3903 if (silent) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3904 expr->set_print_flag (false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3905 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3906 bool do_bind_ans = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3907 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3908 if (expr->is_identifier ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3909 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3910 tree_identifier *id |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3911 = dynamic_cast<tree_identifier *> (expr); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3912 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3913 do_bind_ans = (! id->is_variable ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3914 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3915 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3916 do_bind_ans = (! expr->is_assignment_expression ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3917 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3918 retval = expr->rvalue (nargout); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3919 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3920 if (do_bind_ans && ! (error_state || retval.empty ())) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3921 bind_ans (retval(0), expr->print_result ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3922 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3923 if (nargout == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3924 retval = octave_value_list (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3925 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3926 else if (nargout == 0) |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
3927 curr_parser.stmt_list->accept (*current_evaluator); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3928 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3929 error ("eval: invalid use of statement list"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3930 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3931 if (error_state |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3932 || tree_return_command::returning |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3933 || tree_break_command::breaking |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3934 || tree_continue_command::continuing) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3935 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3936 } |
16187
490625211945
don't use new to create parser object
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
3937 else if (curr_parser.curr_lexer->end_of_input) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3938 break; |
3883 | 3939 } |
3877 | 3940 } |
3941 while (parse_status == 0); | |
3021 | 3942 |
3943 return retval; | |
3944 } | |
3945 | |
3946 octave_value | |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
3947 eval_string (const std::string& eval_str, bool silent, int& parse_status) |
3021 | 3948 { |
3949 octave_value retval; | |
3950 | |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16187
diff
changeset
|
3951 octave_value_list tmp = eval_string (eval_str, silent, parse_status, 1); |
3021 | 3952 |
3953 if (! tmp.empty ()) | |
3954 retval = tmp(0); | |
3955 | |
3956 return retval; | |
3957 } | |
3958 | |
3959 static octave_value_list | |
3960 eval_string (const octave_value& arg, bool silent, int& parse_status, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
3961 int nargout) |
3021 | 3962 { |
3523 | 3963 std::string s = arg.string_value (); |
3021 | 3964 |
3965 if (error_state) | |
3966 { | |
3523 | 3967 error ("eval: expecting std::string argument"); |
4233 | 3968 return octave_value (-1); |
3021 | 3969 } |
3970 | |
3971 return eval_string (s, silent, parse_status, nargout); | |
3972 } | |
3973 | |
13970 | 3974 void |
3975 cleanup_statement_list (tree_statement_list **lst) | |
3976 { | |
3977 if (*lst) | |
3978 { | |
3979 delete *lst; | |
3980 *lst = 0; | |
3981 } | |
3982 } | |
3983 | |
3021 | 3984 DEFUN (eval, args, nargout, |
3371 | 3985 "-*- texinfo -*-\n\ |
14172
cba1c681f1b7
doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
3986 @deftypefn {Built-in Function} {} eval (@var{try})\n\ |
cba1c681f1b7
doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
3987 @deftypefnx {Built-in Function} {} eval (@var{try}, @var{catch})\n\ |
3371 | 3988 Parse the string @var{try} and evaluate it as if it were an Octave\n\ |
6643 | 3989 program. If that fails, evaluate the optional string @var{catch}.\n\ |
4463 | 3990 The string @var{try} is evaluated in the current context,\n\ |
3991 so any results remain available after @code{eval} returns.\n\ | |
6643 | 3992 \n\ |
3993 The following example makes the variable @var{a} with the approximate\n\ | |
3994 value 3.1416 available.\n\ | |
3995 \n\ | |
3996 @example\n\ | |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14329
diff
changeset
|
3997 eval (\"a = acos(-1);\");\n\ |
6643 | 3998 @end example\n\ |
3999 \n\ | |
4000 If an error occurs during the evaluation of @var{try} the @var{catch}\n\ | |
8828 | 4001 string is evaluated, as the following example shows:\n\ |
6643 | 4002 \n\ |
4003 @example\n\ | |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
4004 @group\n\ |
6643 | 4005 eval ('error (\"This is a bad example\");',\n\ |
8015
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
8007
diff
changeset
|
4006 'printf (\"This error occurred:\\n%s\\n\", lasterr ());');\n\ |
7001 | 4007 @print{} This error occurred:\n\ |
8015
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
8007
diff
changeset
|
4008 This is a bad example\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
4009 @end group\n\ |
6643 | 4010 @end example\n\ |
14172
cba1c681f1b7
doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
4011 \n\ |
cba1c681f1b7
doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
4012 Consider using try/catch blocks instead if you are only using @code{eval}\n\ |
cba1c681f1b7
doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
4013 as an error-capturing mechanism rather than for the execution of arbitrary\n\ |
cba1c681f1b7
doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
4014 code strings.\n\ |
cba1c681f1b7
doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
4015 @seealso{evalin}\n\ |
3371 | 4016 @end deftypefn") |
3021 | 4017 { |
4018 octave_value_list retval; | |
4019 | |
4020 int nargin = args.length (); | |
4021 | |
4022 if (nargin > 0) | |
4023 { | |
10067
6f79338c269b
omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
4024 unwind_protect frame; |
3021 | 4025 |
4026 if (nargin > 1) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4027 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4028 frame.protect_var (buffer_error_messages); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4029 buffer_error_messages++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4030 } |
3021 | 4031 |
4032 int parse_status = 0; | |
4033 | |
4463 | 4034 octave_value_list tmp = eval_string (args(0), nargout > 0, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4035 parse_status, nargout); |
4463 | 4036 |
3021 | 4037 if (nargin > 1 && (parse_status != 0 || error_state)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4038 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4039 error_state = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4040 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4041 // Set up for letting the user print any messages from |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4042 // errors that occurred in the first part of this eval(). |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4043 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4044 buffer_error_messages--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4045 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4046 tmp = eval_string (args(1), nargout > 0, parse_status, nargout); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4047 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4048 if (nargout > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4049 retval = tmp; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4050 } |
8033
2ad5ba320b93
parse.y (Feval): Return value produced by evaluating CATCH string
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
4051 else if (nargout > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4052 retval = tmp; |
3021 | 4053 } |
4054 else | |
5823 | 4055 print_usage (); |
3021 | 4056 |
4057 return retval; | |
4058 } | |
4059 | |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
4060 /* |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
4061 |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4062 %!shared x |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
4063 %! x = 1; |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4064 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4065 %!assert (eval ("x"), 1) |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4066 %!assert (eval ("x;")) |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4067 %!assert (eval ("x;"), 1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4068 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
4069 %!test |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4070 %! y = eval ("x"); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4071 %! assert (y, 1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4072 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4073 %!test |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4074 %! y = eval ("x;"); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4075 %! assert (y, 1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4076 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4077 %!test |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4078 %! eval ("x = 1;") |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4079 %! assert (x,1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4080 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
4081 %!test |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
4082 %! eval ("flipud = 2;"); |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4083 %! assert (flipud, 2); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4084 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4085 %!function y = __f () |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
4086 %! eval ("flipud = 2;"); |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
4087 %! y = flipud; |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4088 %!endfunction |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
4089 %!assert (__f(), 2) |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
4090 |
14533
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
4091 % bug #35645 |
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
4092 %!test |
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
4093 %! [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
|
4094 %! [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
|
4095 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
4096 */ |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
4097 |
4661 | 4098 DEFUN (assignin, args, , |
4297 | 4099 "-*- texinfo -*-\n\ |
4100 @deftypefn {Built-in Function} {} assignin (@var{context}, @var{varname}, @var{value})\n\ | |
4101 Assign @var{value} to @var{varname} in context @var{context}, which\n\ | |
4102 may be either @code{\"base\"} or @code{\"caller\"}.\n\ | |
14172
cba1c681f1b7
doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
4103 @seealso{evalin}\n\ |
4297 | 4104 @end deftypefn") |
4105 { | |
4106 octave_value_list retval; | |
4107 | |
4108 int nargin = args.length (); | |
4109 | |
4110 if (nargin == 3) | |
4111 { | |
4112 std::string context = args(0).string_value (); | |
4113 | |
4114 if (! error_state) | |
4115 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4116 unwind_protect frame; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4117 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4118 if (context == "caller") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4119 octave_call_stack::goto_caller_frame (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4120 else if (context == "base") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4121 octave_call_stack::goto_base_frame (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4122 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12400
diff
changeset
|
4123 error ("assignin: CONTEXT must be \"caller\" or \"base\""); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4124 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4125 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4126 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4127 frame.add_fcn (octave_call_stack::pop); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4128 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4129 std::string nm = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4130 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4131 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4132 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4133 if (valid_identifier (nm)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4134 symbol_table::varref (nm) = args(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4135 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12400
diff
changeset
|
4136 error ("assignin: invalid variable name in argument VARNAME"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4137 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4138 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12400
diff
changeset
|
4139 error ("assignin: VARNAME must be a string"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4140 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4141 } |
4297 | 4142 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12400
diff
changeset
|
4143 error ("assignin: CONTEXT must be a string"); |
4297 | 4144 } |
4145 else | |
5823 | 4146 print_usage (); |
4297 | 4147 |
4148 return retval; | |
4149 } | |
4150 | |
4245 | 4151 DEFUN (evalin, args, nargout, |
4152 "-*- texinfo -*-\n\ | |
14172
cba1c681f1b7
doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
4153 @deftypefn {Built-in Function} {} evalin (@var{context}, @var{try})\n\ |
cba1c681f1b7
doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
4154 @deftypefnx {Built-in Function} {} evalin (@var{context}, @var{try}, @var{catch})\n\ |
4245 | 4155 Like @code{eval}, except that the expressions are evaluated in the\n\ |
4156 context @var{context}, which may be either @code{\"caller\"} or\n\ | |
4246 | 4157 @code{\"base\"}.\n\ |
14172
cba1c681f1b7
doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
4158 @seealso{eval, assignin}\n\ |
4245 | 4159 @end deftypefn") |
4160 { | |
4161 octave_value_list retval; | |
4162 | |
4163 int nargin = args.length (); | |
4164 | |
4165 if (nargin > 1) | |
4166 { | |
4167 std::string context = args(0).string_value (); | |
4168 | |
4169 if (! error_state) | |
4170 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4171 unwind_protect frame; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4172 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4173 if (context == "caller") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4174 octave_call_stack::goto_caller_frame (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4175 else if (context == "base") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4176 octave_call_stack::goto_base_frame (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4177 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12400
diff
changeset
|
4178 error ("evalin: CONTEXT must be \"caller\" or \"base\""); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4179 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4180 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4181 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4182 frame.add_fcn (octave_call_stack::pop); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4183 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4184 if (nargin > 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4185 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4186 frame.protect_var (buffer_error_messages); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4187 buffer_error_messages++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4188 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4189 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4190 int parse_status = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4191 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4192 octave_value_list tmp = eval_string (args(1), nargout > 0, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4193 parse_status, nargout); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4194 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4195 if (nargout > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4196 retval = tmp; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4197 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4198 if (nargin > 2 && (parse_status != 0 || error_state)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4199 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4200 error_state = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4201 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4202 // Set up for letting the user print any messages from |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4203 // errors that occurred in the first part of this eval(). |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4204 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4205 buffer_error_messages--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4206 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4207 tmp = eval_string (args(2), nargout > 0, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4208 parse_status, nargout); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4209 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4210 retval = (nargout > 0) ? tmp : octave_value_list (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4211 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4212 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
4213 } |
4245 | 4214 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12400
diff
changeset
|
4215 error ("evalin: CONTEXT must be a string"); |
4245 | 4216 } |
4217 else | |
5823 | 4218 print_usage (); |
4245 | 4219 |
4220 return retval; | |
4221 } | |
4222 | |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4223 DEFUN (__parser_debug_flag__, args, nargout, |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
4224 "-*- texinfo -*-\n\ |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
4225 @deftypefn {Built-in Function} {@var{old_val} =} __parser_debug_flag__ (@var{new_val}))\n\ |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
4226 Undocumented internal function.\n\ |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
4227 @end deftypefn") |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4228 { |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4229 octave_value retval; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4230 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4231 bool debug_flag = octave_debug; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4232 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4233 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
|
4234 "__parser_debug_flag__"); |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4235 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4236 octave_debug = debug_flag; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4237 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4238 return retval; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
4239 } |