Mercurial > octave
annotate libinterp/parse-tree/oct-parse.yy @ 31090:1779a64b2510
maint: Merge stable to default
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Fri, 10 Jun 2022 18:57:17 -0400 |
parents | 037c1e768b56 4b6f03d7264a |
children | 670a0d878af1 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30328
diff
changeset
|
3 // Copyright (C) 1993-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
1 | 25 |
26 // Parser for Octave. | |
27 | |
767 | 28 // C decarations. |
29 | |
1 | 30 %{ |
21023
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
31 |
1 | 32 #define YYDEBUG 1 |
33 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21707
diff
changeset
|
34 #if defined (HAVE_CONFIG_H) |
22003
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
35 # include "config.h" |
240 | 36 #endif |
37 | |
3178 | 38 #include <cassert> |
10463
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
39 #include <cstdio> |
bbe99b2a5ba7
undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents:
10447
diff
changeset
|
40 #include <cstdlib> |
2427 | 41 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
42 #include <iostream> |
5484 | 43 #include <map> |
5765 | 44 #include <sstream> |
5484 | 45 |
1 | 46 #include "Matrix.h" |
3021 | 47 #include "cmd-edit.h" |
48 #include "cmd-hist.h" | |
49 #include "file-ops.h" | |
50 #include "file-stat.h" | |
4243 | 51 #include "oct-env.h" |
3712 | 52 #include "oct-time.h" |
4171 | 53 #include "quit.h" |
1 | 54 |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
22003
diff
changeset
|
55 #include "Cell.h" |
27728
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
56 #include "anon-fcn-validator.h" |
23454
30b6eccd6708
use builtin-defun-decls.h to ensure declarations of interpreter functions
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
57 #include "builtin-defun-decls.h" |
2166 | 58 #include "defun.h" |
3021 | 59 #include "dynamic-ld.h" |
1351 | 60 #include "error.h" |
61 #include "input.h" | |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
62 #include "interpreter-private.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
63 #include "interpreter.h" |
1351 | 64 #include "lex.h" |
5832 | 65 #include "load-path.h" |
25517
7fbc39a46be8
Add wrapper to fopen for files with non-ASCII chars in path on Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25442
diff
changeset
|
66 #include "lo-sysdep.h" |
1743 | 67 #include "oct-hist.h" |
5626 | 68 #include "oct-map.h" |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
69 #include "ov-classdef.h" |
4935 | 70 #include "ov-fcn-handle.h" |
2970 | 71 #include "ov-usr-fcn.h" |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8064
diff
changeset
|
72 #include "ov-null-mat.h" |
1351 | 73 #include "pager.h" |
74 #include "parse.h" | |
2987 | 75 #include "pt-all.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8471
diff
changeset
|
76 #include "pt-eval.h" |
1351 | 77 #include "symtab.h" |
78 #include "token.h" | |
3021 | 79 #include "unwind-prot.h" |
1 | 80 #include "utils.h" |
1351 | 81 #include "variables.h" |
1 | 82 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
83 // oct-parse.h must be included after pt-all.h |
23479
06bf3a0b08bf
maint: Use "" instead of <> for our own include files.
John W. Eaton <jwe@octave.org>
parents:
23473
diff
changeset
|
84 #include "oct-parse.h" |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
85 |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
86 extern int octave_lex (YYSTYPE *, void *); |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
87 |
496 | 88 // Forward declarations for some functions defined at the bottom of |
89 // the file. | |
90 | |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
91 static void yyerror (octave::base_parser& parser, const char *s); |
1 | 92 |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
93 #define lexer (parser.get_lexer ()) |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
94 #define scanner lexer.m_scanner |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
95 |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
96 // Previous versions of Octave used Bison's YYUSE macro to avoid |
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
97 // warnings about unused values in rules. But that Bison macro was |
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
98 // apparently never intended to be public. So define our own. All we |
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
99 // need to do is mention the symantic value somewhere in the rule. It |
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
100 // doesn't actually need to be used to avoid the Bison warning, so just |
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
101 // define this macro to discard its parameter. |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
102 #define OCTAVE_YYUSE(X, ...) |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
103 |
21023
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
104 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) |
24444
53ca76c5cc8d
maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents:
24377
diff
changeset
|
105 // Disable this warning for code that is generated by Bison, |
53ca76c5cc8d
maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents:
24377
diff
changeset
|
106 // including grammar rules. Push the current state so we can |
53ca76c5cc8d
maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents:
24377
diff
changeset
|
107 // restore the warning state prior to functions we define at |
53ca76c5cc8d
maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents:
24377
diff
changeset
|
108 // the bottom of the file. |
53ca76c5cc8d
maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents:
24377
diff
changeset
|
109 # pragma GCC diagnostic push |
53ca76c5cc8d
maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents:
24377
diff
changeset
|
110 # pragma GCC diagnostic ignored "-Wold-style-cast" |
21023
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
111 #endif |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
112 |
1 | 113 %} |
114 | |
666 | 115 // Bison declarations. |
116 | |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
117 // The grammar currently has 9 shift/reduce conflicts. Ensure that |
17743
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
118 // we notice if that number changes. |
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
119 |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
120 %expect 9 |
17743
af5ad573c665
oct-parse.in.yy: Add %expect declaration.
John W. Eaton <jwe@octave.org>
parents:
17731
diff
changeset
|
121 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
122 // 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
|
123 // 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
|
124 // reentrant because both still use many global variables. It should be |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
125 // safe to create a parser object and call it while another parser |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
126 // 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
|
127 // 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
|
128 // 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
|
129 // 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
|
130 |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
131 %define api.pure |
25640
7aaf091d39fc
one more fix for parser change... Doh!
John W. Eaton <jwe@octave.org>
parents:
25638
diff
changeset
|
132 // No spaces inside the braces for the prefix and push-pull definitions! |
7aaf091d39fc
one more fix for parser change... Doh!
John W. Eaton <jwe@octave.org>
parents:
25638
diff
changeset
|
133 %define api.prefix {octave_} |
25644
bee8d60413f3
avoid bison warning about deprecated syntax
John W. Eaton <jwe@octave.org>
parents:
25640
diff
changeset
|
134 %define api.push-pull both |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
135 %parse-param { octave::base_parser& parser } |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
136 %lex-param { void *lexer.scanner } |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
137 |
1 | 138 %union |
139 { | |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
140 int dummy_type; |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
141 |
2891 | 142 // The type of the basic tokens returned by the lexer. |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
143 octave::token *tok_val; |
143 | 144 |
3665 | 145 // Comment strings that we need to deal with mid-rule. |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
146 octave::comment_list *comment_type; |
3665 | 147 |
2891 | 148 // Types for the nonterminals we generate. |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
149 char punct_type; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
150 octave::tree *tree_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
151 octave::tree_matrix *tree_matrix_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
152 octave::tree_cell *tree_cell_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
153 octave::tree_expression *tree_expression_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
154 octave::tree_constant *tree_constant_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
155 octave::tree_fcn_handle *tree_fcn_handle_type; |
26686
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
156 octave::tree_superclass_ref *tree_superclass_ref_type; |
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
157 octave::tree_metaclass_query *tree_metaclass_query_type; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
158 octave::tree_function_def *tree_function_def_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
159 octave::tree_anon_fcn_handle *tree_anon_fcn_handle_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
160 octave::tree_identifier *tree_identifier_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
161 octave::tree_index_expression *tree_index_expression_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
162 octave::tree_colon_expression *tree_colon_expression_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
163 octave::tree_argument_list *tree_argument_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
164 octave::tree_parameter_list *tree_parameter_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
165 octave::tree_command *tree_command_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
166 octave::tree_if_command *tree_if_command_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
167 octave::tree_if_clause *tree_if_clause_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
168 octave::tree_if_command_list *tree_if_command_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
169 octave::tree_switch_command *tree_switch_command_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
170 octave::tree_switch_case *tree_switch_case_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
171 octave::tree_switch_case_list *tree_switch_case_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
172 octave::tree_decl_elt *tree_decl_elt_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
173 octave::tree_decl_init_list *tree_decl_init_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
174 octave::tree_decl_command *tree_decl_command_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
175 octave::tree_statement *tree_statement_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
176 octave::tree_statement_list *tree_statement_list_type; |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
177 octave::tree_arguments_block *tree_arguments_block_type; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
178 octave::tree_args_block_attribute_list *tree_args_block_attribute_list_type; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
179 octave::tree_args_block_validation_list *tree_args_block_validation_list_type; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
180 octave::tree_arg_size_spec *tree_arg_size_spec_type; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
181 octave::tree_arg_validation *tree_arg_validation_type; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
182 octave::tree_arg_validation_fcns *tree_arg_validation_fcns_type; |
2891 | 183 octave_user_function *octave_user_function_type; |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
184 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
185 octave::tree_classdef *tree_classdef_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
186 octave::tree_classdef_attribute* tree_classdef_attribute_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
187 octave::tree_classdef_attribute_list* tree_classdef_attribute_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
188 octave::tree_classdef_superclass* tree_classdef_superclass_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
189 octave::tree_classdef_superclass_list* tree_classdef_superclass_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
190 octave::tree_classdef_body* tree_classdef_body_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
191 octave::tree_classdef_property* tree_classdef_property_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
192 octave::tree_classdef_property_list* tree_classdef_property_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
193 octave::tree_classdef_properties_block* tree_classdef_properties_block_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
194 octave::tree_classdef_methods_list* tree_classdef_methods_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
195 octave::tree_classdef_methods_block* tree_classdef_methods_block_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
196 octave::tree_classdef_event* tree_classdef_event_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
197 octave::tree_classdef_events_list* tree_classdef_events_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
198 octave::tree_classdef_events_block* tree_classdef_events_block_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
199 octave::tree_classdef_enum* tree_classdef_enum_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
200 octave::tree_classdef_enum_list* tree_classdef_enum_list_type; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
201 octave::tree_classdef_enum_block* tree_classdef_enum_block_type; |
1 | 202 } |
203 | |
143 | 204 // Tokens with line and column information. |
205 %token <tok_val> '=' ':' '-' '+' '*' '/' | |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
206 %token <tok_val> '(' ')' '[' ']' '{' '}' '.' '@' |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
207 %token <tok_val> ',' ';' '\n' |
4018 | 208 %token <tok_val> ADD_EQ SUB_EQ MUL_EQ DIV_EQ LEFTDIV_EQ POW_EQ |
209 %token <tok_val> EMUL_EQ EDIV_EQ ELEFTDIV_EQ EPOW_EQ AND_EQ OR_EQ | |
428 | 210 %token <tok_val> EXPR_AND_AND EXPR_OR_OR |
143 | 211 %token <tok_val> EXPR_AND EXPR_OR EXPR_NOT |
212 %token <tok_val> EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT | |
30328
a2397a85d7e5
deprecate .+ and .- operators
John W. Eaton <jwe@octave.org>
parents:
30259
diff
changeset
|
213 %token <tok_val> LEFTDIV EMUL EDIV ELEFTDIV |
16284
09881dab3aaf
* lex.ll, oct-parse.in.yy (HERMITIAN): Rename token from QUOTE.
John W. Eaton <jwe@octave.org>
parents:
16279
diff
changeset
|
214 %token <tok_val> HERMITIAN TRANSPOSE |
143 | 215 %token <tok_val> PLUS_PLUS MINUS_MINUS POW EPOW |
28582
dc8de424fc72
use octave_value object to store numeric tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
28548
diff
changeset
|
216 %token <tok_val> NUMBER |
2970 | 217 %token <tok_val> STRUCT_ELT |
2883 | 218 %token <tok_val> NAME |
143 | 219 %token <tok_val> END |
5279 | 220 %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
|
221 %token <tok_val> FOR PARFOR WHILE DO UNTIL |
28517
6e8a9845d118
Add 'spmd' as interpreter keyword for Matlab compatibility (bug #58676).
Rik <rik@octave.org>
parents:
28516
diff
changeset
|
222 %token <tok_val> SPMD |
1491 | 223 %token <tok_val> IF ELSEIF ELSE |
2764 | 224 %token <tok_val> SWITCH CASE OTHERWISE |
1491 | 225 %token <tok_val> BREAK CONTINUE FUNC_RET |
924 | 226 %token <tok_val> UNWIND CLEANUP |
1489 | 227 %token <tok_val> TRY CATCH |
14294
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14293
diff
changeset
|
228 %token <tok_val> GLOBAL PERSISTENT |
4342 | 229 %token <tok_val> FCN_HANDLE |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
230 %token <tok_val> CLASSDEF |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
231 %token <tok_val> PROPERTIES METHODS EVENTS ENUMERATION |
9476 | 232 %token <tok_val> METAQUERY |
233 %token <tok_val> SUPERCLASSREF | |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
234 %token <tok_val> FQ_IDENT |
9476 | 235 %token <tok_val> GET SET |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
236 %token <tok_val> FCN |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
237 %token <tok_val> ARGUMENTS |
21064
a9f2c2d72892
handle lexical errors as parser errors (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21063
diff
changeset
|
238 %token <tok_val> LEXICAL_ERROR |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
239 %token <tok_val> END_OF_INPUT |
1 | 240 |
143 | 241 // Other tokens. |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
242 %token <dummy_type> INPUT_FILE |
7587
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7562
diff
changeset
|
243 // %token VARARGIN VARARGOUT |
1 | 244 |
143 | 245 // Nonterminals we construct. |
29727
05d7b7e64811
eliminate unused lexical feedback flag
John W. Eaton <jwe@octave.org>
parents:
29724
diff
changeset
|
246 %type <dummy_type> indirect_ref_op |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
247 %type <dummy_type> push_fcn_symtab push_script_symtab begin_file |
27736
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
248 %type <dummy_type> param_list_beg param_list_end stmt_begin anon_fcn_begin |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
249 %type <dummy_type> parsing_local_fcns parse_error at_first_executable_stmt |
16644
856cb7cba231
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
250 %type <comment_type> stash_comment |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
251 %type <tok_val> function_beg classdef_beg arguments_beg |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
252 %type <tok_val> properties_beg methods_beg events_beg enumeration_beg |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
253 %type <punct_type> sep_no_nl opt_sep_no_nl nl opt_nl sep opt_sep |
578 | 254 %type <tree_type> input |
5861 | 255 %type <tree_constant_type> string constant magic_colon |
256 %type <tree_anon_fcn_handle_type> anon_fcn_handle | |
4342 | 257 %type <tree_fcn_handle_type> fcn_handle |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
258 %type <tree_matrix_type> matrix_rows |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
259 %type <tree_cell_type> cell_rows |
5102 | 260 %type <tree_expression_type> matrix cell |
27729
718845eb3c7a
eliminate unnecessary expr_no_assign non-terminal in parser
John W. Eaton <jwe@octave.org>
parents:
27728
diff
changeset
|
261 %type <tree_expression_type> primary_expr oper_expr power_expr |
4207 | 262 %type <tree_expression_type> simple_expr colon_expr assign_expr expression |
29729
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
263 %type <tree_expression_type> arg_name |
17283
e6c0ac8ce5b6
eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
264 %type <tree_identifier_type> identifier fcn_name magic_tilde |
26686
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
265 %type <tree_superclass_ref_type> superclass_identifier |
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
266 %type <tree_metaclass_query_type> meta_identifier |
2970 | 267 %type <tree_index_expression_type> word_list_cmd |
3351 | 268 %type <tree_argument_list_type> arg_list word_list assign_lhs |
269 %type <tree_argument_list_type> cell_or_matrix_row | |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
270 %type <tree_parameter_list_type> opt_param_list param_list |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
271 %type <tree_parameter_list_type> param_list1 param_list2 |
723 | 272 %type <tree_parameter_list_type> return_list return_list1 |
2970 | 273 %type <tree_command_type> command select_command loop_command |
28518
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
274 %type <tree_command_type> jump_command spmd_command except_command |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
275 %type <tree_function_def_type> function |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
276 %type <tree_classdef_type> classdef |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
277 %type <tree_command_type> file |
578 | 278 %type <tree_if_command_type> if_command |
279 %type <tree_if_clause_type> elseif_clause else_clause | |
280 %type <tree_if_command_list_type> if_cmd_list1 if_cmd_list | |
2764 | 281 %type <tree_switch_command_type> switch_command |
282 %type <tree_switch_case_type> switch_case default_case | |
283 %type <tree_switch_case_list_type> case_list1 case_list | |
29728
287fde79ffa2
rename some non-terminal symbols in the parser
John W. Eaton <jwe@octave.org>
parents:
29727
diff
changeset
|
284 %type <tree_decl_elt_type> decl_elt param_list_elt |
287fde79ffa2
rename some non-terminal symbols in the parser
John W. Eaton <jwe@octave.org>
parents:
29727
diff
changeset
|
285 %type <tree_decl_init_list_type> decl_init_list |
2846 | 286 %type <tree_decl_command_type> declaration |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
287 %type <tree_statement_type> statement function_end |
627 | 288 %type <tree_statement_list_type> simple_list simple_list1 list list1 |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
289 %type <tree_statement_list_type> opt_list function_body function_body1 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
290 %type <tree_statement_list_type> opt_fcn_list fcn_list fcn_list1 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
291 %type <tree_classdef_attribute_type> attr |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
292 %type <tree_classdef_attribute_list_type> attr_list attr_list1 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
293 %type <tree_classdef_superclass_type> superclass |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
294 %type <tree_classdef_superclass_list_type> superclass_list superclass_list1 |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
295 %type <tree_classdef_body_type> class_body class_body1 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
296 %type <tree_classdef_property_type> class_property |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
297 %type <tree_classdef_property_list_type> property_list property_list1 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
298 %type <tree_classdef_properties_block_type> properties_block |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
299 %type <tree_classdef_methods_list_type> methods_list methods_list1 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
300 %type <tree_classdef_methods_block_type> methods_block |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
301 %type <tree_classdef_event_type> class_event |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
302 %type <tree_classdef_events_list_type> events_list events_list1 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
303 %type <tree_classdef_events_block_type> events_block |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
304 %type <tree_classdef_enum_type> class_enum |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
305 %type <tree_classdef_enum_list_type> enum_list enum_list1 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
306 %type <tree_classdef_enum_block_type> enum_block |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
307 %type <tree_function_def_type> method_decl method |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
308 %type <tree_arguments_block_type> arguments_block |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
309 %type <tree_args_block_attribute_list_type> args_attr_list |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
310 %type <tree_args_block_validation_list_type> args_validation_list |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
311 %type <tree_arg_validation_type> arg_validation |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
312 %type <tree_arg_size_spec_type> size_spec |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
313 %type <tree_identifier_type> class_name |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
314 %type <tree_arg_validation_fcns_type> validation_fcns |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
315 %type <tree_expression_type> default_value |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
316 %type <octave_user_function_type> method_decl1 |
1 | 317 |
143 | 318 // Precedence and associativity. |
21294
3d375b0905a0
eliminate unused << and >> operators from Octave scripting language
John W. Eaton <jwe@octave.org>
parents:
21159
diff
changeset
|
319 %right '=' ADD_EQ SUB_EQ MUL_EQ DIV_EQ LEFTDIV_EQ POW_EQ EMUL_EQ EDIV_EQ ELEFTDIV_EQ EPOW_EQ OR_EQ AND_EQ |
4023 | 320 %left EXPR_OR_OR |
321 %left EXPR_AND_AND | |
322 %left EXPR_OR | |
323 %left EXPR_AND | |
1 | 324 %left EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT |
325 %left ':' | |
30328
a2397a85d7e5
deprecate .+ and .- operators
John W. Eaton <jwe@octave.org>
parents:
30259
diff
changeset
|
326 %left '-' '+' |
1 | 327 %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
|
328 %right UNARY EXPR_NOT |
16284
09881dab3aaf
* lex.ll, oct-parse.in.yy (HERMITIAN): Rename token from QUOTE.
John W. Eaton <jwe@octave.org>
parents:
16279
diff
changeset
|
329 %left POW EPOW HERMITIAN TRANSPOSE |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
330 %right PLUS_PLUS MINUS_MINUS |
3351 | 331 %left '(' '.' '{' |
1 | 332 |
17629
1e8f8900a041
clean up partially constructed parse tree objects on parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17622
diff
changeset
|
333 // How to clean up if there is a parse error. We handle deleting tokens |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26585
diff
changeset
|
334 // and comments separately and separators are just characters. The |
17629
1e8f8900a041
clean up partially constructed parse tree objects on parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17622
diff
changeset
|
335 // remaining items are dynamically allocated parse tree objects that |
17658
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
336 // must be deleted. Use the wildcard case (<*>) to detect unhandled |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
337 // cases (for example, a new semantic type is added but not handled |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
338 // here). |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
339 |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
340 %destructor { } <tok_val> |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
341 %destructor { } <punct_type> |
17658
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
342 %destructor { } <comment_type> |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
343 %destructor { } <> |
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
344 |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
345 %destructor { delete $$; } <tree_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
346 %destructor { delete $$; } <tree_matrix_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
347 %destructor { delete $$; } <tree_cell_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
348 %destructor { delete $$; } <tree_expression_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
349 %destructor { delete $$; } <tree_constant_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
350 %destructor { delete $$; } <tree_fcn_handle_type> |
26686
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
351 %destructor { delete $$; } <tree_superclass_ref_type> |
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26662
diff
changeset
|
352 %destructor { delete $$; } <tree_metaclass_query_type> |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
353 %destructor { delete $$; } <tree_function_def_type> |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
354 %destructor { delete $$; } <tree_anon_fcn_handle_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
355 %destructor { delete $$; } <tree_identifier_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
356 %destructor { delete $$; } <tree_index_expression_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
357 %destructor { delete $$; } <tree_argument_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
358 %destructor { delete $$; } <tree_parameter_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
359 %destructor { delete $$; } <tree_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
360 %destructor { delete $$; } <tree_if_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
361 %destructor { delete $$; } <tree_if_clause_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
362 %destructor { delete $$; } <tree_if_command_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
363 %destructor { delete $$; } <tree_switch_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
364 %destructor { delete $$; } <tree_switch_case_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
365 %destructor { delete $$; } <tree_switch_case_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
366 %destructor { delete $$; } <tree_decl_elt_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
367 %destructor { delete $$; } <tree_decl_init_list_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
368 %destructor { delete $$; } <tree_decl_command_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
369 %destructor { delete $$; } <tree_statement_type> |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
370 %destructor { delete $$; } <tree_statement_list_type> |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
371 %destructor { delete $$; } <tree_arguments_block_type> |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
372 %destructor { delete $$; } <tree_args_block_attribute_list_type> |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
373 %destructor { delete $$; } <tree_args_block_validation_list_type> |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
374 %destructor { delete $$; } <tree_arg_validation_type> |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
375 %destructor { delete $$; } <tree_arg_size_spec_type> |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
376 %destructor { delete $$; } <tree_arg_validation_fcns_type> |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18974
diff
changeset
|
377 %destructor { delete $$; } <octave_user_function_type> |
17658
0c5f50706ba3
attempt to catch possible memory leaks in parser cleanup
John W. Eaton <jwe@octave.org>
parents:
17632
diff
changeset
|
378 |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
379 %destructor { delete $$; } <tree_classdef_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
380 %destructor { delete $$; } <tree_classdef_attribute_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
381 %destructor { delete $$; } <tree_classdef_attribute_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
382 %destructor { delete $$; } <tree_classdef_superclass_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
383 %destructor { delete $$; } <tree_classdef_superclass_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
384 %destructor { delete $$; } <tree_classdef_body_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
385 %destructor { delete $$; } <tree_classdef_property_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
386 %destructor { delete $$; } <tree_classdef_property_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
387 %destructor { delete $$; } <tree_classdef_properties_block_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
388 %destructor { delete $$; } <tree_classdef_methods_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
389 %destructor { delete $$; } <tree_classdef_methods_block_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
390 %destructor { delete $$; } <tree_classdef_event_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
391 %destructor { delete $$; } <tree_classdef_events_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
392 %destructor { delete $$; } <tree_classdef_events_block_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
393 %destructor { delete $$; } <tree_classdef_enum_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
394 %destructor { delete $$; } <tree_classdef_enum_list_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
395 %destructor { delete $$; } <tree_classdef_enum_block_type> |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
396 |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
397 // Defining a generic destructor generates a warning if destructors are |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
398 // already explicitly declared for all types. |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
399 // |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
400 // %destructor { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
401 // warning_with_id |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
402 // ("Octave:parser-destructor", |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
403 // "possible memory leak in cleanup following parse error"); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
404 // } <*> |
17629
1e8f8900a041
clean up partially constructed parse tree objects on parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17622
diff
changeset
|
405 |
143 | 406 // Where to start. |
1 | 407 %start input |
408 | |
409 %% | |
410 | |
2970 | 411 // ============================== |
412 // Statements and statement lists | |
413 // ============================== | |
414 | |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
415 input : simple_list '\n' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
416 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
417 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
418 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
419 $$ = nullptr; |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
420 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
421 if (! parser.finish_input ($1)) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
422 YYABORT; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
423 else |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
424 YYACCEPT; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
425 } |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
426 | simple_list END_OF_INPUT |
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
427 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
428 OCTAVE_YYUSE ($2); |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
429 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
430 $$ = nullptr; |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
431 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
432 if (! parser.finish_input ($1, true)) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
433 YYABORT; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
434 else |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
435 YYACCEPT; |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
436 } |
17326
f444e4cef9b9
avoid exiting Octave on parse error (bug #39862)
John W. Eaton <jwe@octave.org>
parents:
17322
diff
changeset
|
437 | parse_error |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
438 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
439 $$ = nullptr; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
440 YYABORT; |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
441 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
442 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
443 |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
444 simple_list : opt_sep_no_nl |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
445 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
446 OCTAVE_YYUSE ($1); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
447 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
448 $$ = nullptr; |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
449 } |
17322
4c1ae06111c9
allow parser to accept empty statements (bug #37099)
John W. Eaton <jwe@octave.org>
parents:
17317
diff
changeset
|
450 | simple_list1 opt_sep_no_nl |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
451 { $$ = 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
|
452 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
453 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
454 simple_list1 : statement |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
455 { $$ = parser.make_statement_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
456 | simple_list1 sep_no_nl statement |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
457 { $$ = 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
|
458 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
459 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
460 opt_list : // empty |
30130
a9e3e1c96c47
eliminate unnecessary construction of parse tree elements
John W. Eaton <jwe@octave.org>
parents:
30108
diff
changeset
|
461 { $$ = nullptr; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
462 | list |
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 list : list1 opt_sep |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
467 { $$ = 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
|
468 ; |
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 list1 : statement |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
471 { $$ = parser.make_statement_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
472 | list1 sep statement |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
473 { $$ = 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
|
474 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
475 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
476 opt_fcn_list : // empty |
30130
a9e3e1c96c47
eliminate unnecessary construction of parse tree elements
John W. Eaton <jwe@octave.org>
parents:
30108
diff
changeset
|
477 { $$ = nullptr; } |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
478 | fcn_list |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
479 { $$ = $1; } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
480 ; |
23396
945b53af4655
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
23343
diff
changeset
|
481 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
482 fcn_list : fcn_list1 opt_sep |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
483 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
484 OCTAVE_YYUSE ($2); |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
485 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
486 $$ = $1; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
487 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
488 ; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
489 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
490 fcn_list1 : function |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
491 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
492 octave::tree_statement *stmt = parser.make_statement ($1); |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
493 $$ = parser.make_statement_list (stmt); |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
494 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
495 | fcn_list1 opt_sep function |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
496 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
497 octave::tree_statement *stmt = parser.make_statement ($3); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
498 $$ = parser.append_statement_list ($1, $2, stmt, false); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
499 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
500 ; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
501 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
502 statement : expression |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
503 { $$ = parser.make_statement ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
504 | command |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
505 { $$ = parser.make_statement ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
506 | word_list_cmd |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
507 { $$ = parser.make_statement ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
508 ; |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
509 |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
510 // ================= |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
511 // Word-list command |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
512 // ================= |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
513 |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
514 // 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
|
515 // 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
|
516 // WHILE, etc. |
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8745
diff
changeset
|
517 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
518 word_list_cmd : identifier word_list |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
519 { |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
520 $$ = parser.make_index_expression ($1, $2, '('); |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
521 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
522 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
523 // make_index_expression deleted $1 and $2. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
524 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
525 } |
26662
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
526 $$->mark_word_list_cmd (); |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
527 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
528 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
529 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
530 word_list : string |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
531 { $$ = parser.make_argument_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
532 | word_list string |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
533 { $$ = parser.append_argument_list ($1, $2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
534 ; |
1 | 535 |
2970 | 536 // =========== |
537 // Expressions | |
538 // =========== | |
539 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
540 identifier : NAME |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
541 { $$ = parser.make_identifier ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
542 ; |
2970 | 543 |
9476 | 544 superclass_identifier |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
545 : SUPERCLASSREF |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
546 { $$ = parser.make_superclass_ref ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
547 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
548 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
549 meta_identifier : METAQUERY |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
550 { $$ = parser.make_metaclass_query ($1); } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
551 ; |
10315
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 string : DQ_STRING |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
554 { $$ = parser.make_constant ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
555 | SQ_STRING |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
556 { $$ = parser.make_constant ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
557 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
558 |
28582
dc8de424fc72
use octave_value object to store numeric tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
28548
diff
changeset
|
559 constant : NUMBER |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
560 { $$ = parser.make_constant ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
561 | string |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
562 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
563 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
564 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
565 matrix : '[' matrix_rows ']' |
27764
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
566 { $$ = parser.finish_matrix ($2, $1, $3); } |
10315
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 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
569 matrix_rows : cell_or_matrix_row |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
570 { $$ = parser.make_matrix ($1); } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
571 | matrix_rows ';' cell_or_matrix_row |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
572 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
573 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
574 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
575 $$ = parser.append_matrix_row ($1, $3); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
576 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
577 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
578 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
579 cell : '{' cell_rows '}' |
27764
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
580 { $$ = parser.finish_cell ($2, $1, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
581 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
582 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
583 cell_rows : cell_or_matrix_row |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
584 { $$ = parser.make_cell ($1); } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
585 | cell_rows ';' cell_or_matrix_row |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
586 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
587 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
588 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
589 $$ = parser.append_cell_row ($1, $3); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
590 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
591 ; |
3351 | 592 |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
593 // tree_argument_list objects can't be empty or have leading or trailing |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
594 // commas, but those are all allowed in matrix and cell array rows. |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
595 |
28804
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28700
diff
changeset
|
596 // FIXME: is tree_argument_list the best object for this purpose, or |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28700
diff
changeset
|
597 // should we have a separate one intended specifically to represent the |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28700
diff
changeset
|
598 // list of objects that make up elements in cell and matrix expressions? |
3719f5d452d4
refactor implementation of END indexing in interpreter (bug #58953)
John W. Eaton <jwe@octave.org> and Fernando Alvarruiz
parents:
28700
diff
changeset
|
599 |
3351 | 600 cell_or_matrix_row |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
601 : // empty |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
602 { $$ = nullptr; } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
603 | ',' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
604 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
605 OCTAVE_YYUSE ($1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
606 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
607 $$ = nullptr; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
608 } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
609 | arg_list |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
610 { $$ = $1; } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
611 | arg_list ',' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
612 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
613 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
614 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
615 $$ = $1; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
616 } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
617 | ',' arg_list |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
618 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
619 OCTAVE_YYUSE ($1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
620 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
621 $$ = $2; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
622 } |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16850
diff
changeset
|
623 | ',' arg_list ',' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
624 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
625 OCTAVE_YYUSE ($1, $3); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
626 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
627 $$ = $2; |
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 |
26740
cf271740922a
allow parsing of function handles of the form @foo.bar
John W. Eaton <jwe@octave.org>
parents:
26718
diff
changeset
|
631 fcn_handle : FCN_HANDLE |
cf271740922a
allow parsing of function handles of the form @foo.bar
John W. Eaton <jwe@octave.org>
parents:
26718
diff
changeset
|
632 { $$ = parser.make_fcn_handle ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
633 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
634 |
27736
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
635 // Note that we are deliberately not setting the beginning of statement |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
636 // flag after recognizing the parameter list because we don't want to |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
637 // accept word list commands in anonymous function bodies. |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
638 |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
639 anon_fcn_handle : '@' param_list anon_fcn_begin expression |
13237
1bfca2bbea8b
fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents:
13125
diff
changeset
|
640 { |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
641 $$ = parser.make_anon_fcn_handle ($2, $4, $1->beg_pos ()); |
27728
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
642 if (! $$) |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
643 { |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
644 // make_anon_fcn_handle deleted $2 and $4. |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
645 YYABORT; |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
646 } |
27736
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
647 |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
648 lexer.m_parsing_anon_fcn_body = false; |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
649 lexer.m_nesting_level.remove (); |
13237
1bfca2bbea8b
fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents:
13125
diff
changeset
|
650 } |
27736
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
651 | '@' param_list anon_fcn_begin error |
24283
81557c74be7f
improve error message for invalid anonymous functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
652 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
653 OCTAVE_YYUSE ($1, $2); |
24283
81557c74be7f
improve error message for invalid anonymous functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
654 |
27736
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
655 lexer.m_parsing_anon_fcn_body = false; |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
656 |
24283
81557c74be7f
improve error message for invalid anonymous functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
657 $$ = nullptr; |
81557c74be7f
improve error message for invalid anonymous functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
658 parser.bison_error ("anonymous function bodies must be single expressions"); |
81557c74be7f
improve error message for invalid anonymous functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
659 YYABORT; |
81557c74be7f
improve error message for invalid anonymous functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
660 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
661 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
662 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
663 primary_expr : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
664 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
665 | constant |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
666 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
667 | fcn_handle |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
668 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
669 | matrix |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
670 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
671 lexer.m_looking_at_matrix_or_assign_lhs = false; |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
672 $$ = $1; |
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16251
diff
changeset
|
673 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
674 | cell |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
675 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
676 | meta_identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
677 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
678 | superclass_identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
679 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
680 | '(' expression ')' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
681 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
682 OCTAVE_YYUSE ($1, $3); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
683 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
684 $$ = $2->mark_in_parens (); |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
685 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
686 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
687 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
688 magic_colon : ':' |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
689 { $$ = parser.make_constant ($1); } |
10315
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 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
692 magic_tilde : EXPR_NOT |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
693 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
694 OCTAVE_YYUSE ($1); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
695 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
696 $$ = parser.make_black_hole (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
697 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
698 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
699 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
700 arg_list : expression |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
701 { $$ = parser.make_argument_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
702 | magic_colon |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
703 { $$ = parser.make_argument_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
704 | magic_tilde |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
705 { $$ = parser.make_argument_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
706 | arg_list ',' magic_colon |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
707 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
708 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
709 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
710 $$ = parser.append_argument_list ($1, $3); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
711 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
712 | arg_list ',' magic_tilde |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
713 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
714 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
715 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
716 $$ = parser.append_argument_list ($1, $3); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
717 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
718 | arg_list ',' expression |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
719 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
720 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
721 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
722 $$ = parser.append_argument_list ($1, $3); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
723 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
724 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
725 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
726 indirect_ref_op : '.' |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
727 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
728 OCTAVE_YYUSE ($1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
729 |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
730 $$ = 0; |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
731 lexer.m_looking_at_indirect_ref = true; |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
732 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
733 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
734 |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
735 oper_expr : primary_expr |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
736 { $$ = $1; } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
737 | oper_expr PLUS_PLUS |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
738 { $$ = 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
|
739 | oper_expr MINUS_MINUS |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
740 { $$ = 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
|
741 | oper_expr '(' ')' |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
742 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
743 OCTAVE_YYUSE ($2, $3); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
744 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
745 $$ = parser.make_index_expression ($1, nullptr, '('); |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
746 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
747 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
748 // make_index_expression deleted $1. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
749 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
750 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
751 } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
752 | oper_expr '(' arg_list ')' |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
753 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
754 OCTAVE_YYUSE ($2, $4); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
755 |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
756 $$ = parser.make_index_expression ($1, $3, '('); |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
757 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
758 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
759 // make_index_expression deleted $1 and $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
760 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
761 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
762 } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
763 | oper_expr '{' '}' |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
764 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
765 OCTAVE_YYUSE ($2, $3); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
766 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
767 $$ = parser.make_index_expression ($1, nullptr, '{'); |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
768 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
769 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
770 // make_index_expression deleted $1. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
771 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
772 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
773 } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
774 | oper_expr '{' arg_list '}' |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
775 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
776 OCTAVE_YYUSE ($2, $4); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
777 |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
778 $$ = parser.make_index_expression ($1, $3, '{'); |
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
779 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
780 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
781 // make_index_expression deleted $1 and $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
782 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
783 } |
16302
a4af67e0d22c
oct-parse.in.yy: a{~}.b segfaults the interpreter (bug #37804)
Max Brister <max@2bass.com>
parents:
16294
diff
changeset
|
784 } |
16284
09881dab3aaf
* lex.ll, oct-parse.in.yy (HERMITIAN): Rename token from QUOTE.
John W. Eaton <jwe@octave.org>
parents:
16279
diff
changeset
|
785 | oper_expr HERMITIAN |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
786 { $$ = parser.make_postfix_op (HERMITIAN, $1, $2); } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
787 | oper_expr TRANSPOSE |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
788 { $$ = 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
|
789 | oper_expr indirect_ref_op STRUCT_ELT |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
790 { $$ = 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
|
791 | oper_expr indirect_ref_op '(' expression ')' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
792 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
793 OCTAVE_YYUSE ($3, $5); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
794 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
795 $$ = parser.make_indirect_ref ($1, $4); |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
796 } |
12627
002948ae5bc0
fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
797 | PLUS_PLUS oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
798 { $$ = 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
|
799 | MINUS_MINUS oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
800 { $$ = 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
|
801 | EXPR_NOT oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
802 { $$ = 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
|
803 | '+' oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
804 { $$ = 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
|
805 | '-' oper_expr %prec UNARY |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
806 { $$ = parser.make_prefix_op ('-', $2, $1); } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
807 | oper_expr POW power_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
808 { $$ = parser.make_binary_op (POW, $1, $2, $3); } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
809 | oper_expr EPOW power_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
810 { $$ = 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
|
811 | oper_expr '+' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
812 { $$ = 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
|
813 | oper_expr '-' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
814 { $$ = 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
|
815 | oper_expr '*' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
816 { $$ = 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
|
817 | oper_expr '/' oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
818 { $$ = 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
|
819 | oper_expr EMUL oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
820 { $$ = 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
|
821 | oper_expr EDIV oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
822 { $$ = 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
|
823 | oper_expr LEFTDIV oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
824 { $$ = 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
|
825 | oper_expr ELEFTDIV oper_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
826 { $$ = parser.make_binary_op (ELEFTDIV, $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
827 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
828 |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
829 power_expr : primary_expr |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
830 { $$ = $1; } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
831 | power_expr PLUS_PLUS |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
832 { $$ = parser.make_postfix_op (PLUS_PLUS, $1, $2); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
833 | power_expr MINUS_MINUS |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
834 { $$ = parser.make_postfix_op (MINUS_MINUS, $1, $2); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
835 | power_expr '(' ')' |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
836 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
837 OCTAVE_YYUSE ($2, $3); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
838 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
839 $$ = parser.make_index_expression ($1, nullptr, '('); |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
840 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
841 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
842 // make_index_expression deleted $1. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
843 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
844 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
845 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
846 | power_expr '(' arg_list ')' |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
847 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
848 OCTAVE_YYUSE ($2, $4); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
849 |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
850 $$ = parser.make_index_expression ($1, $3, '('); |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
851 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
852 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
853 // make_index_expression deleted $1 and $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
854 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
855 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
856 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
857 | power_expr '{' '}' |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
858 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
859 OCTAVE_YYUSE ($2, $3); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
860 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
861 $$ = parser.make_index_expression ($1, nullptr, '{'); |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
862 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
863 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
864 // make_index_expression deleted $1. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
865 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
866 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
867 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
868 | power_expr '{' arg_list '}' |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
869 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
870 OCTAVE_YYUSE ($2, $4); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
871 |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
872 $$ = parser.make_index_expression ($1, $3, '{'); |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
873 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
874 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
875 // make_index_expression deleted $1 and $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
876 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
877 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
878 } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
879 | power_expr indirect_ref_op STRUCT_ELT |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
880 { $$ = parser.make_indirect_ref ($1, $3->text ()); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
881 | power_expr indirect_ref_op '(' expression ')' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
882 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
883 OCTAVE_YYUSE ($3, $5); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
884 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
885 $$ = parser.make_indirect_ref ($1, $4); |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
886 } |
17622
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
887 | PLUS_PLUS power_expr %prec POW |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
888 { $$ = parser.make_prefix_op (PLUS_PLUS, $2, $1); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
889 | MINUS_MINUS power_expr %prec POW |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
890 { $$ = parser.make_prefix_op (MINUS_MINUS, $2, $1); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
891 | EXPR_NOT power_expr %prec POW |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
892 { $$ = parser.make_prefix_op (EXPR_NOT, $2, $1); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
893 | '+' power_expr %prec POW |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
894 { $$ = parser.make_prefix_op ('+', $2, $1); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
895 | '-' power_expr %prec POW |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
896 { $$ = parser.make_prefix_op ('-', $2, $1); } |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
897 ; |
fd712a12fe53
compatibility for power operator precedence and direction (bug #33304)
Axel Mathéi <axel.mathei@gmail.com>
parents:
17618
diff
changeset
|
898 |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
899 colon_expr : oper_expr ':' oper_expr |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
900 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
901 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
902 |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
903 $$ = parser.make_colon_expression ($1, $3); |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
904 |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
905 if (! $$) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
906 { |
30197
f692ecc135d6
* oct-parse.yy (colon_expr): Fix comments to match code.
John W. Eaton <jwe@octave.org>
parents:
30145
diff
changeset
|
907 // make_colon_expression deleted $1 and $3. |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
908 YYABORT; |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
909 } |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
910 } |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
911 | oper_expr ':' oper_expr ':' oper_expr |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
912 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
913 OCTAVE_YYUSE ($2, $4); |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
914 |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
915 $$ = parser.make_colon_expression ($1, $5, $3); |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
916 |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
917 if (! $$) |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
918 { |
30197
f692ecc135d6
* oct-parse.yy (colon_expr): Fix comments to match code.
John W. Eaton <jwe@octave.org>
parents:
30145
diff
changeset
|
919 // make_colon_expression deleted $1, $3, and $5. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
920 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
921 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
922 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
923 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
924 |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
925 simple_expr : oper_expr |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
926 { $$ = $1; } |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
927 | colon_expr |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
928 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
929 | simple_expr EXPR_LT simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
930 { $$ = 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
|
931 | simple_expr EXPR_LE simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
932 { $$ = 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
|
933 | simple_expr EXPR_EQ simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
934 { $$ = 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
|
935 | simple_expr EXPR_GE simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
936 { $$ = 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
|
937 | simple_expr EXPR_GT simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
938 { $$ = 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
|
939 | simple_expr EXPR_NE simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
940 { $$ = 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
|
941 | simple_expr EXPR_AND simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
942 { $$ = 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
|
943 | simple_expr EXPR_OR simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
944 { $$ = 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
|
945 | simple_expr EXPR_AND_AND simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
946 { $$ = 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
|
947 | simple_expr EXPR_OR_OR simple_expr |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
948 { $$ = 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
|
949 ; |
2970 | 950 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
951 assign_lhs : simple_expr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
952 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
953 $$ = parser.validate_matrix_for_assignment ($1); |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
954 |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
955 if ($$) |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
956 { lexer.m_looking_at_matrix_or_assign_lhs = false; } |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
957 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
958 { |
16277
8cb65fd72164
eliminate obsolete concepts of "pending local" and "forced" variables
John W. Eaton <jwe@octave.org>
parents:
16273
diff
changeset
|
959 // validate_matrix_for_assignment deleted $1. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
960 YYABORT; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
961 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
962 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
963 ; |
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 assign_expr : assign_lhs '=' expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
966 { $$ = parser.make_assign_op ('=', $1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
967 | assign_lhs ADD_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
968 { $$ = 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
|
969 | assign_lhs SUB_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
970 { $$ = 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
|
971 | assign_lhs MUL_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
972 { $$ = 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
|
973 | assign_lhs DIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
974 { $$ = 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
|
975 | assign_lhs LEFTDIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
976 { $$ = 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
|
977 | assign_lhs POW_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
978 { $$ = 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
|
979 | assign_lhs EMUL_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
980 { $$ = 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
|
981 | assign_lhs EDIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
982 { $$ = 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
|
983 | assign_lhs ELEFTDIV_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
984 { $$ = 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
|
985 | assign_lhs EPOW_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
986 { $$ = 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
|
987 | assign_lhs AND_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
988 { $$ = 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
|
989 | assign_lhs OR_EQ expression |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
990 { $$ = 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
|
991 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
992 |
27729
718845eb3c7a
eliminate unnecessary expr_no_assign non-terminal in parser
John W. Eaton <jwe@octave.org>
parents:
27728
diff
changeset
|
993 expression : simple_expr |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
994 { |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23553
diff
changeset
|
995 if ($1 && ($1->is_matrix () || $1->iscell ())) |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
996 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
997 if (parser.validate_array_list ($1)) |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
998 $$ = $1; |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
999 else |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
1000 { |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
1001 delete $1; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1002 YYABORT; |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
1003 } |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
1004 } |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
1005 else |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
1006 $$ = $1; |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16265
diff
changeset
|
1007 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1008 | assign_expr |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1009 { |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1010 if (! $1) |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1011 YYABORT; |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1012 |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1013 $$ = $1; |
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1014 } |
27729
718845eb3c7a
eliminate unnecessary expr_no_assign non-terminal in parser
John W. Eaton <jwe@octave.org>
parents:
27728
diff
changeset
|
1015 | anon_fcn_handle |
718845eb3c7a
eliminate unnecessary expr_no_assign non-terminal in parser
John W. Eaton <jwe@octave.org>
parents:
27728
diff
changeset
|
1016 { $$ = $1; } |
718845eb3c7a
eliminate unnecessary expr_no_assign non-terminal in parser
John W. Eaton <jwe@octave.org>
parents:
27728
diff
changeset
|
1017 ; |
2970 | 1018 |
1019 // ================================================ | |
1020 // Commands, declarations, and function definitions | |
1021 // ================================================ | |
1022 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1023 command : declaration |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1024 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1025 | select_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1026 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1027 | loop_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1028 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1029 | jump_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1030 { $$ = $1; } |
28518
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1031 | spmd_command |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1032 { $$ = $1; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1033 | except_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1034 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1035 | function |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1036 { $$ = $1; } |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1037 | file |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1038 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1039 ; |
2970 | 1040 |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26585
diff
changeset
|
1041 // ====================== |
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26585
diff
changeset
|
1042 // Declaration statements |
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26585
diff
changeset
|
1043 // ====================== |
2970 | 1044 |
29728
287fde79ffa2
rename some non-terminal symbols in the parser
John W. Eaton <jwe@octave.org>
parents:
29727
diff
changeset
|
1045 declaration : GLOBAL decl_init_list |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1046 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1047 $$ = parser.make_decl_command (GLOBAL, $1, $2); |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1048 lexer.m_looking_at_decl_list = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1049 } |
29728
287fde79ffa2
rename some non-terminal symbols in the parser
John W. Eaton <jwe@octave.org>
parents:
29727
diff
changeset
|
1050 | PERSISTENT decl_init_list |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1051 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1052 $$ = parser.make_decl_command (PERSISTENT, $1, $2); |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1053 lexer.m_looking_at_decl_list = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1054 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1055 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1056 |
29728
287fde79ffa2
rename some non-terminal symbols in the parser
John W. Eaton <jwe@octave.org>
parents:
29727
diff
changeset
|
1057 decl_init_list : decl_elt |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1058 { $$ = parser.make_decl_init_list ($1); } |
29728
287fde79ffa2
rename some non-terminal symbols in the parser
John W. Eaton <jwe@octave.org>
parents:
29727
diff
changeset
|
1059 | decl_init_list decl_elt |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1060 { $$ = parser.append_decl_init_list ($1, $2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1061 ; |
2970 | 1062 |
29728
287fde79ffa2
rename some non-terminal symbols in the parser
John W. Eaton <jwe@octave.org>
parents:
29727
diff
changeset
|
1063 decl_elt : identifier |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1064 { $$ = parser.make_decl_elt ($1); } |
29727
05d7b7e64811
eliminate unused lexical feedback flag
John W. Eaton <jwe@octave.org>
parents:
29724
diff
changeset
|
1065 | identifier '=' expression |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1066 { $$ = parser.make_decl_elt ($1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1067 ; |
2970 | 1068 |
1069 // ==================== | |
1070 // Selection statements | |
1071 // ==================== | |
1072 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1073 select_command : if_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1074 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1075 | switch_command |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1076 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1077 ; |
2970 | 1078 |
1079 // ============ | |
1080 // If statement | |
1081 // ============ | |
1082 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1083 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
|
1084 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1085 if (! ($$ = parser.finish_if_command ($1, $3, $4, $2))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1086 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1087 // finish_if_command deleted $3. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1088 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1089 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1090 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1091 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1092 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1093 if_cmd_list : if_cmd_list1 |
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 | if_cmd_list1 else_clause |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1096 { $$ = parser.append_if_clause ($1, $2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1097 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1098 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1099 if_cmd_list1 : expression stmt_begin opt_sep opt_list |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
1100 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1101 OCTAVE_YYUSE ($3); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1102 |
18127
d76f790b4eec
enable do_braindead_shortcircuit_evaluation by default and deprecate
John W. Eaton <jwe@octave.org>
parents:
17796
diff
changeset
|
1103 $1->mark_braindead_shortcircuit (); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1104 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1105 $$ = parser.start_if_command ($1, $4); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
1106 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1107 | if_cmd_list1 elseif_clause |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1108 { $$ = parser.append_if_clause ($1, $2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1109 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1110 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1111 elseif_clause : ELSEIF stash_comment opt_sep expression stmt_begin opt_sep opt_list |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
1112 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1113 OCTAVE_YYUSE ($3, $6); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1114 |
18127
d76f790b4eec
enable do_braindead_shortcircuit_evaluation by default and deprecate
John W. Eaton <jwe@octave.org>
parents:
17796
diff
changeset
|
1115 $4->mark_braindead_shortcircuit (); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1116 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1117 $$ = parser.make_elseif_clause ($1, $4, $7, $2); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11060
diff
changeset
|
1118 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1119 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1120 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1121 else_clause : ELSE stash_comment opt_sep opt_list |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1122 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1123 OCTAVE_YYUSE ($3); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1124 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1125 $$ = parser.make_else_clause ($1, $2, $4); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1126 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1127 ; |
2970 | 1128 |
1129 // ================ | |
1130 // Switch statement | |
1131 // ================ | |
1132 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1133 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
|
1134 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1135 OCTAVE_YYUSE ($4); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1136 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1137 if (! ($$ = parser.finish_switch_command ($1, $3, $5, $6, $2))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1138 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1139 // finish_switch_command deleted $3 adn $5. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1140 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1141 } |
10315
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 ; |
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 case_list : // empty |
30130
a9e3e1c96c47
eliminate unnecessary construction of parse tree elements
John W. Eaton <jwe@octave.org>
parents:
30108
diff
changeset
|
1146 { $$ = nullptr; } |
11317
2da532d0f41c
accept otherwise clause in switch statement without preceding case statements
John W. Eaton <jwe@octave.org>
parents:
11258
diff
changeset
|
1147 | default_case |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1148 { $$ = parser.make_switch_case_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1149 | case_list1 |
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 | case_list1 default_case |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1152 { $$ = parser.append_switch_case ($1, $2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1153 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1154 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1155 case_list1 : switch_case |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1156 { $$ = parser.make_switch_case_list ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1157 | case_list1 switch_case |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1158 { $$ = parser.append_switch_case ($1, $2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1159 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1160 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1161 switch_case : CASE stash_comment opt_sep expression stmt_begin opt_sep opt_list |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1162 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1163 OCTAVE_YYUSE ($3, $6); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1164 |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1165 $$ = parser.make_switch_case ($1, $4, $7, $2); |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1166 } |
10315
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 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1169 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
|
1170 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1171 OCTAVE_YYUSE ($3); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1172 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1173 $$ = parser.make_default_switch_case ($1, $2, $4); |
10315
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 ; |
2970 | 1176 |
1177 // ======= | |
1178 // Looping | |
1179 // ======= | |
1180 | |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1181 loop_command : WHILE stash_comment expression stmt_begin opt_sep opt_list END |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1182 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1183 OCTAVE_YYUSE ($5); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1184 |
18127
d76f790b4eec
enable do_braindead_shortcircuit_evaluation by default and deprecate
John W. Eaton <jwe@octave.org>
parents:
17796
diff
changeset
|
1185 $3->mark_braindead_shortcircuit (); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1186 |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1187 if (! ($$ = parser.make_while_command ($1, $3, $6, $7, $2))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1188 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1189 // make_while_command deleted $3 and $6. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1190 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1191 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1192 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1193 | 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
|
1194 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1195 OCTAVE_YYUSE ($1, $3); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1196 |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1197 $$ = 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
|
1198 } |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1199 | FOR stash_comment assign_lhs '=' expression stmt_begin opt_sep opt_list END |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1200 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1201 OCTAVE_YYUSE ($4, $7); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1202 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1203 if (! ($$ = parser.make_for_command (FOR, $1, $3, $5, |
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1204 nullptr, $8, $9, $2))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1205 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1206 // make_for_command deleted $3, $5, and $8. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1207 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1208 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1209 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1210 | 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
|
1211 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1212 OCTAVE_YYUSE ($3, $5, $7, $8); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1213 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1214 if (! ($$ = parser.make_for_command (FOR, $1, $4, $6, |
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1215 nullptr, $9, $10, $2))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1216 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1217 // make_for_command deleted $4, $6, and $9. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1218 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1219 } |
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
|
1220 } |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
1221 | PARFOR stash_comment assign_lhs '=' expression stmt_begin opt_sep opt_list END |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
1222 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1223 OCTAVE_YYUSE ($4, $7); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1224 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1225 if (! ($$ = parser.make_for_command (PARFOR, $1, $3, $5, |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1226 nullptr, $8, $9, $2))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1227 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1228 // make_for_command deleted $3, $5, and $8. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1229 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1230 } |
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
|
1231 } |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
1232 | 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
|
1233 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1234 OCTAVE_YYUSE ($3, $5, $7, $9, $10); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1235 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1236 if (! ($$ = parser.make_for_command (PARFOR, $1, $4, $6, |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1237 $8, $11, $12, $2))) |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1238 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1239 // make_for_command deleted $4, $6, $8, and $11. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1240 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1241 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1242 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1243 ; |
2970 | 1244 |
1245 // ======= | |
1246 // Jumping | |
1247 // ======= | |
1248 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1249 jump_command : BREAK |
22785
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1250 { |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1251 if (! ($$ = parser.make_break_command ($1))) |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1252 YYABORT; |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1253 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1254 | CONTINUE |
26981
12532d392693
error if continue is used outside of a for loop (bug #55995)
John W. Eaton <jwe@octave.org>
parents:
26906
diff
changeset
|
1255 { |
12532d392693
error if continue is used outside of a for loop (bug #55995)
John W. Eaton <jwe@octave.org>
parents:
26906
diff
changeset
|
1256 if (! ($$ = parser.make_continue_command ($1))) |
12532d392693
error if continue is used outside of a for loop (bug #55995)
John W. Eaton <jwe@octave.org>
parents:
26906
diff
changeset
|
1257 YYABORT; |
12532d392693
error if continue is used outside of a for loop (bug #55995)
John W. Eaton <jwe@octave.org>
parents:
26906
diff
changeset
|
1258 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1259 | FUNC_RET |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1260 { $$ = parser.make_return_command ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1261 ; |
2970 | 1262 |
28518
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1263 // ======================= |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1264 // Parallel execution pool |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1265 // ======================= |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1266 |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1267 spmd_command : SPMD stash_comment opt_sep opt_list END |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1268 { |
29283
aa645ebc7b29
eliminate extra YYUSE on default missed when merging 59696b24ea53 from stable
John W. Eaton <jwe@octave.org>
parents:
29273
diff
changeset
|
1269 OCTAVE_YYUSE ($3); |
28518
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1270 |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1271 octave::comment_list *lc = $2; |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1272 octave::comment_list *tc = lexer.get_comment (); |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1273 |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1274 if (! ($$ = parser.make_spmd_command ($1, $4, $5, lc, tc))) |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1275 { |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1276 // make_spmd_command deleted $4, LC, and TC. |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1277 YYABORT; |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1278 } |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1279 } |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1280 ; |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
1281 |
2970 | 1282 // ========== |
1283 // Exceptions | |
1284 // ========== | |
1285 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1286 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
|
1287 stash_comment opt_sep opt_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1288 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1289 OCTAVE_YYUSE ($3, $5, $7); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1290 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1291 if (! ($$ = parser.make_unwind_command ($1, $4, $8, $9, $2, $6))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1292 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1293 // make_unwind_command deleted $4 and $8. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1294 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1295 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1296 } |
17283
e6c0ac8ce5b6
eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
1297 | TRY stash_comment opt_sep opt_list CATCH stash_comment |
e6c0ac8ce5b6
eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
1298 opt_sep opt_list END |
17249
923ce8b42db2
improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents:
17170
diff
changeset
|
1299 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1300 OCTAVE_YYUSE ($3, $5, $7); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1301 |
17283
e6c0ac8ce5b6
eliminate parse conflicts introduced by changeset 923ce8b42db2
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
1302 if (! ($$ = parser.make_try_command ($1, $4, $7, $8, $9, $2, $6))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1303 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1304 // make_try_command deleted $4 and $8. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1305 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1306 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1307 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1308 | TRY stash_comment opt_sep opt_list END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1309 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1310 OCTAVE_YYUSE ($3); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1311 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1312 if (! ($$ = parser.make_try_command ($1, $4, 0, nullptr, |
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1313 $5, $2, nullptr))) |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1314 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1315 // make_try_command deleted $4. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1316 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1317 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1318 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1319 ; |
2970 | 1320 |
1321 // =========================================== | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14189
diff
changeset
|
1322 // Some 'subroutines' for function definitions |
2970 | 1323 // =========================================== |
1324 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1325 push_fcn_symtab : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1326 { |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
1327 if (! parser.push_fcn_symtab ()) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
1328 YYABORT; |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
1329 |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1330 $$ = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1331 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1332 ; |
2970 | 1333 |
1334 // =========================== | |
1335 // List of function parameters | |
1336 // =========================== | |
1337 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1338 param_list_beg : '(' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1339 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1340 OCTAVE_YYUSE ($1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
1341 |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1342 $$ = 0; |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1343 lexer.m_looking_at_parameter_list = true; |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1344 lexer.m_arguments_is_keyword = false; |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1345 |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1346 if (lexer.m_looking_at_function_handle) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1347 { |
24354
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
1348 // Will get a real name later. |
29857
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
1349 lexer.m_symtab_context.push (octave::symbol_scope ("parser:param_list_beg")); |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1350 lexer.m_looking_at_function_handle--; |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1351 lexer.m_looking_at_anon_fcn_args = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1352 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1353 } |
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 param_list_end : ')' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1357 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1358 OCTAVE_YYUSE ($1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
1359 |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1360 $$ = 0; |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1361 lexer.m_looking_at_parameter_list = false; |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1362 lexer.m_arguments_is_keyword = true; |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1363 lexer.m_looking_for_object_index = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1364 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1365 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1366 |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1367 opt_param_list : // empty |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1368 { $$ = nullptr; } |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1369 | param_list |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1370 { $$ = $1; } |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1371 ; |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1372 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1373 param_list : param_list_beg param_list1 param_list_end |
16360
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1374 { |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1375 if ($2) |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1376 lexer.mark_as_variables ($2->variable_names ()); |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1377 |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1378 $$ = $2; |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1379 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1380 | param_list_beg error |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1381 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1382 $$ = nullptr; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1383 parser.bison_error ("invalid parameter list"); |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1384 YYABORT; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1385 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1386 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1387 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1388 param_list1 : // empty |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1389 { $$ = parser.make_parameter_list (octave::tree_parameter_list::in); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1390 | param_list2 |
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 $1->mark_as_formal_parameters (); |
23654
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
1393 |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
1394 if (parser.validate_param_list ($1, octave::tree_parameter_list::in)) |
16360
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1395 { |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1396 lexer.mark_as_variables ($1->variable_names ()); |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1397 $$ = $1; |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1398 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1399 else |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1400 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1401 delete $1; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1402 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1403 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1404 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1405 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1406 |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1407 param_list2 : param_list_elt |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1408 { $$ = parser.make_parameter_list (octave::tree_parameter_list::in, $1); } |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1409 | param_list2 ',' param_list_elt |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1410 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1411 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
1412 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1413 $$ = parser.append_parameter_list ($1, $3); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1414 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1415 ; |
2970 | 1416 |
29728
287fde79ffa2
rename some non-terminal symbols in the parser
John W. Eaton <jwe@octave.org>
parents:
29727
diff
changeset
|
1417 param_list_elt : decl_elt |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1418 { $$ = $1; } |
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1419 | magic_tilde |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1420 { $$ = parser.make_decl_elt ($1); } |
17317
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1421 ; |
56fe31b248de
disallow ~ in global and persistent declaration lists
John W. Eaton <jwe@octave.org>
parents:
17316
diff
changeset
|
1422 |
2970 | 1423 // =================================== |
1424 // List of function return value names | |
1425 // =================================== | |
1426 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1427 return_list : '[' ']' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1428 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1429 OCTAVE_YYUSE ($1, $2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
1430 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1431 lexer.m_looking_at_return_list = false; |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1432 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1433 $$ = parser.make_parameter_list (octave::tree_parameter_list::out); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1434 } |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1435 | identifier |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1436 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1437 lexer.m_looking_at_return_list = false; |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1438 |
28257
ae94e3fad6d4
fix printing of functions with varargin/varargout (bug #58279)
John W. Eaton <jwe@octave.org>
parents:
28149
diff
changeset
|
1439 octave::tree_parameter_list *tmp |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1440 = parser.make_parameter_list (octave::tree_parameter_list::out, $1); |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1441 |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1442 // Even though this parameter list can contain only |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1443 // a single identifier, we still need to validate it |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1444 // to check for varargin or varargout. |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1445 |
23654
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
1446 if (parser.validate_param_list (tmp, octave::tree_parameter_list::out)) |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1447 $$ = tmp; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1448 else |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1449 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1450 delete tmp; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1451 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1452 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1453 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1454 | '[' return_list1 ']' |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1455 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1456 OCTAVE_YYUSE ($1, $3); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
1457 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1458 lexer.m_looking_at_return_list = false; |
17316
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1459 |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1460 // Check for duplicate parameter names, varargin, |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1461 // or varargout. |
8e2906e2fb26
avoid reduce/reduce conflict in parser rules
John W. Eaton <jwe@octave.org>
parents:
17283
diff
changeset
|
1462 |
23654
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
1463 if (parser.validate_param_list ($2, octave::tree_parameter_list::out)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1464 $$ = $2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1465 else |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1466 { |
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1467 delete $2; |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1468 YYABORT; |
17632
bd0a84de3375
further reduce memory leaks from parse errors (bug #40231)
John W. Eaton <jwe@octave.org>
parents:
17629
diff
changeset
|
1469 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1470 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1471 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1472 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1473 return_list1 : identifier |
28257
ae94e3fad6d4
fix printing of functions with varargin/varargout (bug #58279)
John W. Eaton <jwe@octave.org>
parents:
28149
diff
changeset
|
1474 { |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1475 $$ = parser.make_parameter_list (octave::tree_parameter_list::out, $1); |
28257
ae94e3fad6d4
fix printing of functions with varargin/varargout (bug #58279)
John W. Eaton <jwe@octave.org>
parents:
28149
diff
changeset
|
1476 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1477 | return_list1 ',' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1478 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1479 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
1480 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1481 $$ = parser.append_parameter_list ($1, $3); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1482 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1483 ; |
2970 | 1484 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1485 // ======================= |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1486 // Script or function file |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1487 // ======================= |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1488 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1489 parsing_local_fcns |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1490 : // empty |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
1491 { parser.parsing_local_functions (true); } |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1492 ; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23342
diff
changeset
|
1493 |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1494 push_script_symtab : // empty |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1495 { |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1496 $$ = 0; |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1497 |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
1498 // This scope may serve as the parent scope for local |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
1499 // functions in classdef files.. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1500 lexer.m_symtab_context.push (octave::symbol_scope ("parser:push_script_symtab")); |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1501 } |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1502 ; |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1503 |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1504 begin_file : push_script_symtab INPUT_FILE |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1505 { $$ = 0; } |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1506 ; |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1507 |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1508 file : begin_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
|
1509 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1510 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1511 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1512 if (lexer.m_reading_fcn_file) |
17618
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1513 { |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1514 // Delete the dummy statement_list we created |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1515 // after parsing the function. Any function |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1516 // definitions found in the file have already |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1517 // been stored in the symbol table or in |
27505
c409d16b7190
eliminate some uses of bare pointers to octave_function objects
John W. Eaton <jwe@octave.org>
parents:
27504
diff
changeset
|
1518 // base_parser::m_primary_fcn. |
17618
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1519 |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1520 // Unused symbol table context. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1521 lexer.m_symtab_context.pop (); |
17618
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1522 |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1523 delete $3; |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
1524 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
1525 if (! parser.validate_primary_fcn ()) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
1526 YYABORT; |
17618
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1527 } |
77eff9c6fb09
avoid memory leak when parsing function files (bug #40218)
John W. Eaton <jwe@octave.org>
parents:
17377
diff
changeset
|
1528 else |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1529 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
1530 octave::tree_statement *end_of_script |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1531 = parser.make_end ("endscript", true, |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
1532 $4->beg_pos (), $4->end_pos ()); |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1533 |
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1534 parser.make_script ($3, end_of_script); |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
1535 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
1536 if (! parser.validate_primary_fcn ()) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
1537 YYABORT; |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
1538 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1539 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1540 $$ = nullptr; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1541 } |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1542 | begin_file opt_nl classdef parsing_local_fcns opt_sep opt_fcn_list END_OF_INPUT |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1543 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1544 OCTAVE_YYUSE ($2, $5, $7); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1545 |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23850
diff
changeset
|
1546 // Unused symbol table context. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1547 lexer.m_symtab_context.pop (); |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
1548 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
1549 if (! parser.finish_classdef_file ($3, $6)) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
1550 YYABORT; |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1551 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1552 $$ = nullptr; |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
1553 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1554 ; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7699
diff
changeset
|
1555 |
2970 | 1556 // =================== |
1557 // Function definition | |
1558 // =================== | |
1559 | |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1560 function_beg : push_fcn_symtab FCN |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1561 { |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1562 $$ = $2; |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1563 if (lexer.m_reading_classdef_file |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1564 || lexer.m_parsing_classdef) |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1565 lexer.m_maybe_classdef_get_set_method = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1566 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1567 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1568 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1569 fcn_name : identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1570 { |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1571 if (! ($$ = parser.make_fcn_name ($1))) |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1572 { |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
1573 // make_fcn_name deleted $1. |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1574 YYABORT; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
1575 } |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1576 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1577 lexer.m_arguments_is_keyword = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1578 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1579 | GET '.' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1580 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1581 OCTAVE_YYUSE ($1, $2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1582 |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1583 $$ = $3; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1584 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1585 lexer.m_parsed_function_name.top () = true; |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1586 lexer.m_maybe_classdef_get_set_method = false; |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1587 lexer.m_parsing_classdef_get_method = true; |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1588 lexer.m_arguments_is_keyword = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1589 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1590 | SET '.' identifier |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1591 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1592 OCTAVE_YYUSE ($1, $2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1593 |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1594 $$ = $3; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1595 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1596 lexer.m_parsed_function_name.top () = true; |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1597 lexer.m_maybe_classdef_get_set_method = false; |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1598 lexer.m_parsing_classdef_set_method = true; |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1599 lexer.m_arguments_is_keyword = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1600 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1601 ; |
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 function_end : END |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1604 { |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
1605 parser.endfunction_found (true); |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
1606 |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
1607 if (parser.end_token_ok ($1, octave::token::function_end)) |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1608 $$ = parser.make_end ("endfunction", false, |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
1609 $1->beg_pos (), $1->end_pos ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1610 else |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
1611 { |
23398
d4ef04757ead
eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
23396
diff
changeset
|
1612 parser.end_token_error ($1, octave::token::function_end); |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1613 YYABORT; |
21071
f25c14056b7c
overhaul parser error handling for end token mismatch
John W. Eaton <jwe@octave.org>
parents:
21066
diff
changeset
|
1614 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1615 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1616 | END_OF_INPUT |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1617 { |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
1618 // A lot of tests are based on the assumption that this is OK |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1619 // if (lexer.m_reading_script_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1620 // { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1621 // 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
|
1622 // YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1623 // } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1624 |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
1625 if (parser.endfunction_found ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1626 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1627 parser.bison_error ("inconsistent function endings -- " |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1628 "if one function is explicitly ended, " |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1629 "so must all the others"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1630 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1631 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1632 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1633 if (! (lexer.m_reading_fcn_file || lexer.m_reading_script_file |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1634 || lexer.input_from_eval_string ())) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1635 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1636 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
|
1637 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1638 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1639 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1640 if (lexer.m_reading_classdef_file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1641 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1642 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
|
1643 YYABORT; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1644 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1645 |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16574
diff
changeset
|
1646 $$ = parser.make_end ("endfunction", true, |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
1647 $1->beg_pos (), $1->end_pos ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1648 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1649 ; |
2970 | 1650 |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1651 function : function_beg stash_comment fcn_name |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1652 opt_param_list opt_sep function_body function_end |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1653 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1654 OCTAVE_YYUSE ($5); |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1655 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1656 $$ = parser.make_function ($1, nullptr, $3, $4, $6, $7, $2); |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1657 } |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1658 | function_beg stash_comment return_list '=' fcn_name |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1659 opt_param_list opt_sep function_body function_end |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1660 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1661 OCTAVE_YYUSE ($4, $7); |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1662 |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1663 $$ = parser.make_function ($1, $3, $5, $6, $8, $9, $2); |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1664 } |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1665 ; |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1666 |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1667 function_body : at_first_executable_stmt opt_list |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1668 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1669 OCTAVE_YYUSE ($1); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1670 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1671 $$ = $2; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1672 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1673 | function_body1 opt_sep at_first_executable_stmt opt_list |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1674 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1675 OCTAVE_YYUSE ($2); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1676 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1677 $$ = parser.append_function_body ($1, $4); |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1678 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1679 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1680 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1681 at_first_executable_stmt |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1682 : // empty |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1683 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1684 $$ = 0; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1685 lexer.m_arguments_is_keyword = false; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1686 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1687 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1688 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1689 function_body1 : arguments_block |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1690 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1691 octave::tree_statement *stmt = parser.make_statement ($1); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1692 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1693 $$ = parser.make_statement_list (stmt); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1694 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1695 | function_body1 opt_sep arguments_block |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1696 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1697 octave::tree_statement *stmt = parser.make_statement ($3); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1698 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1699 $$ = parser.append_statement_list ($1, $2, stmt, false); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1700 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1701 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1702 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1703 arguments_block : arguments_beg stash_comment opt_sep args_attr_list |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1704 args_validation_list opt_sep END |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1705 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1706 OCTAVE_YYUSE ($3, $6); |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1707 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1708 octave::comment_list *lc = $2; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1709 octave::comment_list *tc = lexer.get_comment (); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1710 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1711 if (! ($$ = parser.make_arguments_block ($1, $4, $5, $7, lc, tc))) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1712 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1713 // make_arguments_block deleted $4, $5, LC, and TC. |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1714 YYABORT; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1715 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1716 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1717 lexer.m_arguments_is_keyword = true; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1718 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1719 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1720 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1721 arguments_beg : ARGUMENTS |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1722 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1723 $$ = $1; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1724 lexer.m_arguments_is_keyword = false; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1725 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1726 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1727 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1728 args_attr_list : // empty |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1729 { $$ = nullptr; } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1730 | '(' identifier ')' |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1731 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1732 OCTAVE_YYUSE ($1, $3); |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1733 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1734 // Error if $$ is nullptr. |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1735 if (! ($$ = parser.make_args_attribute_list ($2))) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1736 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1737 // make_args_attribute_list deleted $2. |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1738 YYABORT; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1739 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1740 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1741 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1742 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1743 args_validation_list |
29729
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1744 : arg_name arg_validation |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1745 { |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1746 $2->arg_name ($1); |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1747 $$ = parser.make_args_validation_list ($2); |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1748 } |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1749 | args_validation_list sep arg_name arg_validation |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1750 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1751 OCTAVE_YYUSE ($2); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1752 |
29729
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1753 $4->arg_name ($3); |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1754 $$ = parser.append_args_validation_list ($1, $4); |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1755 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1756 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1757 |
29729
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1758 // FIXME: Change grammar to allow IDENTIFIER to be be either |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1759 // "NAME" or "NAME '.' NAME", possibly not entered in the symbol |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1760 // table for the current scope. Also stash comments before identifier. |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1761 |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1762 arg_name : identifier |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1763 { $$ = $1; } |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1764 ; |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1765 |
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1766 arg_validation : size_spec class_name validation_fcns default_value |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1767 { |
29729
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
1768 if (! ($$ = parser.make_arg_validation ($1, $2, $3, $4))) |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1769 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1770 // make_arg_validation deleted ... |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1771 YYABORT; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1772 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1773 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1774 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1775 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1776 size_spec : // empty |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1777 { $$ = nullptr; } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1778 | '(' arg_list ')' |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1779 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1780 OCTAVE_YYUSE ($1, $3); |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1781 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1782 if (! ($$ = parser.make_arg_size_spec ($2))) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1783 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1784 // make_arg_size_spec deleted $2. |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1785 YYABORT; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1786 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1787 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1788 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1789 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1790 class_name : // empty |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1791 { $$ = nullptr; } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1792 | identifier |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1793 { $$ = $1; } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1794 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1795 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1796 // Use argument list so we can accept anonymous functions. |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1797 validation_fcns : // empty |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1798 { $$ = nullptr; } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1799 | '{' arg_list '}' |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1800 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1801 OCTAVE_YYUSE ($1, $3); |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1802 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1803 if (! ($$ = parser.make_arg_validation_fcns ($2))) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1804 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1805 // make_arg_validation_fcns deleted $2. |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1806 YYABORT; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1807 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1808 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1809 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1810 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1811 default_value : // empty |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1812 { $$ = nullptr; } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1813 | '=' expression |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1814 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1815 OCTAVE_YYUSE ($1); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1816 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1817 $$ = $2; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1818 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1819 ; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
1820 |
9476 | 1821 // ======== |
1822 // Classdef | |
1823 // ======== | |
1824 | |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1825 classdef_beg : CLASSDEF |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1826 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1827 if (! lexer.m_reading_classdef_file) |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1828 { |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1829 parser.bison_error ("classdef must appear inside a file containing only a class definition"); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1830 YYABORT; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1831 } |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1832 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
1833 // Create invalid parent scope. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1834 lexer.m_symtab_context.push (octave::symbol_scope ()); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1835 lexer.m_parsing_classdef = true; |
26709
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26707
diff
changeset
|
1836 lexer.m_parsing_classdef_decl = true; |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
1837 lexer.m_classdef_element_names_are_keywords = true; |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1838 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1839 $$ = $1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1840 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1841 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1842 |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1843 classdef : classdef_beg stash_comment attr_list identifier opt_sep superclass_list class_body END |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1844 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1845 OCTAVE_YYUSE ($5); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1846 |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1847 octave::comment_list *lc = $2; |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1848 octave::comment_list *tc = lexer.get_comment (); |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1849 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
1850 lexer.m_parsing_classdef = false; |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
1851 |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1852 if (! ($$ = parser.make_classdef ($1, $3, $4, $6, $7, $8, |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1853 lc, tc))) |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1854 { |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1855 // make_classdef deleted $3, $4, $6, $7, LC, and |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1856 // TC. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1857 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1858 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1859 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1860 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1861 |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1862 attr_list : // empty |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
1863 { $$ = nullptr; } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1864 | '(' attr_list1 ')' opt_sep |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
1865 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
1866 OCTAVE_YYUSE ($1, $3, $4); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
1867 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
1868 $$ = $2; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
1869 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1870 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1871 |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1872 attr_list1 : attr |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1873 { $$ = parser.make_classdef_attribute_list ($1); } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1874 | attr_list1 ',' attr |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1875 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1876 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
1877 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1878 $$ = parser.append_classdef_attribute ($1, $3); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1879 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1880 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1881 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1882 attr : identifier |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1883 { $$ = parser.make_classdef_attribute ($1); } |
29727
05d7b7e64811
eliminate unused lexical feedback flag
John W. Eaton <jwe@octave.org>
parents:
29724
diff
changeset
|
1884 | identifier '=' expression |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1885 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1886 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1887 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1888 $$ = parser.make_classdef_attribute ($1, $3); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1889 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1890 | EXPR_NOT identifier |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1891 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1892 OCTAVE_YYUSE ($1); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1893 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1894 $$ = parser.make_not_classdef_attribute ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1895 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1896 ; |
9476 | 1897 |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1898 superclass_list : // empty |
26709
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26707
diff
changeset
|
1899 { |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26707
diff
changeset
|
1900 lexer.m_parsing_classdef_decl = false; |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26707
diff
changeset
|
1901 lexer.m_parsing_classdef_superclass = false; |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1902 |
26709
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26707
diff
changeset
|
1903 $$ = nullptr; |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26707
diff
changeset
|
1904 } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1905 | superclass_list1 opt_sep |
26709
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26707
diff
changeset
|
1906 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1907 OCTAVE_YYUSE ($2); |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1908 |
26709
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26707
diff
changeset
|
1909 lexer.m_parsing_classdef_decl = false; |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26707
diff
changeset
|
1910 lexer.m_parsing_classdef_superclass = false; |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1911 |
26709
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26707
diff
changeset
|
1912 $$ = $1; |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26707
diff
changeset
|
1913 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1914 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1915 |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1916 superclass_list1 |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1917 : EXPR_LT superclass |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1918 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1919 OCTAVE_YYUSE ($1); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1920 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1921 $$ = parser.make_classdef_superclass_list ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1922 } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1923 | superclass_list1 EXPR_AND superclass |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1924 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1925 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1926 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1927 $$ = parser.append_classdef_superclass ($1, $3); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1928 } |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1929 ; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1930 |
18520
932aca9a7c57
Allow multi-level classdef package.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18419
diff
changeset
|
1931 superclass : FQ_IDENT |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1932 { $$ = parser.make_classdef_superclass ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1933 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1934 |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1935 class_body : // empty |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
1936 { |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
1937 lexer.m_classdef_element_names_are_keywords = false; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
1938 $$ = nullptr; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
1939 } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1940 | class_body1 opt_sep |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1941 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1942 OCTAVE_YYUSE ($2); |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1943 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
1944 lexer.m_classdef_element_names_are_keywords = false; |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1945 $$ = $1; |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1946 } |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1947 ; |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1948 |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1949 class_body1 : properties_block |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1950 { $$ = parser.make_classdef_body ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1951 | methods_block |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1952 { $$ = parser.make_classdef_body ($1); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1953 | events_block |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1954 { $$ = parser.make_classdef_body ($1); } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
1955 | enum_block |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
1956 { $$ = parser.make_classdef_body ($1); } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1957 | class_body1 opt_sep properties_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1958 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1959 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1960 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1961 $$ = parser.append_classdef_properties_block ($1, $3); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1962 } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1963 | class_body1 opt_sep methods_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1964 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1965 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1966 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1967 $$ = parser.append_classdef_methods_block ($1, $3); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1968 } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1969 | class_body1 opt_sep events_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1970 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1971 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1972 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1973 $$ = parser.append_classdef_events_block ($1, $3); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1974 } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
1975 | class_body1 opt_sep enum_block |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1976 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1977 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1978 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
1979 $$ = parser.append_classdef_enum_block ($1, $3); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1980 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1981 ; |
9476 | 1982 |
1983 properties_block | |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
1984 : properties_beg stash_comment opt_sep attr_list property_list END |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
1985 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
1986 OCTAVE_YYUSE ($3); |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1987 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1988 octave::comment_list *lc = $2; |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1989 octave::comment_list *tc = lexer.get_comment (); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
1990 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
1991 if (! ($$ = parser.make_classdef_properties_block |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1992 ($1, $4, $5, $6, lc, tc))) |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
1993 { |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1994 // make_classdef_properties_block deleted $4, |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
1995 // $5, LC, and TC. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
1996 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1997 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
1998 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1999 ; |
9476 | 2000 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2001 properties_beg : PROPERTIES |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2002 { |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2003 lexer.m_classdef_element_names_are_keywords = false; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2004 $$ = $1; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2005 } |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2006 ; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2007 |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2008 property_list : // empty |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2009 { |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2010 lexer.m_classdef_element_names_are_keywords = true; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2011 $$ = nullptr; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2012 } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2013 | property_list1 opt_sep |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2014 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2015 OCTAVE_YYUSE ($2); |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2016 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2017 lexer.m_classdef_element_names_are_keywords = true; |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2018 $$ = $1; |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2019 } |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2020 ; |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2021 |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2022 property_list1 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2023 : class_property |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2024 { $$ = parser.make_classdef_property_list ($1); } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2025 | property_list1 sep class_property |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2026 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2027 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2028 |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2029 // We don't look ahead to grab end-of-line comments. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2030 // Instead, they are grabbed when we see the |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2031 // identifier that becomes the next element in the |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2032 // list. If the element at the end of the list |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2033 // doesn't have a doc string, see whether the |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2034 // element we are adding is stroing an end-of-line |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2035 // comment for us to use. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2036 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2037 octave::tree_classdef_property *last_elt = $1->back (); |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2038 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2039 if (! last_elt->have_doc_string ()) |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2040 { |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2041 octave::comment_list *cl = $3->comments (); |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2042 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2043 if (cl) |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2044 { |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2045 octave::comment_elt elt = cl->front (); |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2046 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2047 if (elt.is_end_of_line ()) |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2048 last_elt->doc_string (elt.text ()); |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2049 } |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2050 } |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2051 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2052 $$ = parser.append_classdef_property ($1, $3); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2053 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2054 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2055 |
29729
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
2056 class_property : stash_comment identifier arg_validation |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2057 { $$ = parser.make_classdef_property ($1, $2, $3); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2058 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2059 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2060 methods_block : methods_beg stash_comment opt_sep attr_list methods_list END |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2061 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2062 OCTAVE_YYUSE ($3); |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2063 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2064 octave::comment_list *lc = $2; |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2065 octave::comment_list *tc = lexer.get_comment (); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2066 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
2067 if (! ($$ = parser.make_classdef_methods_block |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2068 ($1, $4, $5, $6, lc, tc))) |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
2069 { |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2070 // make_classdef_methods_block deleted $4, $5, |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2071 // LC, and TC. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
2072 YYABORT; |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
2073 } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2074 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2075 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2076 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2077 methods_beg : METHODS |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2078 { |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2079 lexer.m_classdef_element_names_are_keywords = false; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2080 $$ = $1; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2081 } |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2082 ; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2083 |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
2084 method_decl1 : identifier |
18308
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
2085 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
2086 if (! ($$ = parser.start_classdef_external_method ($1, nullptr))) |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
2087 YYABORT; |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
2088 } |
18308
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
2089 | identifier param_list |
18341
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
2090 { |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
2091 if (! ($$ = parser.start_classdef_external_method ($1, $2))) |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
2092 YYABORT; |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
2093 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2094 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2095 |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
2096 method_decl : stash_comment method_decl1 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
2097 { $$ = parser.finish_classdef_external_method ($2, nullptr, $1); } |
18341
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
2098 | stash_comment return_list '=' |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
2099 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2100 OCTAVE_YYUSE ($3); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2101 |
30896
c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
2102 lexer.m_defining_fcn++; |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
2103 lexer.m_parsed_function_name.push (false); |
18341
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
2104 } |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
2105 method_decl1 |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
2106 { |
30896
c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
2107 lexer.m_defining_fcn--; |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
2108 lexer.m_parsed_function_name.pop (); |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2109 |
18341
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
2110 $$ = parser.finish_classdef_external_method ($5, $2, $1); |
02b349ccf0ec
Allow "end" method declaration/definition in classde files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18308
diff
changeset
|
2111 } |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
2112 ; |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
2113 |
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
2114 method : method_decl |
18308
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
2115 { $$ = $1; } |
c1baf94184af
* oct-parse.in.yy: Suppress TAB characters.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18304
diff
changeset
|
2116 | function |
18262
69990d5edcc2
Allow to parse external methods declaration in classdef files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18158
diff
changeset
|
2117 { $$ = $1; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2118 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2119 |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2120 methods_list : // empty |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2121 { |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2122 lexer.m_classdef_element_names_are_keywords = true; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2123 $$ = nullptr; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2124 } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2125 | methods_list1 opt_sep |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2126 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2127 OCTAVE_YYUSE ($2); |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2128 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2129 lexer.m_classdef_element_names_are_keywords = true; |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2130 $$ = $1; |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2131 } |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2132 ; |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2133 |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2134 methods_list1 : method |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2135 { $$ = parser.make_classdef_methods_list ($1); } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2136 | methods_list1 opt_sep method |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2137 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2138 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2139 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2140 $$ = parser.append_classdef_method ($1, $3); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2141 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2142 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2143 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2144 events_block : events_beg stash_comment opt_sep attr_list events_list END |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2145 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2146 OCTAVE_YYUSE ($3); |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2147 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2148 octave::comment_list *lc = $2; |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2149 octave::comment_list *tc = lexer.get_comment (); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2150 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
2151 if (! ($$ = parser.make_classdef_events_block |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2152 ($1, $4, $5, $6, lc, tc))) |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
2153 { |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2154 // make_classdef_events_block deleted $4, $5, |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2155 // LC, and TC. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
2156 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
2157 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
2158 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2159 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2160 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2161 events_beg : EVENTS |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2162 { |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2163 lexer.m_classdef_element_names_are_keywords = false; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2164 $$ = $1; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2165 } |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2166 ; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2167 |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2168 events_list : // empty |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2169 { |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2170 lexer.m_classdef_element_names_are_keywords = true; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2171 $$ = nullptr; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2172 } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2173 | events_list1 opt_sep |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2174 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2175 OCTAVE_YYUSE ($2); |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2176 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2177 lexer.m_classdef_element_names_are_keywords = true; |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2178 $$ = $1; |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2179 } |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2180 ; |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2181 |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2182 events_list1 : class_event |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2183 { $$ = parser.make_classdef_events_list ($1); } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2184 | events_list1 opt_sep class_event |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2185 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2186 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2187 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2188 $$ = parser.append_classdef_event ($1, $3); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2189 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2190 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2191 |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2192 class_event : stash_comment identifier |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2193 { $$ = parser.make_classdef_event ($1, $2); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2194 ; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2195 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2196 enum_block : enumeration_beg stash_comment opt_sep attr_list enum_list END |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2197 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2198 OCTAVE_YYUSE ($3); |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2199 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2200 octave::comment_list *lc = $2; |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2201 octave::comment_list *tc = lexer.get_comment (); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2202 |
16289
bde729ba8381
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
2203 if (! ($$ = parser.make_classdef_enum_block |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2204 ($1, $4, $5, $6, lc, tc))) |
17656
2b1047efc4fb
don't leak memory when parsing classdef objects fails
John W. Eaton <jwe@octave.org>
parents:
17654
diff
changeset
|
2205 { |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2206 // make_classdef_enum_block deleted $4, $5, LC, |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2207 // and TC. |
21073
f7cc48f601d2
additional reworking of error handling in the parser (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21071
diff
changeset
|
2208 YYABORT; |
18419
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
2209 } |
9154dc252f47
Allow empty classdef or methods/properties/... blocks
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18395
diff
changeset
|
2210 } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
2211 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
2212 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2213 enumeration_beg : ENUMERATION |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2214 { |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2215 lexer.m_classdef_element_names_are_keywords = false; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2216 $$ = $1; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2217 } |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2218 ; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2219 |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2220 enum_list : // empty |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2221 { |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2222 lexer.m_classdef_element_names_are_keywords = true; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2223 $$ = nullptr; |
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2224 } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2225 | enum_list1 opt_sep |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2226 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2227 OCTAVE_YYUSE ($2); |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2228 |
29759
ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
John W. Eaton <jwe@octave.org>
parents:
29729
diff
changeset
|
2229 lexer.m_classdef_element_names_are_keywords = true; |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2230 $$ = $1; |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2231 } |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2232 ; |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2233 |
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2234 enum_list1 : class_enum |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2235 { $$ = parser.make_classdef_enum_list ($1); } |
28509
06bc2f0bf760
refactor some classdef parsing rules
John W. Eaton <jwe@octave.org>
parents:
28432
diff
changeset
|
2236 | enum_list1 opt_sep class_enum |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2237 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2238 OCTAVE_YYUSE ($2); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2239 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2240 $$ = parser.append_classdef_enum ($1, $3); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14846
diff
changeset
|
2241 } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
2242 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
2243 |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2244 class_enum : stash_comment identifier '(' expression ')' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2245 { |
30145
cd6f7957c889
* oct-parse.yy (OCTAVE_YYUSE): Use variadic macro.
John W. Eaton <jwe@octave.org>
parents:
30144
diff
changeset
|
2246 OCTAVE_YYUSE ($3, $5); |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
2247 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2248 $$ = parser.make_classdef_enum ($2, $4, $1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2249 } |
13249
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
2250 ; |
7861a5fd3479
accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents:
13246
diff
changeset
|
2251 |
2970 | 2252 // ============= |
2253 // Miscellaneous | |
2254 // ============= | |
2255 | |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
2256 stmt_begin : // empty |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2257 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2258 $$ = 0; |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
2259 lexer.m_at_beginning_of_statement = true; |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2260 } |
16681
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
2261 ; |
d3619d4d267c
recognize character string at beginning of statement (bug #38926, #38958)
John W. Eaton <jwe@octave.org>
parents:
16627
diff
changeset
|
2262 |
27736
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
2263 anon_fcn_begin : // empty |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
2264 { |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
2265 $$ = 0; |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
2266 lexer.m_at_beginning_of_statement = true; |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
2267 lexer.m_parsing_anon_fcn_body = true; |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
2268 } |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
2269 ; |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27729
diff
changeset
|
2270 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2271 stash_comment : // empty |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
17673
diff
changeset
|
2272 { $$ = lexer.get_comment (); } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2273 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2274 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2275 parse_error : LEXICAL_ERROR |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2276 { |
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2277 $$ = 0; |
21064
a9f2c2d72892
handle lexical errors as parser errors (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21063
diff
changeset
|
2278 std::string msg = $1->text (); |
a9f2c2d72892
handle lexical errors as parser errors (bug #46877)
John W. Eaton <jwe@octave.org>
parents:
21063
diff
changeset
|
2279 parser.bison_error (msg.c_str ()); |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2280 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2281 | error |
19778
bf737d927707
eliminate bison warnings from oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
19709
diff
changeset
|
2282 { $$ = 0; } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2283 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2284 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2285 sep_no_nl : ',' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2286 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2287 OCTAVE_YYUSE ($1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2288 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2289 $$ = ','; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2290 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2291 | ';' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2292 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2293 OCTAVE_YYUSE ($1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2294 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2295 $$ = ';'; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2296 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2297 | sep_no_nl ',' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2298 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2299 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2300 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2301 $$ = $1; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2302 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2303 | sep_no_nl ';' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2304 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2305 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2306 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2307 $$ = $1; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2308 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2309 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2310 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2311 opt_sep_no_nl : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2312 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2313 | sep_no_nl |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2314 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2315 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2316 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2317 opt_nl : // empty |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2318 { $$ = 0; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2319 | nl |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2320 { $$ = $1; } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2321 ; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2322 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2323 nl : '\n' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2324 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2325 OCTAVE_YYUSE ($1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2326 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2327 $$ = '\n'; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2328 } |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2329 | nl '\n' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2330 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2331 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2332 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2333 $$ = $1; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2334 } |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2335 ; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
2336 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2337 sep : ',' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2338 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2339 OCTAVE_YYUSE ($1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2340 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2341 $$ = ','; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2342 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2343 | ';' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2344 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2345 OCTAVE_YYUSE ($1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2346 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2347 $$ = ';'; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2348 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2349 | '\n' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2350 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2351 OCTAVE_YYUSE ($1); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2352 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2353 $$ = '\n'; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2354 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2355 | sep ',' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2356 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2357 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2358 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2359 $$ = $1; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2360 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2361 | sep ';' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2362 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2363 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2364 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2365 $$ = $1; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2366 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2367 | sep '\n' |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2368 { |
29272
59696b24ea53
avoid YYUSE in Octave parser files (see bug #59806)
John W. Eaton <jwe@octave.org>
parents:
29006
diff
changeset
|
2369 OCTAVE_YYUSE ($2); |
27762
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2370 |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2371 $$ = $1; |
80d68a3e8ec0
make location info available for more tokens in parser
John W. Eaton <jwe@octave.org>
parents:
27745
diff
changeset
|
2372 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2373 ; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2374 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2375 opt_sep : // empty |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2376 { $$ = 0; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2377 | sep |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2378 { $$ = $1; } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2379 ; |
2525 | 2380 |
1 | 2381 %% |
2382 | |
21023
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2383 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) |
24444
53ca76c5cc8d
maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents:
24377
diff
changeset
|
2384 // Restore prevailing warning state for remainder of the file. |
53ca76c5cc8d
maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents:
24377
diff
changeset
|
2385 # pragma GCC diagnostic pop |
21023
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2386 #endif |
ec532a439c6f
rework method of disabling warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
21021
diff
changeset
|
2387 |
666 | 2388 // Generic error messages. |
2389 | |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
2390 #undef lexer |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2391 #undef scanner |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16147
diff
changeset
|
2392 |
1 | 2393 static void |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2394 yyerror (octave::base_parser& parser, const char *s) |
1 | 2395 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
2396 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
|
2397 } |
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
|
2398 |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2399 OCTAVE_NAMESPACE_BEGIN |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2400 |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2401 class parse_exception : public std::runtime_error |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2402 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2403 public: |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2404 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2405 parse_exception (const std::string& message, |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2406 const std::string& fcn_name = "", |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2407 const std::string& file_name = "", |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2408 int line = -1, int column = -1) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2409 : runtime_error (message), m_message (message), |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2410 m_fcn_name (fcn_name), m_file_name (file_name), |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2411 m_line (line), m_column (column) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2412 { } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2413 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2414 parse_exception (const parse_exception&) = default; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2415 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2416 parse_exception& operator = (const parse_exception&) = default; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2417 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2418 ~parse_exception (void) = default; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2419 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2420 std::string message (void) const { return m_message; } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2421 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2422 // Provided for std::exception interface. |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2423 const char * what (void) const noexcept { return m_message.c_str (); } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2424 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2425 std::string fcn_name (void) const { return m_fcn_name; } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2426 std::string file_name (void) const { return m_file_name; } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2427 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2428 int line (void) const { return m_line; } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2429 int column (void) const { return m_column; } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2430 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2431 // virtual void display (std::ostream& os) const; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2432 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2433 private: |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2434 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2435 std::string m_message; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2436 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2437 std::string m_fcn_name; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2438 std::string m_file_name; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2439 int m_line; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2440 int m_column; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2441 }; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2442 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2443 class parse_tree_validator : public tree_walker |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2444 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2445 public: |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2446 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2447 parse_tree_validator (void) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2448 : m_scope (), m_error_list () |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2449 { } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2450 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2451 parse_tree_validator (const parse_tree_validator&) = delete; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2452 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2453 parse_tree_validator& operator = (const parse_tree_validator&) = delete; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2454 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2455 ~parse_tree_validator (void) = default; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2456 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2457 symbol_scope get_scope (void) const { return m_scope; } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2458 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2459 bool ok (void) const { return m_error_list.empty (); } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2460 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2461 std::list<parse_exception> error_list (void) const |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2462 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2463 return m_error_list; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2464 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2465 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2466 void visit_octave_user_script (octave_user_script& script) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2467 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2468 unwind_protect_var<symbol_scope> restore_var (m_scope, script.scope ()); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2469 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2470 tree_statement_list *stmt_list = script.body (); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2471 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2472 if (stmt_list) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2473 stmt_list->accept (*this); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2474 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2475 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2476 void visit_octave_user_function (octave_user_function& fcn) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2477 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2478 unwind_protect_var<symbol_scope> restore_var (m_scope, fcn.scope ()); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2479 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2480 tree_statement_list *stmt_list = fcn.body (); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2481 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2482 if (stmt_list) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2483 stmt_list->accept (*this); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2484 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2485 std::map<std::string, octave_value> subfcns = fcn.subfunctions (); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2486 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2487 if (! subfcns.empty ()) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2488 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2489 for (auto& nm_val : subfcns) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2490 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2491 octave_user_function *subfcn |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2492 = nm_val.second.user_function_value (); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2493 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2494 if (subfcn) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2495 subfcn->accept (*this); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2496 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2497 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2498 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2499 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2500 void visit_index_expression (tree_index_expression& idx_expr) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2501 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2502 if (idx_expr.is_word_list_cmd ()) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2503 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2504 std::string sym_nm = idx_expr.name (); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2505 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2506 if (m_scope.is_variable (sym_nm)) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2507 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2508 std::string message |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2509 = sym_nm + ": invalid use of symbol as both variable and command"; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2510 parse_exception pe (message, m_scope.fcn_name (), |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2511 m_scope.fcn_file_name (), |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2512 idx_expr.line (), idx_expr.column ()); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2513 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2514 m_error_list.push_back (pe); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2515 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2516 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2517 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2518 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2519 private: |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2520 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2521 symbol_scope m_scope; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2522 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2523 std::list<parse_exception> m_error_list; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2524 }; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
2525 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2526 template <typename LIST_T, typename ELT_T> |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2527 static LIST_T * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2528 list_append (LIST_T *list, ELT_T elt) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2529 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2530 list->append (elt); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2531 return list; |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2532 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
2533 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
2534 std::size_t |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2535 base_parser::parent_scope_info::size (void) const |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2536 { |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2537 return m_info.size (); |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2538 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2539 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2540 void |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2541 base_parser::parent_scope_info::push (const value_type& elt) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2542 { |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2543 m_info.push_back (elt); |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2544 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2545 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2546 void |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
2547 base_parser::parent_scope_info::push (const symbol_scope& scope) |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2548 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23600
diff
changeset
|
2549 push (value_type (scope, "")); |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2550 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2551 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2552 void |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2553 base_parser::parent_scope_info::pop (void) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2554 { |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2555 m_info.pop_back (); |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2556 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2557 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2558 bool |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2559 base_parser::parent_scope_info::name_ok (const std::string& name) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2560 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2561 // Name can't be the same as any parent function or any other |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2562 // function we've already seen. We could maintain a complex |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2563 // tree structure of names, or we can just store the set of |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2564 // full names of all the functions, which must be unique. |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2565 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2566 std::string full_name; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2567 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
2568 for (std::size_t i = 0; i < size()-1; i++) |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2569 { |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2570 const value_type& elt = m_info[i]; |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2571 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2572 if (name == elt.second) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2573 return false; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2574 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2575 full_name += elt.second + ">"; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2576 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2577 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2578 full_name += name; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2579 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2580 if (m_all_names.find (full_name) != m_all_names.end ()) |
28698
d45d1b4bb919
allow functions to be redefined in scripts (bug #52851)
John W. Eaton <jwe@octave.org>
parents:
28545
diff
changeset
|
2581 { |
d45d1b4bb919
allow functions to be redefined in scripts (bug #52851)
John W. Eaton <jwe@octave.org>
parents:
28545
diff
changeset
|
2582 // Return false (failure) if we are parsing a subfunction, local |
d45d1b4bb919
allow functions to be redefined in scripts (bug #52851)
John W. Eaton <jwe@octave.org>
parents:
28545
diff
changeset
|
2583 // function, or nested function. Otherwise, it is OK to have a |
d45d1b4bb919
allow functions to be redefined in scripts (bug #52851)
John W. Eaton <jwe@octave.org>
parents:
28545
diff
changeset
|
2584 // duplicate name. |
d45d1b4bb919
allow functions to be redefined in scripts (bug #52851)
John W. Eaton <jwe@octave.org>
parents:
28545
diff
changeset
|
2585 |
d45d1b4bb919
allow functions to be redefined in scripts (bug #52851)
John W. Eaton <jwe@octave.org>
parents:
28545
diff
changeset
|
2586 return ! (m_parser.parsing_subfunctions () |
d45d1b4bb919
allow functions to be redefined in scripts (bug #52851)
John W. Eaton <jwe@octave.org>
parents:
28545
diff
changeset
|
2587 || m_parser.parsing_local_functions () |
d45d1b4bb919
allow functions to be redefined in scripts (bug #52851)
John W. Eaton <jwe@octave.org>
parents:
28545
diff
changeset
|
2588 || m_parser.curr_fcn_depth () > 0); |
d45d1b4bb919
allow functions to be redefined in scripts (bug #52851)
John W. Eaton <jwe@octave.org>
parents:
28545
diff
changeset
|
2589 } |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2590 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2591 m_all_names.insert (full_name); |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2592 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2593 return true; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2594 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2595 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2596 bool |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2597 base_parser::parent_scope_info::name_current_scope (const std::string& name) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2598 { |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2599 if (! name_ok (name)) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2600 return false; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2601 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2602 if (size () > 0) |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2603 m_info.back().second = name; |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2604 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2605 return true; |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2606 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2607 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
2608 symbol_scope |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2609 base_parser::parent_scope_info::parent_scope (void) const |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2610 { |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
2611 return size () > 1 ? m_info[size()-2].first : symbol_scope (); |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2612 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2613 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2614 std::string |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2615 base_parser::parent_scope_info::parent_name (void) const |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2616 { |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2617 return m_info[size()-2].second; |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2618 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2619 |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2620 void base_parser::parent_scope_info::clear (void) |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2621 { |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2622 m_info.clear (); |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2623 m_all_names.clear (); |
23054
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2624 } |
564e959a0e89
avoid invalid nested function and subfunctions definitions (bug #50014)
John W. Eaton <jwe@octave.org>
parents:
23052
diff
changeset
|
2625 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2626 base_parser::base_parser (base_lexer& lxr) |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2627 : m_endfunction_found (false), m_autoloading (false), |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2628 m_fcn_file_from_relative_lookup (false), |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2629 m_parsing_subfunctions (false), m_parsing_local_functions (false), |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
2630 m_max_fcn_depth (-1), m_curr_fcn_depth (-1), m_primary_fcn_scope (), |
28698
d45d1b4bb919
allow functions to be redefined in scripts (bug #52851)
John W. Eaton <jwe@octave.org>
parents:
28545
diff
changeset
|
2631 m_curr_class_name (), m_curr_package_name (), m_function_scopes (*this), |
27505
c409d16b7190
eliminate some uses of bare pointers to octave_function objects
John W. Eaton <jwe@octave.org>
parents:
27504
diff
changeset
|
2632 m_primary_fcn (), m_subfunction_names (), m_classdef_object (), |
c409d16b7190
eliminate some uses of bare pointers to octave_function objects
John W. Eaton <jwe@octave.org>
parents:
27504
diff
changeset
|
2633 m_stmt_list (), m_lexer (lxr), m_parser_state (yypstate_new ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2634 { } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2635 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2636 base_parser::~base_parser (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2637 { |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2638 delete &m_lexer; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2639 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2640 // FIXME: Deleting the internal Bison parser state structure does |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2641 // not clean up any partial parse trees in the event of an interrupt or |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2642 // error. It's not clear how to safely do that with the C language |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2643 // parser that Bison generates. The C++ language parser that Bison |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2644 // generates would do it for us automatically whenever an exception |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2645 // is thrown while parsing input, but there is currently no C++ |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2646 // interface for a push parser. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2647 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2648 yypstate_delete (static_cast<yypstate *> (m_parser_state)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2649 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2650 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2651 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2652 base_parser::reset (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2653 { |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2654 m_endfunction_found = false; |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2655 m_autoloading = false; |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2656 m_fcn_file_from_relative_lookup = false; |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2657 m_parsing_subfunctions = false; |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2658 m_parsing_local_functions = false; |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
2659 m_max_fcn_depth = -1; |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
2660 m_curr_fcn_depth = -1; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
2661 m_primary_fcn_scope = symbol_scope (); |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2662 m_curr_class_name = ""; |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2663 m_curr_package_name = ""; |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2664 m_function_scopes.clear (); |
27505
c409d16b7190
eliminate some uses of bare pointers to octave_function objects
John W. Eaton <jwe@octave.org>
parents:
27504
diff
changeset
|
2665 m_primary_fcn = octave_value (); |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2666 m_subfunction_names.clear (); |
27504
7a31b25e3252
use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents:
27481
diff
changeset
|
2667 m_classdef_object.reset (); |
7a31b25e3252
use shared_ptr for storing classdef and statement_list objects in parser
John W. Eaton <jwe@octave.org>
parents:
27481
diff
changeset
|
2668 m_stmt_list.reset (); |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2669 |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2670 m_lexer.reset (); |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2671 |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2672 yypstate_delete (static_cast<yypstate *> (m_parser_state)); |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2673 m_parser_state = yypstate_new (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2674 } |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2675 |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26585
diff
changeset
|
2676 // Error messages for mismatched end tokens. |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2677 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2678 static std::string |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2679 end_token_as_string (token::end_tok_type ettype) |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2680 { |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2681 std::string retval = "<unknown>"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2682 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2683 switch (ettype) |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2684 { |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2685 case token::simple_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2686 retval = "end"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2687 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2688 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2689 case token::classdef_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2690 retval = "endclassdef"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2691 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2692 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2693 case token::enumeration_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2694 retval = "endenumeration"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2695 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2696 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2697 case token::events_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2698 retval = "endevents"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2699 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2700 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2701 case token::for_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2702 retval = "endfor"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2703 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2704 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2705 case token::function_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2706 retval = "endfunction"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2707 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2708 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2709 case token::if_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2710 retval = "endif"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2711 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2712 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2713 case token::methods_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2714 retval = "endmethods"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2715 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2716 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2717 case token::parfor_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2718 retval = "endparfor"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2719 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2720 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2721 case token::properties_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2722 retval = "endproperties"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2723 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2724 |
28517
6e8a9845d118
Add 'spmd' as interpreter keyword for Matlab compatibility (bug #58676).
Rik <rik@octave.org>
parents:
28516
diff
changeset
|
2725 case token::spmd_end: |
6e8a9845d118
Add 'spmd' as interpreter keyword for Matlab compatibility (bug #58676).
Rik <rik@octave.org>
parents:
28516
diff
changeset
|
2726 retval = "endspmd"; |
6e8a9845d118
Add 'spmd' as interpreter keyword for Matlab compatibility (bug #58676).
Rik <rik@octave.org>
parents:
28516
diff
changeset
|
2727 break; |
6e8a9845d118
Add 'spmd' as interpreter keyword for Matlab compatibility (bug #58676).
Rik <rik@octave.org>
parents:
28516
diff
changeset
|
2728 |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2729 case token::switch_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2730 retval = "endswitch"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2731 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2732 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2733 case token::try_catch_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2734 retval = "end_try_catch"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2735 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2736 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2737 case token::unwind_protect_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2738 retval = "end_unwind_protect"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2739 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2740 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2741 case token::while_end: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2742 retval = "endwhile"; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2743 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2744 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2745 default: |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2746 panic_impossible (); |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2747 break; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2748 } |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2749 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2750 return retval; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2751 } |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
2752 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2753 void |
28407
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2754 base_parser::statement_list (std::shared_ptr<tree_statement_list>& lst) |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2755 { |
29322
6264fb660f72
avoid crash on null statement list (bug #59938)
John W. Eaton <jwe@octave.org>
parents:
29272
diff
changeset
|
2756 if (! lst) |
6264fb660f72
avoid crash on null statement list (bug #59938)
John W. Eaton <jwe@octave.org>
parents:
29272
diff
changeset
|
2757 return; |
6264fb660f72
avoid crash on null statement list (bug #59938)
John W. Eaton <jwe@octave.org>
parents:
29272
diff
changeset
|
2758 |
28407
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2759 if (m_stmt_list) |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2760 { |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2761 // Append additional code to existing statement list. |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2762 |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2763 while (! lst->empty ()) |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2764 { |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2765 m_stmt_list->push_back (lst->front ()); |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2766 lst->pop_front (); |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2767 } |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2768 } |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2769 else |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2770 m_stmt_list = lst; |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2771 } |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2772 |
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
2773 void |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2774 base_parser::end_token_error (token *tok, token::end_tok_type expected) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2775 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2776 std::string msg = ("'" + end_token_as_string (expected) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2777 + "' command matched by '" |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2778 + end_token_as_string (tok->ettype ()) + "'"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2779 |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
2780 bison_error (msg, tok->beg_pos ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2781 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2782 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2783 // Check to see that end tokens are properly matched. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2784 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2785 bool |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2786 base_parser::end_token_ok (token *tok, token::end_tok_type expected) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2787 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2788 token::end_tok_type ettype = tok->ettype (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2789 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2790 return ettype == expected || ettype == token::simple_end; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2791 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2792 |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2793 bool |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2794 base_parser::push_fcn_symtab (void) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2795 { |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2796 m_curr_fcn_depth++; |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2797 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2798 if (m_max_fcn_depth < m_curr_fcn_depth) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2799 m_max_fcn_depth = m_curr_fcn_depth; |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2800 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2801 // Will get a real name later. |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
2802 m_lexer.m_symtab_context.push (symbol_scope ("parser:push_fcn_symtab")); |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2803 m_function_scopes.push (m_lexer.m_symtab_context.curr_scope ()); |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2804 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2805 if (! m_lexer.m_reading_script_file && m_curr_fcn_depth == 0 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2806 && ! m_parsing_subfunctions) |
28432
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
2807 { |
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
2808 m_primary_fcn_scope = m_lexer.m_symtab_context.curr_scope (); |
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
2809 m_primary_fcn_scope.mark_primary_fcn_scope (); |
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
2810 } |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2811 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2812 if (m_lexer.m_reading_script_file && m_curr_fcn_depth > 0) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2813 { |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2814 bison_error ("nested functions not implemented in this context"); |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2815 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2816 return false; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2817 } |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2818 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
2819 return true; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2820 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2821 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2822 // Make a constant. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2823 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2824 tree_constant * |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2825 base_parser::make_constant (token *tok_val) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2826 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2827 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2828 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2829 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2830 int op = tok_val->token_value (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2831 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
2832 tree_constant *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2833 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2834 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2835 { |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2836 case ':': |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2837 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2838 octave_value tmp (octave_value::magic_colon_t); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2839 retval = new tree_constant (tmp); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2840 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2841 break; |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2842 |
28582
dc8de424fc72
use octave_value object to store numeric tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
28548
diff
changeset
|
2843 case NUMBER: |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2844 { |
28582
dc8de424fc72
use octave_value object to store numeric tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
28548
diff
changeset
|
2845 retval = new tree_constant (tok_val->number (), l, c); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2846 retval->stash_original_text (tok_val->text_rep ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2847 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2848 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2849 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2850 case DQ_STRING: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2851 case SQ_STRING: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2852 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2853 std::string txt = tok_val->text (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2854 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2855 char delim = op == DQ_STRING ? '"' : '\''; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2856 octave_value tmp (txt, delim); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2857 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2858 if (txt.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2859 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2860 if (op == DQ_STRING) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2861 tmp = octave_null_str::instance; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2862 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2863 tmp = octave_null_sq_str::instance; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2864 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2865 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2866 retval = new tree_constant (tmp, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2867 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2868 if (op == DQ_STRING) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2869 txt = undo_string_escapes (txt); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2870 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2871 // FIXME: maybe this should also be handled by |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2872 // tok_val->text_rep () for character strings? |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2873 retval->stash_original_text (delim + txt + delim); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2874 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2875 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2876 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2877 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2878 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2879 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2880 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2881 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2882 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2883 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2884 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2885 tree_black_hole * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2886 base_parser::make_black_hole (void) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2887 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2888 return new tree_black_hole (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2889 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
2890 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2891 // Make a function handle. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2892 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2893 tree_fcn_handle * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2894 base_parser::make_fcn_handle (token *tok_val) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2895 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2896 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2897 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2898 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2899 tree_fcn_handle *retval = new tree_fcn_handle (tok_val->text (), l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2900 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2901 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2902 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2903 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2904 // Make an anonymous function handle. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2905 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2906 tree_anon_fcn_handle * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2907 base_parser::make_anon_fcn_handle (tree_parameter_list *param_list, |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
2908 tree_expression *expr, |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
2909 const filepos& at_pos) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2910 { |
27728
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2911 // FIXME: We need to examine EXPR and issue an error if any |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2912 // sub-expression contains an assignment, compound assignment, |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2913 // increment, or decrement operator. |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2914 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2915 anon_fcn_validator validator (param_list, expr); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2916 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2917 if (! validator.ok ()) |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2918 { |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2919 delete param_list; |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2920 delete expr; |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2921 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2922 bison_error (validator.message (), validator.line (), |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2923 validator.column ()); |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2924 |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2925 return nullptr; |
5e92bff668d6
disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27516
diff
changeset
|
2926 } |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
2927 |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
2928 symbol_scope fcn_scope = m_lexer.m_symtab_context.curr_scope (); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
2929 symbol_scope parent_scope = m_lexer.m_symtab_context.parent_scope (); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
2930 |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
2931 m_lexer.m_symtab_context.pop (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2932 |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
2933 expr->set_print_flag (false); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2934 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
2935 fcn_scope.mark_static (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2936 |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
2937 int at_line = at_pos.line (); |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
2938 int at_column = at_pos.column (); |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
2939 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2940 tree_anon_fcn_handle *retval |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
2941 = new tree_anon_fcn_handle (param_list, expr, fcn_scope, |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
2942 parent_scope, at_line, at_column); |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
2943 |
24354
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2944 std::ostringstream buf; |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2945 |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2946 tree_print_code tpc (buf); |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2947 |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2948 retval->accept (tpc); |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2949 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
2950 std::string file = m_lexer.m_fcn_file_full_name; |
24354
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2951 if (! file.empty ()) |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2952 buf << ": file: " << file; |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2953 else if (m_lexer.input_from_terminal ()) |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2954 buf << ": *terminal input*"; |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2955 else if (m_lexer.input_from_eval_string ()) |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2956 buf << ": *eval string*"; |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
2957 buf << ": line: " << at_line << " column: " << at_column; |
24354
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2958 |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2959 std::string scope_name = buf.str (); |
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2960 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
2961 fcn_scope.cache_name (scope_name); |
24354
11d3603dd880
give names to anonymous function scopes
John W. Eaton <jwe@octave.org>
parents:
24297
diff
changeset
|
2962 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2963 // FIXME: Stash the filename. This does not work and produces |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2964 // errors when executed. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
2965 //retval->stash_file_name (m_lexer.m_fcn_file_name); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2966 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2967 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2968 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
2969 |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2970 // Build a colon expression. |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2971 |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2972 tree_expression * |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2973 base_parser::make_colon_expression (tree_expression *base, |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2974 tree_expression *limit, |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2975 tree_expression *incr) |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2976 { |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2977 tree_expression *retval = nullptr; |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2978 |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2979 if (! base || ! limit) |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2980 { |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2981 delete base; |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2982 delete limit; |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2983 delete incr; |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2984 |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2985 return retval; |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2986 } |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2987 |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2988 int l = base->line (); |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2989 int c = base->column (); |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2990 |
27516
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
2991 tree_colon_expression *expr |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2992 = new tree_colon_expression (base, limit, incr, l, c); |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2993 |
27516
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
2994 retval = expr; |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
2995 |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2996 if (base->is_constant () && limit->is_constant () |
26404
abca0c2690b7
oct-parse.yy: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
2997 && (! incr || incr->is_constant ())) |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
2998 { |
27516
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
2999 interpreter& interp = __get_interpreter__ ("finish_colon_expression"); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3000 |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
3001 try |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
3002 { |
27516
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3003 // If the evaluation generates a warning message, restore |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3004 // the previous value of last_warning_message and skip the |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3005 // conversion to a constant value. |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3006 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3007 error_system& es = interp.get_error_system (); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3008 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
3009 unwind_action restore_last_warning_message |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
3010 (&error_system::set_last_warning_message, &es, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
3011 es.last_warning_message ("")); |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
3012 |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
3013 unwind_action restore_discard_warning_messages |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
3014 (&error_system::set_discard_warning_messages, &es, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
3015 es.discard_warning_messages (true)); |
27516
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3016 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
3017 tree_evaluator& tw = interp.get_evaluator (); |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
3018 |
27516
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3019 octave_value tmp = expr->evaluate (tw); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3020 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3021 std::string msg = es.last_warning_message (); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3022 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3023 if (msg.empty ()) |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3024 { |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3025 tree_constant *tc_retval |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3026 = new tree_constant (tmp, expr->line (), expr->column ()); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3027 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3028 std::ostringstream buf; |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3029 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3030 tree_print_code tpc (buf); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3031 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3032 expr->accept (tpc); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3033 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3034 tc_retval->stash_original_text (buf.str ()); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3035 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3036 delete expr; |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3037 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3038 retval = tc_retval; |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
3039 } |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
3040 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
3041 catch (const execution_exception&) |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
3042 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
3043 interp.recover_from_exception (); |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
3044 } |
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23654
diff
changeset
|
3045 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3046 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3047 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3048 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3049 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3050 // Build a binary expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3051 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3052 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3053 base_parser::make_binary_op (int op, tree_expression *op1, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3054 token *tok_val, tree_expression *op2) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3055 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3056 octave_value::binary_op t = octave_value::unknown_binary_op; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3057 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3058 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3059 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3060 case POW: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3061 t = octave_value::op_pow; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3062 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3063 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3064 case EPOW: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3065 t = octave_value::op_el_pow; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3066 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3067 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3068 case '+': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3069 t = octave_value::op_add; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3070 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3071 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3072 case '-': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3073 t = octave_value::op_sub; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3074 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3075 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3076 case '*': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3077 t = octave_value::op_mul; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3078 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3079 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3080 case '/': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3081 t = octave_value::op_div; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3082 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3083 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3084 case EMUL: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3085 t = octave_value::op_el_mul; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3086 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3087 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3088 case EDIV: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3089 t = octave_value::op_el_div; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3090 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3091 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3092 case LEFTDIV: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3093 t = octave_value::op_ldiv; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3094 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3095 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3096 case ELEFTDIV: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3097 t = octave_value::op_el_ldiv; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3098 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3099 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3100 case EXPR_LT: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3101 t = octave_value::op_lt; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3102 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3103 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3104 case EXPR_LE: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3105 t = octave_value::op_le; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3106 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3107 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3108 case EXPR_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3109 t = octave_value::op_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3110 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3111 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3112 case EXPR_GE: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3113 t = octave_value::op_ge; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3114 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3115 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3116 case EXPR_GT: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3117 t = octave_value::op_gt; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3118 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3119 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3120 case EXPR_NE: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3121 t = octave_value::op_ne; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3122 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3123 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3124 case EXPR_AND: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3125 t = octave_value::op_el_and; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3126 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3127 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3128 case EXPR_OR: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3129 t = octave_value::op_el_or; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3130 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3131 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3132 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3133 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3134 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3135 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3136 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3137 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3138 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3139 |
25829
8ac4bfa55053
restore optimization for compound transpose-mul/div ops (bug #45890)
John W. Eaton <jwe@octave.org>
parents:
25753
diff
changeset
|
3140 return maybe_compound_binary_expression (op1, op2, l, c, t); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3141 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3142 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3143 // Build a boolean expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3144 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3145 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3146 base_parser::make_boolean_op (int op, tree_expression *op1, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3147 token *tok_val, tree_expression *op2) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3148 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3149 tree_boolean_expression::type t; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3150 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3151 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3152 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3153 case EXPR_AND_AND: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3154 t = tree_boolean_expression::bool_and; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3155 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3156 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3157 case EXPR_OR_OR: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3158 t = tree_boolean_expression::bool_or; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3159 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3160 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3161 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3162 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3163 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3164 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3165 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3166 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3167 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3168 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3169 return new tree_boolean_expression (op1, op2, l, c, t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3170 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3171 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3172 // Build a prefix expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3173 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3174 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3175 base_parser::make_prefix_op (int op, tree_expression *op1, token *tok_val) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3176 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3177 octave_value::unary_op t = octave_value::unknown_unary_op; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3178 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3179 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3180 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3181 case EXPR_NOT: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3182 t = octave_value::op_not; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3183 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3184 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3185 case '+': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3186 t = octave_value::op_uplus; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3187 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3188 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3189 case '-': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3190 t = octave_value::op_uminus; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3191 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3192 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3193 case PLUS_PLUS: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3194 t = octave_value::op_incr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3195 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3196 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3197 case MINUS_MINUS: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3198 t = octave_value::op_decr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3199 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3200 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3201 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3202 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3203 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3204 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3205 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3206 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3207 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3208 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3209 return new tree_prefix_expression (op1, l, c, t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3210 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3211 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3212 // Build a postfix expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3213 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3214 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3215 base_parser::make_postfix_op (int op, tree_expression *op1, token *tok_val) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3216 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3217 octave_value::unary_op t = octave_value::unknown_unary_op; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3218 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3219 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3220 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3221 case HERMITIAN: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3222 t = octave_value::op_hermitian; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3223 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3224 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3225 case TRANSPOSE: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3226 t = octave_value::op_transpose; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3227 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3228 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3229 case PLUS_PLUS: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3230 t = octave_value::op_incr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3231 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3232 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3233 case MINUS_MINUS: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3234 t = octave_value::op_decr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3235 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3236 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3237 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3238 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3239 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3240 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3241 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3242 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3243 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3244 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3245 return new tree_postfix_expression (op1, l, c, t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3246 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3247 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3248 // Build an unwind-protect command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3249 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3250 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3251 base_parser::make_unwind_command (token *unwind_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3252 tree_statement_list *body, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3253 tree_statement_list *cleanup_stmts, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3254 token *end_tok, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3255 comment_list *lc, |
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3256 comment_list *mc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3257 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3258 tree_command *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3259 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3260 if (end_token_ok (end_tok, token::unwind_protect_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3261 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3262 comment_list *tc = m_lexer.m_comment_buf.get_comment (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3263 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3264 int l = unwind_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3265 int c = unwind_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3266 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3267 retval = new tree_unwind_protect_command (body, cleanup_stmts, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3268 lc, mc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3269 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3270 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3271 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3272 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3273 delete cleanup_stmts; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3274 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3275 end_token_error (end_tok, token::unwind_protect_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3276 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3277 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3278 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3279 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3280 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3281 // Build a try-catch command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3282 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3283 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3284 base_parser::make_try_command (token *try_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3285 tree_statement_list *body, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3286 char catch_sep, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3287 tree_statement_list *cleanup_stmts, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3288 token *end_tok, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3289 comment_list *lc, |
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3290 comment_list *mc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3291 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3292 tree_command *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3293 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3294 if (end_token_ok (end_tok, token::try_catch_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3295 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3296 comment_list *tc = m_lexer.m_comment_buf.get_comment (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3297 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3298 int l = try_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3299 int c = try_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3300 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3301 tree_identifier *id = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3302 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3303 if (! catch_sep && cleanup_stmts && ! cleanup_stmts->empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3304 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3305 tree_statement *stmt = cleanup_stmts->front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3306 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3307 if (stmt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3308 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3309 tree_expression *expr = stmt->expression (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3310 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3311 if (expr && expr->is_identifier ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3312 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3313 id = dynamic_cast<tree_identifier *> (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3314 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3315 cleanup_stmts->pop_front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3316 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3317 stmt->set_expression (nullptr); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3318 delete stmt; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3319 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3320 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3321 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3322 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3323 retval = new tree_try_catch_command (body, cleanup_stmts, id, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3324 lc, mc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3325 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3326 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3327 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3328 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3329 delete cleanup_stmts; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3330 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3331 end_token_error (end_tok, token::try_catch_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3332 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3333 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3334 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3335 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3336 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3337 // Build a while command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3338 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3339 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3340 base_parser::make_while_command (token *while_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3341 tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3342 tree_statement_list *body, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3343 token *end_tok, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3344 comment_list *lc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3345 { |
23798
771310737137
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23796
diff
changeset
|
3346 tree_command *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3347 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3348 maybe_warn_assign_as_truth_value (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3349 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3350 if (end_token_ok (end_tok, token::while_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3351 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3352 comment_list *tc = m_lexer.m_comment_buf.get_comment (); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3353 |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3354 m_lexer.m_looping--; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3355 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3356 int l = while_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3357 int c = while_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3358 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3359 retval = new tree_while_command (expr, body, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3360 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3361 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3362 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3363 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3364 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3365 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3366 end_token_error (end_tok, token::while_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3367 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3368 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3369 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3370 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3371 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3372 // Build a do-until command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3373 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3374 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3375 base_parser::make_do_until_command (token *until_tok, |
16287
04a7953496a7
create base class for parser; use reference for curr_lexer
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
3376 tree_statement_list *body, |
04a7953496a7
create base class for parser; use reference for curr_lexer
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
3377 tree_expression *expr, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3378 comment_list *lc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3379 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3380 maybe_warn_assign_as_truth_value (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3381 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3382 comment_list *tc = m_lexer.m_comment_buf.get_comment (); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3383 |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3384 m_lexer.m_looping--; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3385 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3386 int l = until_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3387 int c = until_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3388 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3389 return new tree_do_until_command (expr, body, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3390 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3391 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3392 // Build a for command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3393 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3394 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3395 base_parser::make_for_command (int tok_id, token *for_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3396 tree_argument_list *lhs, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3397 tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3398 tree_expression *maxproc, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3399 tree_statement_list *body, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3400 token *end_tok, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3401 comment_list *lc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3402 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3403 tree_command *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3404 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3405 bool parfor = tok_id == PARFOR; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3406 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3407 if (end_token_ok (end_tok, parfor ? token::parfor_end : token::for_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3408 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3409 expr->mark_as_for_cmd_expr (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3410 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3411 comment_list *tc = m_lexer.m_comment_buf.get_comment (); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3412 |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3413 m_lexer.m_looping--; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3414 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3415 int l = for_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3416 int c = for_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3417 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3418 if (lhs->length () == 1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3419 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3420 tree_expression *tmp = lhs->remove_front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3421 |
29857
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
3422 m_lexer.mark_as_variable (tmp->name ()); |
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
3423 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3424 retval = new tree_simple_for_command (parfor, tmp, expr, maxproc, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3425 body, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3426 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3427 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3428 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3429 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3430 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3431 if (parfor) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3432 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3433 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3434 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3435 delete maxproc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3436 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3437 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3438 bison_error ("invalid syntax for parfor statement"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3439 } |
29857
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
3440 |
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
3441 m_lexer.mark_as_variables (lhs->variable_names ()); |
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
3442 |
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
3443 retval = new tree_complex_for_command (lhs, expr, body, |
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
3444 lc, tc, l, c); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3445 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3446 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3447 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3448 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3449 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3450 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3451 delete maxproc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3452 delete body; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3453 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3454 end_token_error (end_tok, parfor ? token::parfor_end : token::for_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3455 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3456 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3457 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3458 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3459 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3460 // Build a break command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3461 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3462 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3463 base_parser::make_break_command (token *break_tok) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3464 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3465 int l = break_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3466 int c = break_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3467 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3468 if (! m_lexer.m_looping) |
22785
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
3469 { |
26998
258195ea1a76
Simplify error messages when break or continue statements fail to parse (bug #55995).
Rik <rik@octave.org>
parents:
26981
diff
changeset
|
3470 bison_error ("break must appear within a loop"); |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3471 return nullptr; |
22785
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
3472 } |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
3473 else |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
3474 return new tree_break_command (l, c); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3475 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3476 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3477 // Build a continue command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3478 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3479 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3480 base_parser::make_continue_command (token *continue_tok) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3481 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3482 int l = continue_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3483 int c = continue_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3484 |
26981
12532d392693
error if continue is used outside of a for loop (bug #55995)
John W. Eaton <jwe@octave.org>
parents:
26906
diff
changeset
|
3485 if (! m_lexer.m_looping) |
12532d392693
error if continue is used outside of a for loop (bug #55995)
John W. Eaton <jwe@octave.org>
parents:
26906
diff
changeset
|
3486 { |
26998
258195ea1a76
Simplify error messages when break or continue statements fail to parse (bug #55995).
Rik <rik@octave.org>
parents:
26981
diff
changeset
|
3487 bison_error ("continue must appear within a loop"); |
26981
12532d392693
error if continue is used outside of a for loop (bug #55995)
John W. Eaton <jwe@octave.org>
parents:
26906
diff
changeset
|
3488 return nullptr; |
12532d392693
error if continue is used outside of a for loop (bug #55995)
John W. Eaton <jwe@octave.org>
parents:
26906
diff
changeset
|
3489 } |
12532d392693
error if continue is used outside of a for loop (bug #55995)
John W. Eaton <jwe@octave.org>
parents:
26906
diff
changeset
|
3490 else |
12532d392693
error if continue is used outside of a for loop (bug #55995)
John W. Eaton <jwe@octave.org>
parents:
26906
diff
changeset
|
3491 return new tree_continue_command (l, c); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3492 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3493 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3494 // Build a return command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3495 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3496 tree_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3497 base_parser::make_return_command (token *return_tok) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3498 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3499 int l = return_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3500 int c = return_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3501 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3502 return new tree_return_command (l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3503 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3504 |
28518
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3505 // Build an spmd command. |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3506 |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3507 tree_spmd_command * |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3508 base_parser::make_spmd_command (token *spmd_tok, tree_statement_list *body, |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3509 token *end_tok, comment_list *lc, |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3510 comment_list *tc) |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3511 { |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3512 tree_spmd_command *retval = nullptr; |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3513 |
28522
a5541f5a78dd
make parsing of spmd and endspmd keywords work properly (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28518
diff
changeset
|
3514 if (end_token_ok (end_tok, token::spmd_end)) |
28518
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3515 { |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3516 int l = spmd_tok->line (); |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3517 int c = spmd_tok->column (); |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3518 |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3519 retval = new tree_spmd_command (body, lc, tc, l, c); |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3520 } |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3521 else |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3522 { |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3523 delete body; |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3524 delete lc; |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3525 delete tc; |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3526 |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3527 end_token_error (end_tok, token::spmd_end); |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3528 } |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3529 |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3530 return retval; |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3531 } |
b8ab8b58547d
accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
3532 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3533 // Start an if command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3534 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3535 tree_if_command_list * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3536 base_parser::start_if_command (tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3537 tree_statement_list *list) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3538 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3539 maybe_warn_assign_as_truth_value (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3540 |
30202
c2c11605fa7a
save file position info in more parse tree elements
John W. Eaton <jwe@octave.org>
parents:
30197
diff
changeset
|
3541 // Line and column will be set in finish_if_command. |
c2c11605fa7a
save file position info in more parse tree elements
John W. Eaton <jwe@octave.org>
parents:
30197
diff
changeset
|
3542 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3543 tree_if_clause *t = new tree_if_clause (expr, list); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3544 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3545 return new tree_if_command_list (t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3546 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3547 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3548 // Finish an if command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3549 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3550 tree_if_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3551 base_parser::finish_if_command (token *if_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3552 tree_if_command_list *list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3553 token *end_tok, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3554 comment_list *lc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3555 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3556 tree_if_command *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3557 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3558 if (end_token_ok (end_tok, token::if_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3559 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3560 comment_list *tc = m_lexer.m_comment_buf.get_comment (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3561 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3562 int l = if_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3563 int c = if_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3564 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3565 if (list && ! list->empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3566 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3567 tree_if_clause *elt = list->front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3568 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3569 if (elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3570 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3571 elt->line (l); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3572 elt->column (c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3573 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3574 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3575 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3576 retval = new tree_if_command (list, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3577 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3578 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3579 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3580 delete list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3581 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3582 end_token_error (end_tok, token::if_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3583 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3584 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3585 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3586 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3587 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3588 // Build an elseif clause. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3589 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3590 tree_if_clause * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3591 base_parser::make_elseif_clause (token *elseif_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3592 tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3593 tree_statement_list *list, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3594 comment_list *lc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3595 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3596 maybe_warn_assign_as_truth_value (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3597 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3598 int l = elseif_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3599 int c = elseif_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3600 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3601 return new tree_if_clause (expr, list, lc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3602 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3603 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3604 tree_if_clause * |
30202
c2c11605fa7a
save file position info in more parse tree elements
John W. Eaton <jwe@octave.org>
parents:
30197
diff
changeset
|
3605 base_parser::make_else_clause (token *else_tok, comment_list *lc, |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3606 tree_statement_list *list) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3607 { |
30202
c2c11605fa7a
save file position info in more parse tree elements
John W. Eaton <jwe@octave.org>
parents:
30197
diff
changeset
|
3608 int l = else_tok->line (); |
c2c11605fa7a
save file position info in more parse tree elements
John W. Eaton <jwe@octave.org>
parents:
30197
diff
changeset
|
3609 int c = else_tok->column (); |
c2c11605fa7a
save file position info in more parse tree elements
John W. Eaton <jwe@octave.org>
parents:
30197
diff
changeset
|
3610 |
c2c11605fa7a
save file position info in more parse tree elements
John W. Eaton <jwe@octave.org>
parents:
30197
diff
changeset
|
3611 return new tree_if_clause (list, lc, l, c); |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3612 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3613 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3614 tree_if_command_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3615 base_parser::append_if_clause (tree_if_command_list *list, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3616 tree_if_clause *clause) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3617 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3618 return list_append (list, clause); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3619 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3620 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3621 // Finish a switch command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3622 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3623 tree_switch_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3624 base_parser::finish_switch_command (token *switch_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3625 tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3626 tree_switch_case_list *list, |
16287
04a7953496a7
create base class for parser; use reference for curr_lexer
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
3627 token *end_tok, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3628 comment_list *lc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3629 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3630 tree_switch_command *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3631 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3632 if (end_token_ok (end_tok, token::switch_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3633 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3634 comment_list *tc = m_lexer.m_comment_buf.get_comment (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3635 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3636 int l = switch_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3637 int c = switch_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3638 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3639 if (list && ! list->empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3640 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3641 tree_switch_case *elt = list->front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3642 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3643 if (elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3644 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3645 elt->line (l); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3646 elt->column (c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3647 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3648 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3649 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3650 retval = new tree_switch_command (expr, list, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3651 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3652 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3653 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3654 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3655 delete list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3656 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3657 end_token_error (end_tok, token::switch_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3658 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3659 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3660 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3661 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3662 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3663 tree_switch_case_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3664 base_parser::make_switch_case_list (tree_switch_case *switch_case) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3665 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3666 return new tree_switch_case_list (switch_case); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3667 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3668 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3669 // Build a switch case. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3670 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3671 tree_switch_case * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3672 base_parser::make_switch_case (token *case_tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3673 tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3674 tree_statement_list *list, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3675 comment_list *lc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3676 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3677 maybe_warn_variable_switch_label (expr); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3678 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3679 int l = case_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3680 int c = case_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3681 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3682 return new tree_switch_case (expr, list, lc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3683 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3684 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3685 tree_switch_case * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3686 base_parser::make_default_switch_case (token *default_tok, comment_list *lc, |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3687 tree_statement_list *list) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3688 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3689 int l = default_tok->line (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3690 int c = default_tok->column (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3691 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3692 return new tree_switch_case (list, lc, l, c); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3693 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
3694 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3695 tree_switch_case_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3696 base_parser::append_switch_case (tree_switch_case_list *list, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3697 tree_switch_case *elt) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3698 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3699 return list_append (list, elt); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3700 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
3701 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3702 // Build an assignment to a variable. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3703 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3704 tree_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3705 base_parser::make_assign_op (int op, tree_argument_list *lhs, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3706 token *eq_tok, tree_expression *rhs) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3707 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3708 octave_value::assign_op t = octave_value::unknown_assign_op; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3709 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3710 switch (op) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3711 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3712 case '=': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3713 t = octave_value::op_asn_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3714 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3715 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3716 case ADD_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3717 t = octave_value::op_add_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3718 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3719 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3720 case SUB_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3721 t = octave_value::op_sub_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3722 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3723 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3724 case MUL_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3725 t = octave_value::op_mul_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3726 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3727 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3728 case DIV_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3729 t = octave_value::op_div_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3730 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3731 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3732 case LEFTDIV_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3733 t = octave_value::op_ldiv_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3734 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3735 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3736 case POW_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3737 t = octave_value::op_pow_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3738 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3739 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3740 case EMUL_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3741 t = octave_value::op_el_mul_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3742 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3743 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3744 case EDIV_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3745 t = octave_value::op_el_div_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3746 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3747 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3748 case ELEFTDIV_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3749 t = octave_value::op_el_ldiv_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3750 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3751 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3752 case EPOW_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3753 t = octave_value::op_el_pow_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3754 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3755 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3756 case AND_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3757 t = octave_value::op_el_and_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3758 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3759 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3760 case OR_EQ: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3761 t = octave_value::op_el_or_eq; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3762 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3763 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3764 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3765 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3766 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3767 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3768 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3769 int l = eq_tok->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3770 int c = eq_tok->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3771 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3772 if (! lhs->is_simple_assign_lhs () && t != octave_value::op_asn_eq) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3773 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3774 // Multiple assignments like [x,y] OP= rhs are only valid for |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3775 // '=', not '+=', etc. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3776 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3777 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3778 delete rhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3779 |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
3780 bison_error ("computed multiple assignment not allowed", |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
3781 eq_tok->beg_pos ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3782 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3783 return nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3784 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3785 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3786 if (lhs->is_simple_assign_lhs ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3787 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3788 // We are looking at a simple assignment statement like x = rhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3789 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3790 tree_expression *tmp = lhs->remove_front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3791 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3792 if ((tmp->is_identifier () || tmp->is_index_expression ()) |
26059
da2bbcf1fbcd
Deprecate C++ function is_keyword in favor of iskeyword for readability.
Rik <rik@octave.org>
parents:
26040
diff
changeset
|
3793 && iskeyword (tmp->name ())) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3794 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3795 std::string kw = tmp->name (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3796 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3797 delete tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3798 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3799 delete rhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3800 |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
3801 bison_error ("invalid assignment to keyword \"" + kw + "\"", |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
3802 eq_tok->beg_pos ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3803 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3804 return nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3805 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3806 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3807 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3808 |
29857
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
3809 m_lexer.mark_as_variable (tmp->name ()); |
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
3810 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3811 return new tree_simple_assignment (tmp, rhs, false, l, c, t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3812 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3813 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3814 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3815 std::list<std::string> names = lhs->variable_names (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3816 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22785
diff
changeset
|
3817 for (const auto& kw : names) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3818 { |
26059
da2bbcf1fbcd
Deprecate C++ function is_keyword in favor of iskeyword for readability.
Rik <rik@octave.org>
parents:
26040
diff
changeset
|
3819 if (iskeyword (kw)) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3820 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3821 delete lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3822 delete rhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3823 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3824 bison_error ("invalid assignment to keyword \"" + kw + "\"", |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
3825 eq_tok->beg_pos ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3826 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3827 return nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3828 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3829 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3830 |
29857
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
3831 m_lexer.mark_as_variables (names); |
0b01806bb663
fix command syntax parsing error (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29759
diff
changeset
|
3832 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3833 return new tree_multi_assignment (lhs, rhs, false, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3834 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3835 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3836 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3837 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3838 base_parser::make_script (tree_statement_list *cmds, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3839 tree_statement *end_script) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3840 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3841 if (! cmds) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3842 cmds = new tree_statement_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3843 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3844 cmds->append (end_script); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3845 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3846 symbol_scope script_scope = m_lexer.m_symtab_context.curr_scope (); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3847 |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3848 script_scope.cache_name (m_lexer.m_fcn_file_full_name); |
28026
262cdfc6faf9
allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
3849 script_scope.cache_fcn_file_name (m_lexer.m_fcn_file_full_name); |
262cdfc6faf9
allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
3850 script_scope.cache_dir_name (m_lexer.m_dir_name); |
24063 | 3851 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3852 octave_user_script *script |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3853 = new octave_user_script (m_lexer.m_fcn_file_full_name, |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3854 m_lexer.m_fcn_file_name, script_scope, |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3855 cmds, m_lexer.m_help_text); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3856 |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3857 m_lexer.m_symtab_context.pop (); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3858 m_lexer.m_help_text = ""; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3859 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
3860 sys::time now; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3861 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3862 script->stash_fcn_file_time (now); |
27745
7a45100a40c4
allow private scripts to be called from other private scripts
John W. Eaton <jwe@octave.org>
parents:
27736
diff
changeset
|
3863 script->stash_dir_name (m_lexer.m_dir_name); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3864 |
27505
c409d16b7190
eliminate some uses of bare pointers to octave_function objects
John W. Eaton <jwe@octave.org>
parents:
27504
diff
changeset
|
3865 m_primary_fcn = octave_value (script); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3866 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3867 |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3868 tree_identifier * |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3869 base_parser::make_fcn_name (tree_identifier *id) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3870 { |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3871 std::string id_name = id->name (); |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3872 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3873 // Make classdef local functions unique from classdef methods. |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3874 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3875 if (m_parsing_local_functions && m_curr_fcn_depth == 0) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3876 id_name = m_lexer.m_fcn_file_name + ">" + id_name; |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3877 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3878 if (! m_function_scopes.name_current_scope (id_name)) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3879 { |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3880 bison_error ("duplicate subfunction or nested function name", |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3881 id->line (), id->column ()); |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3882 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3883 delete id; |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3884 return nullptr; |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3885 } |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3886 |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
3887 symbol_scope curr_scope = m_lexer.m_symtab_context.curr_scope (); |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3888 curr_scope.cache_name (id_name); |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3889 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3890 m_lexer.m_parsed_function_name.top () = true; |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3891 m_lexer.m_maybe_classdef_get_set_method = false; |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3892 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
3893 return id; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3894 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3895 |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3896 // Define a function. |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3897 |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3898 // FIXME: combining start_function, finish_function, and |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3899 // recover_from_parsing_function should be possible, but it makes |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3900 // for a large mess. Maybe this could be a bit better organized? |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3901 |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3902 tree_function_def * |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3903 base_parser::make_function (token *fcn_tok, |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3904 tree_parameter_list *ret_list, |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3905 tree_identifier *id, |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3906 tree_parameter_list *param_list, |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3907 tree_statement_list *body, |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3908 tree_statement *end_fcn_stmt, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
3909 comment_list *lc) |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3910 { |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3911 int l = fcn_tok->line (); |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3912 int c = fcn_tok->column (); |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3913 |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3914 octave_user_function *tmp_fcn |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3915 = start_function (id, param_list, body, end_fcn_stmt); |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3916 |
26404
abca0c2690b7
oct-parse.yy: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3917 tree_function_def *retval = finish_function (ret_list, tmp_fcn, lc, l, c); |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3918 |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3919 recover_from_parsing_function (); |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3920 |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3921 return retval; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3922 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3923 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3924 // Begin defining a function. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3925 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3926 octave_user_function * |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3927 base_parser::start_function (tree_identifier *id, |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3928 tree_parameter_list *param_list, |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3929 tree_statement_list *body, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3930 tree_statement *end_fcn_stmt) |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
3931 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3932 // We'll fill in the return list later. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3933 |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3934 std::string id_name = id->name (); |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3935 |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3936 delete id; |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3937 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3938 if (m_lexer.m_parsing_classdef_get_method) |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3939 id_name.insert (0, "get."); |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3940 else if (m_lexer.m_parsing_classdef_set_method) |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3941 id_name.insert (0, "set."); |
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3942 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3943 m_lexer.m_parsing_classdef_get_method = false; |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3944 m_lexer.m_parsing_classdef_set_method = false; |
23673
1d1ce4df5255
refactor bison rules for parsing functions
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
3945 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3946 if (! body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3947 body = new tree_statement_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3948 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3949 body->append (end_fcn_stmt); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3950 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3951 octave_user_function *fcn |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3952 = new octave_user_function (m_lexer.m_symtab_context.curr_scope (), |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
3953 param_list, nullptr, body); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3954 |
26369
0249ba4c9589
Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents:
26149
diff
changeset
|
3955 comment_list *tc = m_lexer.m_comment_buf.get_comment (); |
0249ba4c9589
Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents:
26149
diff
changeset
|
3956 |
0249ba4c9589
Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents:
26149
diff
changeset
|
3957 fcn->stash_trailing_comment (tc); |
0249ba4c9589
Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents:
26149
diff
changeset
|
3958 fcn->stash_fcn_end_location (end_fcn_stmt->line (), |
0249ba4c9589
Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents:
26149
diff
changeset
|
3959 end_fcn_stmt->column ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3960 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3961 // If input is coming from a file, issue a warning if the name of |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3962 // the file does not match the name of the function stated in the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3963 // file. Matlab doesn't provide a diagnostic (it ignores the stated |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3964 // name). |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3965 if (! m_autoloading && m_lexer.m_reading_fcn_file |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
3966 && m_curr_fcn_depth == 0 && ! m_parsing_subfunctions) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3967 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3968 // FIXME: should m_lexer.m_fcn_file_name already be |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3969 // preprocessed when we get here? It seems to only be a |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3970 // problem with relative filenames. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3971 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3972 std::string nm = m_lexer.m_fcn_file_name; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3973 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3974 std::size_t pos = nm.find_last_of (sys::file_ops::dir_sep_chars ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3975 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3976 if (pos != std::string::npos) |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3977 nm = m_lexer.m_fcn_file_name.substr (pos+1); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3978 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3979 if (nm != id_name) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3980 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3981 warning_with_id |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3982 ("Octave:function-name-clash", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3983 "function name '%s' does not agree with function filename '%s'", |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3984 id_name.c_str (), m_lexer.m_fcn_file_full_name.c_str ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3985 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3986 id_name = nm; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3987 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3988 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
3989 |
28700
7d63f42e94be
allow keboard to work in functions defined in script files (bug #54789)
John W. Eaton <jwe@octave.org>
parents:
28698
diff
changeset
|
3990 sys::time now; |
7d63f42e94be
allow keboard to work in functions defined in script files (bug #54789)
John W. Eaton <jwe@octave.org>
parents:
28698
diff
changeset
|
3991 |
7d63f42e94be
allow keboard to work in functions defined in script files (bug #54789)
John W. Eaton <jwe@octave.org>
parents:
28698
diff
changeset
|
3992 fcn->stash_fcn_file_name (m_lexer.m_fcn_file_full_name); |
7d63f42e94be
allow keboard to work in functions defined in script files (bug #54789)
John W. Eaton <jwe@octave.org>
parents:
28698
diff
changeset
|
3993 fcn->stash_fcn_file_time (now); |
7d63f42e94be
allow keboard to work in functions defined in script files (bug #54789)
John W. Eaton <jwe@octave.org>
parents:
28698
diff
changeset
|
3994 fcn->stash_dir_name (m_lexer.m_dir_name); |
7d63f42e94be
allow keboard to work in functions defined in script files (bug #54789)
John W. Eaton <jwe@octave.org>
parents:
28698
diff
changeset
|
3995 fcn->stash_package_name (m_lexer.m_package_name); |
7d63f42e94be
allow keboard to work in functions defined in script files (bug #54789)
John W. Eaton <jwe@octave.org>
parents:
28698
diff
changeset
|
3996 fcn->mark_as_system_fcn_file (); |
7d63f42e94be
allow keboard to work in functions defined in script files (bug #54789)
John W. Eaton <jwe@octave.org>
parents:
28698
diff
changeset
|
3997 fcn->stash_function_name (id_name); |
7d63f42e94be
allow keboard to work in functions defined in script files (bug #54789)
John W. Eaton <jwe@octave.org>
parents:
28698
diff
changeset
|
3998 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
3999 if (m_lexer.m_reading_fcn_file || m_lexer.m_reading_classdef_file || m_autoloading) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4000 { |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4001 if (m_fcn_file_from_relative_lookup) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4002 fcn->mark_relative (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4003 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4004 if (m_lexer.m_parsing_class_method) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4005 { |
26794
287eba9ed14b
refactor predicates for classdef methods/constructors
John W. Eaton <jwe@octave.org>
parents:
26740
diff
changeset
|
4006 if (m_lexer.m_parsing_classdef) |
287eba9ed14b
refactor predicates for classdef methods/constructors
John W. Eaton <jwe@octave.org>
parents:
26740
diff
changeset
|
4007 { |
287eba9ed14b
refactor predicates for classdef methods/constructors
John W. Eaton <jwe@octave.org>
parents:
26740
diff
changeset
|
4008 if (m_curr_class_name == id_name) |
26799
0b17abf0ee9d
fix error introduced in changeset 287eba9ed14b
John W. Eaton <jwe@octave.org>
parents:
26794
diff
changeset
|
4009 fcn->mark_as_classdef_constructor (); |
26794
287eba9ed14b
refactor predicates for classdef methods/constructors
John W. Eaton <jwe@octave.org>
parents:
26740
diff
changeset
|
4010 else |
26799
0b17abf0ee9d
fix error introduced in changeset 287eba9ed14b
John W. Eaton <jwe@octave.org>
parents:
26794
diff
changeset
|
4011 fcn->mark_as_classdef_method (); |
26794
287eba9ed14b
refactor predicates for classdef methods/constructors
John W. Eaton <jwe@octave.org>
parents:
26740
diff
changeset
|
4012 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4013 else |
26794
287eba9ed14b
refactor predicates for classdef methods/constructors
John W. Eaton <jwe@octave.org>
parents:
26740
diff
changeset
|
4014 { |
287eba9ed14b
refactor predicates for classdef methods/constructors
John W. Eaton <jwe@octave.org>
parents:
26740
diff
changeset
|
4015 if (m_curr_class_name == id_name) |
26799
0b17abf0ee9d
fix error introduced in changeset 287eba9ed14b
John W. Eaton <jwe@octave.org>
parents:
26794
diff
changeset
|
4016 fcn->mark_as_legacy_constructor (); |
26794
287eba9ed14b
refactor predicates for classdef methods/constructors
John W. Eaton <jwe@octave.org>
parents:
26740
diff
changeset
|
4017 else |
26799
0b17abf0ee9d
fix error introduced in changeset 287eba9ed14b
John W. Eaton <jwe@octave.org>
parents:
26794
diff
changeset
|
4018 fcn->mark_as_legacy_method (); |
26794
287eba9ed14b
refactor predicates for classdef methods/constructors
John W. Eaton <jwe@octave.org>
parents:
26740
diff
changeset
|
4019 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4020 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4021 fcn->stash_dispatch_class (m_curr_class_name); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4022 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4023 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4024 std::string nm = fcn->fcn_file_name (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4025 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
4026 sys::file_stat fs (nm); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4027 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4028 if (fs && fs.is_newer (now)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4029 warning_with_id ("Octave:future-time-stamp", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4030 "time stamp for '%s' is in the future", nm.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4031 } |
25994
f881d3e271d2
eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents:
25830
diff
changeset
|
4032 else if (! m_lexer.input_from_tmp_history_file () |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4033 && ! m_lexer.m_force_script |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4034 && m_lexer.m_reading_script_file |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4035 && m_lexer.m_fcn_file_name == id_name) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4036 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4037 warning ("function '%s' defined within script file '%s'", |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4038 id_name.c_str (), m_lexer.m_fcn_file_full_name.c_str ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4039 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4040 |
24297
9a1b193ddd01
Recognize docstrings from subfunctions (bug #46008).
Rik <rik@octave.org>
parents:
24283
diff
changeset
|
4041 // Record help text for functions other than nested functions. |
9a1b193ddd01
Recognize docstrings from subfunctions (bug #46008).
Rik <rik@octave.org>
parents:
24283
diff
changeset
|
4042 // We cannot currently record help for nested functions (bug #46008) |
9a1b193ddd01
Recognize docstrings from subfunctions (bug #46008).
Rik <rik@octave.org>
parents:
24283
diff
changeset
|
4043 // because the doc_string of the outermost function is read first, |
9a1b193ddd01
Recognize docstrings from subfunctions (bug #46008).
Rik <rik@octave.org>
parents:
24283
diff
changeset
|
4044 // whereas this function is called for the innermost function first. |
9a1b193ddd01
Recognize docstrings from subfunctions (bug #46008).
Rik <rik@octave.org>
parents:
24283
diff
changeset
|
4045 // We could have a stack of help_text in lexer. |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
4046 if (! m_lexer.m_help_text.empty () && m_curr_fcn_depth == 0) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4047 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4048 fcn->document (m_lexer.m_help_text); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4049 |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4050 m_lexer.m_help_text = ""; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4051 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4052 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
4053 if (m_lexer.m_reading_fcn_file && m_curr_fcn_depth == 0 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4054 && ! m_parsing_subfunctions) |
27505
c409d16b7190
eliminate some uses of bare pointers to octave_function objects
John W. Eaton <jwe@octave.org>
parents:
27504
diff
changeset
|
4055 m_primary_fcn = octave_value (fcn); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4056 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4057 return fcn; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4058 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4059 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4060 tree_statement * |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
4061 base_parser::make_end (const std::string& type, bool eof, |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
4062 const filepos& beg_pos, const filepos& /*end_pos*/) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4063 { |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
4064 int l = beg_pos.line (); |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
4065 int c = beg_pos.column (); |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
4066 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4067 return make_statement (new tree_no_op_command (type, eof, l, c)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4068 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4069 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4070 tree_function_def * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4071 base_parser::finish_function (tree_parameter_list *ret_list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4072 octave_user_function *fcn, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
4073 comment_list *lc, |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4074 int l, int c) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4075 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
4076 tree_function_def *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4077 |
28545
3dae50cf0bc5
don't allow function return_list objects to be null
John W. Eaton <jwe@octave.org>
parents:
28511
diff
changeset
|
4078 if (! ret_list) |
3dae50cf0bc5
don't allow function return_list objects to be null
John W. Eaton <jwe@octave.org>
parents:
28511
diff
changeset
|
4079 ret_list = new tree_parameter_list (tree_parameter_list::out); |
3dae50cf0bc5
don't allow function return_list objects to be null
John W. Eaton <jwe@octave.org>
parents:
28511
diff
changeset
|
4080 |
3dae50cf0bc5
don't allow function return_list objects to be null
John W. Eaton <jwe@octave.org>
parents:
28511
diff
changeset
|
4081 ret_list->mark_as_formal_parameters (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4082 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4083 if (fcn) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4084 { |
28432
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
4085 std::string fcn_nm = fcn->name (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4086 std::string file = fcn->fcn_file_name (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4087 |
28432
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
4088 std::string tmp = fcn_nm; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4089 if (! file.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4090 tmp += ": " + file; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4091 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
4092 symbol_scope fcn_scope = fcn->scope (); |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
4093 fcn_scope.cache_name (tmp); |
28432
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
4094 fcn_scope.cache_fcn_name (fcn_nm); |
28026
262cdfc6faf9
allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
4095 fcn_scope.cache_fcn_file_name (file); |
262cdfc6faf9
allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
4096 fcn_scope.cache_dir_name (m_lexer.m_dir_name); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4097 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4098 if (lc) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4099 fcn->stash_leading_comment (lc); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4100 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4101 fcn->define_ret_list (ret_list); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4102 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
4103 if (m_curr_fcn_depth > 0 || m_parsing_subfunctions) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4104 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4105 fcn->stash_fcn_location (l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4106 |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23603
diff
changeset
|
4107 octave_value ov_fcn (fcn); |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23603
diff
changeset
|
4108 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4109 if (m_endfunction_found && m_function_scopes.size () > 1) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4110 { |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24624
diff
changeset
|
4111 fcn->mark_as_nested_function (); |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
4112 fcn_scope.set_nesting_depth (m_curr_fcn_depth); |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24624
diff
changeset
|
4113 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
4114 symbol_scope pscope = m_function_scopes.parent_scope (); |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24624
diff
changeset
|
4115 fcn_scope.set_parent (pscope); |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
4116 fcn_scope.set_primary_parent (m_primary_fcn_scope); |
30108
3efce22b7350
eliminate duplicate parent function name info in symbol scope objects
John W. Eaton <jwe@octave.org>
parents:
30105
diff
changeset
|
4117 |
28432
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
4118 pscope.install_nestfunction (fcn_nm, ov_fcn, fcn_scope); |
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
4119 |
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
4120 // For nested functions, the list of parent functions is |
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
4121 // set in symbol_scope::update_nest. |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4122 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4123 else |
22974
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22880
diff
changeset
|
4124 { |
ecc5eeada8dc
Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents:
22880
diff
changeset
|
4125 fcn->mark_as_subfunction (); |
28432
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
4126 m_subfunction_names.push_back (fcn_nm); |
30108
3efce22b7350
eliminate duplicate parent function name info in symbol scope objects
John W. Eaton <jwe@octave.org>
parents:
30105
diff
changeset
|
4127 |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24624
diff
changeset
|
4128 fcn_scope.set_parent (m_primary_fcn_scope); |
28432
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
4129 if (m_parsing_subfunctions) |
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
4130 fcn_scope.set_primary_parent (m_primary_fcn_scope); |
30108
3efce22b7350
eliminate duplicate parent function name info in symbol scope objects
John W. Eaton <jwe@octave.org>
parents:
30105
diff
changeset
|
4131 |
28432
71c34141cc2d
refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents:
28407
diff
changeset
|
4132 m_primary_fcn_scope.install_subfunction (fcn_nm, ov_fcn); |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24624
diff
changeset
|
4133 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4134 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4135 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
4136 if (m_curr_fcn_depth == 0) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
4137 fcn_scope.update_nest (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4138 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
4139 if (! m_lexer.m_reading_fcn_file && m_curr_fcn_depth == 0) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4140 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4141 // We are either reading a script file or defining a function |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4142 // at the command line, so this definition creates a |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4143 // tree_function object that is placed in the parse tree. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4144 // Otherwise, it is just inserted in the symbol table, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4145 // either as a subfunction or nested function (see above), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4146 // or as the primary function for the file, via |
27505
c409d16b7190
eliminate some uses of bare pointers to octave_function objects
John W. Eaton <jwe@octave.org>
parents:
27504
diff
changeset
|
4147 // m_primary_fcn (see also load_fcn_from_file,, |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4148 // parse_fcn_file, and |
24270
bc3819b7cca1
don't use symbol_table:: nesting for symbol_record, symbol_scope, or fcn_info
John W. Eaton <jwe@octave.org>
parents:
24216
diff
changeset
|
4149 // fcn_info::fcn_info_rep::find_user_function). |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4150 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4151 if (m_lexer.m_buffer_function_text) |
23730
85f1d31956c0
make echo work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4152 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4153 fcn->cache_function_text (m_lexer.m_function_text, |
23730
85f1d31956c0
make echo work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4154 fcn->time_parsed ()); |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4155 m_lexer.m_buffer_function_text = false; |
23730
85f1d31956c0
make echo work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4156 } |
85f1d31956c0
make echo work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4157 |
30202
c2c11605fa7a
save file position info in more parse tree elements
John W. Eaton <jwe@octave.org>
parents:
30197
diff
changeset
|
4158 retval = new tree_function_def (fcn, l, c); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4159 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4160 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4161 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4162 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4163 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4164 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4165 tree_statement_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4166 base_parser::append_function_body (tree_statement_list *body, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4167 tree_statement_list *list) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4168 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4169 if (list) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4170 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4171 for (const auto& elt : *list) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4172 list_append (body, elt); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4173 |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4174 list->clear (); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4175 delete (list); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4176 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4177 |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4178 return body; |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4179 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4180 |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4181 tree_arguments_block * |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4182 base_parser::make_arguments_block (token *arguments_tok, |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4183 tree_args_block_attribute_list *attr_list, |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4184 tree_args_block_validation_list *validation_list, |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4185 token *end_tok, |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4186 comment_list *lc, comment_list *tc) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4187 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4188 tree_arguments_block *retval = nullptr; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4189 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4190 if (end_token_ok (end_tok, token::arguments_end)) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4191 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4192 filepos beg_pos = arguments_tok->beg_pos (); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4193 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4194 int l = beg_pos.line (); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4195 int c = beg_pos.column (); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4196 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4197 retval = new tree_arguments_block (attr_list, validation_list, l, c); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4198 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4199 else |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4200 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4201 delete attr_list; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4202 delete validation_list; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4203 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4204 delete lc; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4205 delete tc; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4206 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4207 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4208 return retval; |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4209 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4210 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4211 tree_arg_validation * |
29729
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
4212 base_parser::make_arg_validation (tree_arg_size_spec *size_spec, |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4213 tree_identifier *class_name, |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4214 tree_arg_validation_fcns *validation_fcns, |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4215 tree_expression *default_value) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4216 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4217 // FIXME: Validate arguments and convert to more specific types |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4218 // (std::string for arg_name and class_name, etc). |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4219 |
29729
d0ce7260978d
also accept validation syntax for classdef properties
John W. Eaton <jwe@octave.org>
parents:
29728
diff
changeset
|
4220 return new tree_arg_validation (size_spec, class_name, |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4221 validation_fcns, default_value); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4222 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4223 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4224 tree_args_block_attribute_list * |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4225 base_parser::make_args_attribute_list (tree_identifier *attribute_name) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4226 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4227 // FIXME: Validate argument and convert to more specific type |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4228 // (std::string for attribute_name). |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4229 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4230 return new tree_args_block_attribute_list (attribute_name); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4231 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4232 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4233 tree_args_block_validation_list * |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4234 base_parser::make_args_validation_list (tree_arg_validation *arg_validation) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4235 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4236 return new tree_args_block_validation_list (arg_validation); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4237 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4238 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4239 tree_args_block_validation_list * |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4240 base_parser::append_args_validation_list (tree_args_block_validation_list *list, |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4241 tree_arg_validation *arg_validation) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4242 { |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4243 return list_append (list, arg_validation); |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4244 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4245 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4246 tree_arg_size_spec * |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4247 base_parser::make_arg_size_spec (tree_argument_list *size_args) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4248 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4249 // FIXME: Validate argument. |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4250 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4251 return new tree_arg_size_spec (size_args); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4252 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4253 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4254 tree_arg_validation_fcns * |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4255 base_parser::make_arg_validation_fcns (tree_argument_list *fcn_args) |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4256 { |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4257 // FIXME: Validate argument. |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4258 |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4259 return new tree_arg_validation_fcns (fcn_args); |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4260 } |
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
4261 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4262 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4263 base_parser::recover_from_parsing_function (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4264 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4265 m_lexer.m_symtab_context.pop (); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4266 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
4267 if (m_lexer.m_reading_fcn_file && m_curr_fcn_depth == 0 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4268 && ! m_parsing_subfunctions) |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4269 m_parsing_subfunctions = true; |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4270 |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4271 m_curr_fcn_depth--; |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4272 m_function_scopes.pop (); |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4273 |
30896
c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
4274 m_lexer.m_defining_fcn--; |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4275 m_lexer.m_parsed_function_name.pop (); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4276 m_lexer.m_looking_at_return_list = false; |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4277 m_lexer.m_looking_at_parameter_list = false; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4278 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4279 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4280 // A CLASSDEF block defines a class that has a constructor and other |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4281 // methods, but it is not an executable command. Parsing the block |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4282 // makes some changes in the symbol table (inserting the constructor |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4283 // and methods, and adding to the list of known objects) and creates |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4284 // a parse tree containing meta information about the class. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4285 |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4286 // LC contains comments appearing before the classdef keyword. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4287 // TC contains comments appearing between the classdef elements |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4288 // and the final end token for the classdef block. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4289 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4290 tree_classdef * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4291 base_parser::make_classdef (token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4292 tree_classdef_attribute_list *a, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4293 tree_identifier *id, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4294 tree_classdef_superclass_list *sc, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4295 tree_classdef_body *body, token *end_tok, |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4296 comment_list *lc, comment_list *tc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4297 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
4298 tree_classdef *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4299 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4300 m_lexer.m_symtab_context.pop (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4301 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4302 std::string cls_name = id->name (); |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
4303 |
30259
03ff3f1020cf
store file name in classdef class object
John W. Eaton <jwe@octave.org>
parents:
30202
diff
changeset
|
4304 std::string full_name = m_lexer.m_fcn_file_full_name; |
03ff3f1020cf
store file name in classdef class object
John W. Eaton <jwe@octave.org>
parents:
30202
diff
changeset
|
4305 std::string short_name = m_lexer.m_fcn_file_name; |
03ff3f1020cf
store file name in classdef class object
John W. Eaton <jwe@octave.org>
parents:
30202
diff
changeset
|
4306 |
03ff3f1020cf
store file name in classdef class object
John W. Eaton <jwe@octave.org>
parents:
30202
diff
changeset
|
4307 std::size_t pos |
03ff3f1020cf
store file name in classdef class object
John W. Eaton <jwe@octave.org>
parents:
30202
diff
changeset
|
4308 = short_name.find_last_of (sys::file_ops::dir_sep_chars ()); |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
4309 |
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
4310 if (pos != std::string::npos) |
30259
03ff3f1020cf
store file name in classdef class object
John W. Eaton <jwe@octave.org>
parents:
30202
diff
changeset
|
4311 short_name = short_name.substr (pos+1); |
03ff3f1020cf
store file name in classdef class object
John W. Eaton <jwe@octave.org>
parents:
30202
diff
changeset
|
4312 |
03ff3f1020cf
store file name in classdef class object
John W. Eaton <jwe@octave.org>
parents:
30202
diff
changeset
|
4313 if (short_name != cls_name) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4314 { |
27050
69082b3b99a0
use correct line in classdef file name mismatch error message (bug #55812)
John W. Eaton <jwe@octave.org>
parents:
27049
diff
changeset
|
4315 int l = id->line (); |
69082b3b99a0
use correct line in classdef file name mismatch error message (bug #55812)
John W. Eaton <jwe@octave.org>
parents:
27049
diff
changeset
|
4316 int c = id->column (); |
69082b3b99a0
use correct line in classdef file name mismatch error message (bug #55812)
John W. Eaton <jwe@octave.org>
parents:
27049
diff
changeset
|
4317 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4318 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4319 delete id; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4320 delete sc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4321 delete body; |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4322 delete lc; |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4323 delete tc; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4324 |
27050
69082b3b99a0
use correct line in classdef file name mismatch error message (bug #55812)
John W. Eaton <jwe@octave.org>
parents:
27049
diff
changeset
|
4325 bison_error ("invalid classdef definition, the class name must match the filename", l, c); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4326 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4327 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4328 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4329 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4330 if (end_token_ok (end_tok, token::classdef_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4331 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4332 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4333 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4334 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4335 if (! body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4336 body = new tree_classdef_body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4337 |
27189
946c6f117091
use dummy stack frame when creating meta class (bug #55766 and #55768)
John W. Eaton <jwe@octave.org>
parents:
27165
diff
changeset
|
4338 retval = new tree_classdef (m_lexer.m_symtab_context.curr_scope (), |
946c6f117091
use dummy stack frame when creating meta class (bug #55766 and #55768)
John W. Eaton <jwe@octave.org>
parents:
27165
diff
changeset
|
4339 a, id, sc, body, lc, tc, |
30259
03ff3f1020cf
store file name in classdef class object
John W. Eaton <jwe@octave.org>
parents:
30202
diff
changeset
|
4340 m_curr_package_name, full_name, l, c); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4341 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4342 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4343 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4344 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4345 delete id; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4346 delete sc; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4347 delete body; |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4348 delete lc; |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4349 delete tc; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4350 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4351 end_token_error (end_tok, token::switch_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4352 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4353 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4354 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4355 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4356 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4357 |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4358 // LC contains comments appearing before the properties keyword. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4359 // If this properties block appears first in the list of classdef |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4360 // elements, this comment list will be used for the help text for the |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4361 // classdef block. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4362 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4363 // TC contains comments appearing between the list of properties |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4364 // and the final end token for the properties block and may be used to |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4365 // find the doc string for the final property in the list. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4366 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4367 tree_classdef_properties_block * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4368 base_parser::make_classdef_properties_block (token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4369 tree_classdef_attribute_list *a, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4370 tree_classdef_property_list *plist, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4371 token *end_tok, |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4372 comment_list *lc, |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4373 comment_list *tc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4374 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
4375 tree_classdef_properties_block *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4376 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4377 if (end_token_ok (end_tok, token::properties_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4378 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4379 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4380 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4381 |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4382 if (plist) |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4383 { |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4384 // If the element at the end of the list doesn't have a doc |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4385 // string, see whether the first element of TC is an |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4386 // end-of-line comment for us to use. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4387 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4388 if (tc) |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4389 { |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4390 tree_classdef_property *last_elt = plist->back (); |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4391 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4392 if (! last_elt->have_doc_string ()) |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4393 { |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4394 comment_elt first_comment_elt = tc->front (); |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4395 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4396 if (first_comment_elt.is_end_of_line ()) |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4397 { |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4398 std::string eol_comment = first_comment_elt.text (); |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4399 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4400 last_elt->doc_string (eol_comment); |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4401 } |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4402 } |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4403 } |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4404 } |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4405 else |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4406 plist = new tree_classdef_property_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4407 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4408 retval = new tree_classdef_properties_block (a, plist, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4409 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4410 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4411 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4412 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4413 delete plist; |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4414 delete lc; |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4415 delete tc; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4416 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4417 end_token_error (end_tok, token::properties_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4418 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4419 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4420 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4421 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4422 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4423 tree_classdef_property_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4424 base_parser::make_classdef_property_list (tree_classdef_property *prop) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4425 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4426 return new tree_classdef_property_list (prop); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4427 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4428 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4429 tree_classdef_property * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4430 base_parser::make_classdef_property (comment_list *lc, tree_identifier *id, |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4431 tree_arg_validation *av) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4432 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4433 av->arg_name (id); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4434 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4435 if (av->size_spec () || av->class_name () || av->validation_fcns ()) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4436 warning ("size, class, and validation function specifications are not yet supported for classdef properties; INCORRECT RESULTS ARE POSSIBLE!"); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4437 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4438 return new tree_classdef_property (av, lc); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4439 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4440 |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4441 // LC contains comments appearing before the methods keyword. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4442 // If this methods block appears first in the list of classdef |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4443 // elements, this comment list will be used for the help text for the |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4444 // classdef block. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4445 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4446 tree_classdef_methods_block * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4447 base_parser::make_classdef_methods_block (token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4448 tree_classdef_attribute_list *a, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4449 tree_classdef_methods_list *mlist, |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4450 token *end_tok, comment_list *lc, |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4451 comment_list *tc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4452 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
4453 tree_classdef_methods_block *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4454 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4455 if (end_token_ok (end_tok, token::methods_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4456 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4457 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4458 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4459 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4460 if (! mlist) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4461 mlist = new tree_classdef_methods_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4462 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4463 retval = new tree_classdef_methods_block (a, mlist, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4464 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4465 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4466 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4467 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4468 delete mlist; |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4469 delete lc; |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4470 delete tc; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4471 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4472 end_token_error (end_tok, token::methods_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4473 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4474 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4475 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4476 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4477 |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4478 // LC contains comments appearing before the events keyword. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4479 // If this events block appears first in the list of classdef |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4480 // elements, this comment list will be used for the help text for the |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4481 // classdef block. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4482 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4483 // TC contains comments appearing between the list of events and |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4484 // the final end token for the events block and may be used to find |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4485 // the doc string for the final event in the list. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4486 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4487 tree_classdef_events_block * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4488 base_parser::make_classdef_events_block (token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4489 tree_classdef_attribute_list *a, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4490 tree_classdef_events_list *elist, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4491 token *end_tok, |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4492 comment_list *lc, |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4493 comment_list *tc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4494 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
4495 tree_classdef_events_block *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4496 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4497 if (end_token_ok (end_tok, token::events_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4498 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4499 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4500 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4501 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4502 if (! elist) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4503 elist = new tree_classdef_events_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4504 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4505 retval = new tree_classdef_events_block (a, elist, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4506 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4507 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4508 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4509 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4510 delete elist; |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4511 delete lc; |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4512 delete tc; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4513 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4514 end_token_error (end_tok, token::events_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4515 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4516 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4517 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4518 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4519 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4520 tree_classdef_events_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4521 base_parser::make_classdef_events_list (tree_classdef_event *e) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4522 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4523 return new tree_classdef_events_list (e); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4524 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4525 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4526 tree_classdef_event * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4527 base_parser::make_classdef_event (comment_list *lc, tree_identifier *id) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4528 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4529 return new tree_classdef_event (id, lc); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4530 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4531 |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4532 // LC contains comments appearing before the enumeration keyword. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4533 // If this enumeration block appears first in the list of classdef |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4534 // elements, this comment list will be used for the help text for the |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4535 // classdef block. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4536 |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4537 // TC contains comments appearing between the list of |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4538 // enumerations and the final end token for the enumeration block and |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4539 // may be used to find the doc string for the final enumeration in the |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4540 // list. |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4541 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4542 tree_classdef_enum_block * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4543 base_parser::make_classdef_enum_block (token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4544 tree_classdef_attribute_list *a, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4545 tree_classdef_enum_list *elist, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4546 token *end_tok, |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4547 comment_list *lc, |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4548 comment_list *tc) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4549 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
4550 tree_classdef_enum_block *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4551 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4552 if (end_token_ok (end_tok, token::enumeration_end)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4553 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4554 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4555 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4556 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4557 if (! elist) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4558 elist = new tree_classdef_enum_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4559 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4560 retval = new tree_classdef_enum_block (a, elist, lc, tc, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4561 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4562 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4563 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4564 delete a; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4565 delete elist; |
28511
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4566 delete lc; |
59dfd9ed72a3
capture comments for classdef classes, properties, events, and enumerations
John W. Eaton <jwe@octave.org>
parents:
28509
diff
changeset
|
4567 delete tc; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4568 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4569 end_token_error (end_tok, token::enumeration_end); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4570 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4571 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4572 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4573 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4574 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4575 tree_classdef_enum_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4576 base_parser::make_classdef_enum_list (tree_classdef_enum *e) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4577 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4578 return new tree_classdef_enum_list (e); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4579 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4580 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4581 tree_classdef_enum * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4582 base_parser::make_classdef_enum (tree_identifier *id, tree_expression *expr, |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4583 comment_list *lc) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4584 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4585 return new tree_classdef_enum (id, expr, lc); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4586 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4587 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4588 tree_classdef_property_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4589 base_parser::append_classdef_property (tree_classdef_property_list *list, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4590 tree_classdef_property *elt) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4591 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4592 return list_append (list, elt); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4593 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4594 |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4595 tree_classdef_events_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4596 base_parser::append_classdef_event (tree_classdef_events_list *list, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4597 tree_classdef_event *elt) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4598 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4599 return list_append (list, elt); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4600 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4601 |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4602 tree_classdef_enum_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4603 base_parser::append_classdef_enum (tree_classdef_enum_list *list, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4604 tree_classdef_enum *elt) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4605 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4606 return list_append (list, elt); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4607 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4608 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4609 tree_classdef_superclass_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4610 base_parser::make_classdef_superclass_list (tree_classdef_superclass *sc) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4611 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4612 return new tree_classdef_superclass_list (sc); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4613 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4614 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4615 tree_classdef_superclass * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4616 base_parser::make_classdef_superclass (token *fqident) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4617 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4618 return new tree_classdef_superclass (fqident->text ()); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4619 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4620 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4621 tree_classdef_superclass_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4622 base_parser::append_classdef_superclass (tree_classdef_superclass_list *list, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4623 tree_classdef_superclass *elt) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4624 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4625 return list_append (list, elt); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4626 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4627 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4628 tree_classdef_attribute_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4629 base_parser::make_classdef_attribute_list (tree_classdef_attribute *attr) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4630 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4631 return new tree_classdef_attribute_list (attr); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4632 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4633 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4634 tree_classdef_attribute * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4635 base_parser::make_classdef_attribute (tree_identifier *id, |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4636 tree_expression *expr) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4637 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4638 return (expr |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4639 ? new tree_classdef_attribute (id, expr) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4640 : new tree_classdef_attribute (id)); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4641 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4642 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4643 tree_classdef_attribute * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4644 base_parser::make_not_classdef_attribute (tree_identifier *id) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4645 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4646 return new tree_classdef_attribute (id, false); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4647 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4648 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4649 tree_classdef_attribute_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4650 base_parser::append_classdef_attribute (tree_classdef_attribute_list *list, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4651 tree_classdef_attribute *elt) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4652 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4653 return list_append (list, elt); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4654 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4655 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4656 tree_classdef_body * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4657 base_parser::make_classdef_body (tree_classdef_properties_block *pb) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4658 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4659 return new tree_classdef_body (pb); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4660 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4661 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4662 tree_classdef_body * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4663 base_parser::make_classdef_body (tree_classdef_methods_block *mb) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4664 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4665 return new tree_classdef_body (mb); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4666 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4667 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4668 tree_classdef_body * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4669 base_parser::make_classdef_body (tree_classdef_events_block *evb) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4670 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4671 return new tree_classdef_body (evb); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4672 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4673 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4674 tree_classdef_body * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4675 base_parser::make_classdef_body (tree_classdef_enum_block *enb) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4676 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4677 return new tree_classdef_body (enb); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4678 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4679 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4680 tree_classdef_body * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4681 base_parser::append_classdef_properties_block (tree_classdef_body *body, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4682 tree_classdef_properties_block *block) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4683 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4684 return list_append (body, block); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4685 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4686 |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4687 tree_classdef_body * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4688 base_parser::append_classdef_methods_block (tree_classdef_body *body, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4689 tree_classdef_methods_block *block) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4690 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4691 return list_append (body, block); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4692 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4693 |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4694 tree_classdef_body * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4695 base_parser::append_classdef_events_block (tree_classdef_body *body, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4696 tree_classdef_events_block *block) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4697 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4698 return list_append (body, block); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4699 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4700 |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4701 tree_classdef_body * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4702 base_parser::append_classdef_enum_block (tree_classdef_body *body, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4703 tree_classdef_enum_block *block) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4704 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4705 return list_append (body, block); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4706 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4707 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4708 octave_user_function* |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4709 base_parser::start_classdef_external_method (tree_identifier *id, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4710 tree_parameter_list *pl) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4711 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
4712 octave_user_function* retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4713 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4714 // External methods are only allowed within @-folders. In this case, |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4715 // m_curr_class_name will be non-empty. |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4716 |
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4717 if (! m_curr_class_name.empty ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4718 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4719 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4720 std::string mname = id->name (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4721 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4722 // Methods that cannot be declared outside the classdef file: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4723 // - methods with '.' character (e.g. property accessors) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4724 // - class constructor |
27216
823b4bcf79fc
unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents:
27189
diff
changeset
|
4725 // - 'delete' |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4726 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4727 if (mname.find_first_of (".") == std::string::npos |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4728 && mname != "delete" |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
4729 && mname != m_curr_class_name) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4730 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4731 // Create a dummy function that is used until the real method |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4732 // is loaded. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4733 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
4734 retval = new octave_user_function (symbol_scope (), pl); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4735 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4736 retval->stash_function_name (mname); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4737 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4738 int l = id->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4739 int c = id->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4740 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4741 retval->stash_fcn_location (l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4742 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4743 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4744 bison_error ("invalid external method declaration, an external " |
27216
823b4bcf79fc
unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents:
27189
diff
changeset
|
4745 "method cannot be the class constructor, 'delete' " |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4746 "or have a dot (.) character in its name"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4747 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4748 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4749 bison_error ("external methods are only allowed in @-folders"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4750 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4751 if (! retval) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4752 delete id; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4753 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4754 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4755 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4756 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4757 tree_function_def * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4758 base_parser::finish_classdef_external_method (octave_user_function *fcn, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4759 tree_parameter_list *ret_list, |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
4760 comment_list *cl) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4761 { |
28545
3dae50cf0bc5
don't allow function return_list objects to be null
John W. Eaton <jwe@octave.org>
parents:
28511
diff
changeset
|
4762 if (! ret_list) |
3dae50cf0bc5
don't allow function return_list objects to be null
John W. Eaton <jwe@octave.org>
parents:
28511
diff
changeset
|
4763 ret_list = new tree_parameter_list (tree_parameter_list::out); |
3dae50cf0bc5
don't allow function return_list objects to be null
John W. Eaton <jwe@octave.org>
parents:
28511
diff
changeset
|
4764 |
3dae50cf0bc5
don't allow function return_list objects to be null
John W. Eaton <jwe@octave.org>
parents:
28511
diff
changeset
|
4765 fcn->define_ret_list (ret_list); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4766 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4767 if (cl) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4768 fcn->stash_leading_comment (cl); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4769 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4770 int l = fcn->beginning_line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4771 int c = fcn->beginning_column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4772 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4773 return new tree_function_def (fcn, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4774 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4775 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4776 tree_classdef_methods_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4777 base_parser::make_classdef_methods_list (tree_function_def *fcn_def) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4778 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4779 octave_value fcn; |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4780 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4781 if (fcn_def) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4782 fcn = fcn_def->function (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4783 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4784 delete fcn_def; |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4785 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4786 return new tree_classdef_methods_list (fcn); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4787 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
4788 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4789 tree_classdef_methods_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4790 base_parser::append_classdef_method (tree_classdef_methods_list *list, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4791 tree_function_def *fcn_def) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4792 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4793 octave_value fcn; |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4794 |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4795 if (fcn_def) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4796 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4797 fcn = fcn_def->function (); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4798 |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4799 delete fcn_def; |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4800 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4801 |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4802 return list_append (list, fcn); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4803 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4804 |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4805 bool |
24067
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4806 base_parser::finish_classdef_file (tree_classdef *cls, |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4807 tree_statement_list *local_fcns) |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4808 { |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4809 parse_tree_validator validator; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4810 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4811 cls->accept (validator); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4812 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4813 if (local_fcns) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4814 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4815 for (tree_statement *elt : *local_fcns) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4816 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4817 tree_command *cmd = elt->command (); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4818 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4819 tree_function_def *fcn_def |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4820 = dynamic_cast<tree_function_def *> (cmd); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4821 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4822 fcn_def->accept (validator); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4823 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4824 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4825 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4826 if (! validator.ok ()) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4827 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4828 delete cls; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4829 delete local_fcns; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4830 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4831 bison_error (validator.error_list ()); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4832 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4833 return false; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4834 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4835 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4836 // Require all validations to succeed before installing any local |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4837 // functions or defining the classdef object for later use. |
24067
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4838 |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4839 if (local_fcns) |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4840 { |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4841 symbol_table& symtab |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4842 = __get_symbol_table__ ("base_parser::finish_classdef_file"); |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4843 |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4844 for (tree_statement *elt : *local_fcns) |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4845 { |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4846 tree_command *cmd = elt->command (); |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4847 |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4848 tree_function_def *fcn_def |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4849 = dynamic_cast<tree_function_def *> (cmd); |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4850 |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4851 octave_value ov_fcn = fcn_def->function (); |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4852 octave_user_function *fcn = ov_fcn.user_function_value (); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4853 |
24067
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4854 std::string nm = fcn->name (); |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4855 std::string file = fcn->fcn_file_name (); |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4856 |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4857 symtab.install_local_function (nm, ov_fcn, file); |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4858 } |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4859 |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4860 delete local_fcns; |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4861 } |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4862 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4863 // FIXME: Is it possible for the following condition to be false? |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4864 if (m_lexer.m_reading_classdef_file) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4865 m_classdef_object = std::shared_ptr<tree_classdef> (cls); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4866 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
4867 return true; |
24067
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4868 } |
5b88383b9a69
install local functions after classdef parse is complete (bug #52080)
John W. Eaton <jwe@octave.org>
parents:
24063
diff
changeset
|
4869 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4870 // Make an index expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4871 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4872 tree_index_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4873 base_parser::make_index_expression (tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4874 tree_argument_list *args, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4875 char type) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4876 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
4877 tree_index_expression *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4878 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4879 if (args && args->has_magic_tilde ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4880 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4881 delete expr; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4882 delete args; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4883 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4884 bison_error ("invalid use of empty argument (~) in index expression"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4885 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4886 else |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
4887 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4888 int l = expr->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4889 int c = expr->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4890 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4891 if (! expr->is_postfix_indexed ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4892 expr->set_postfix_index (type); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4893 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4894 if (expr->is_index_expression ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4895 { |
26707
f35db7d5b7a4
use dynamic_cast instead of static_cast as appropriate parser
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
4896 tree_index_expression *tmp |
f35db7d5b7a4
use dynamic_cast instead of static_cast as appropriate parser
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
4897 = dynamic_cast<tree_index_expression *> (expr); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4898 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4899 retval = tmp->append (args, type); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4900 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4901 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4902 retval = new tree_index_expression (expr, args, l, c, type); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4903 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4904 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4905 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4906 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4907 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4908 // Make an indirect reference expression. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4909 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4910 tree_index_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4911 base_parser::make_indirect_ref (tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4912 const std::string& elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4913 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
4914 tree_index_expression *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4915 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4916 int l = expr->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4917 int c = expr->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4918 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4919 if (! expr->is_postfix_indexed ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4920 expr->set_postfix_index ('.'); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4921 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4922 if (expr->is_index_expression ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4923 { |
26707
f35db7d5b7a4
use dynamic_cast instead of static_cast as appropriate parser
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
4924 tree_index_expression *tmp |
f35db7d5b7a4
use dynamic_cast instead of static_cast as appropriate parser
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
4925 = dynamic_cast<tree_index_expression *> (expr); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4926 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4927 retval = tmp->append (elt); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4928 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4929 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4930 retval = new tree_index_expression (expr, elt, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4931 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4932 m_lexer.m_looking_at_indirect_ref = false; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4933 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4934 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4935 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4936 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4937 // Make an indirect reference expression with dynamic field name. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4938 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4939 tree_index_expression * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4940 base_parser::make_indirect_ref (tree_expression *expr, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4941 tree_expression *elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4942 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
4943 tree_index_expression *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4944 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4945 int l = expr->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4946 int c = expr->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4947 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4948 if (! expr->is_postfix_indexed ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4949 expr->set_postfix_index ('.'); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4950 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4951 if (expr->is_index_expression ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4952 { |
26707
f35db7d5b7a4
use dynamic_cast instead of static_cast as appropriate parser
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
4953 tree_index_expression *tmp |
f35db7d5b7a4
use dynamic_cast instead of static_cast as appropriate parser
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
4954 = dynamic_cast<tree_index_expression *> (expr); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4955 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
4956 retval = list_append (tmp, elt); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4957 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4958 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4959 retval = new tree_index_expression (expr, elt, l, c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4960 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4961 m_lexer.m_looking_at_indirect_ref = false; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4962 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4963 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4964 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4965 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4966 // Make a declaration command. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4967 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4968 tree_decl_command * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4969 base_parser::make_decl_command (int tok, token *tok_val, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4970 tree_decl_init_list *lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4971 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
4972 tree_decl_command *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4973 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4974 int l = tok_val->line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4975 int c = tok_val->column (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4976 |
24216
81d723f0cdfe
clean up change merged from stable
John W. Eaton <jwe@octave.org>
parents:
24215
diff
changeset
|
4977 if (lst) |
81d723f0cdfe
clean up change merged from stable
John W. Eaton <jwe@octave.org>
parents:
24215
diff
changeset
|
4978 m_lexer.mark_as_variables (lst->variable_names ()); |
24213
d2cfaaa57677
tag global and persistent symbols as variables when parsing (bug #52363)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
4979 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4980 switch (tok) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4981 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4982 case GLOBAL: |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
4983 { |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
4984 retval = new tree_decl_command ("global", lst, l, c); |
23470
a41fdb801db6
use mark_global and mark_persistent consistently
John W. Eaton <jwe@octave.org>
parents:
23469
diff
changeset
|
4985 retval->mark_global (); |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
4986 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4987 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4988 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4989 case PERSISTENT: |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26059
diff
changeset
|
4990 if (m_curr_fcn_depth >= 0) |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
4991 { |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
4992 retval = new tree_decl_command ("persistent", lst, l, c); |
23470
a41fdb801db6
use mark_global and mark_persistent consistently
John W. Eaton <jwe@octave.org>
parents:
23469
diff
changeset
|
4993 retval->mark_persistent (); |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23454
diff
changeset
|
4994 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4995 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4996 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4997 if (m_lexer.m_reading_script_file) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
4998 warning ("ignoring persistent declaration near line %d of file '%s'", |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
4999 l, m_lexer.m_fcn_file_full_name.c_str ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5000 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5001 warning ("ignoring persistent declaration near line %d", l); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5002 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5003 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5004 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5005 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5006 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5007 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5008 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5009 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5010 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5011 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5012 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5013 tree_decl_init_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5014 base_parser::make_decl_init_list (tree_decl_elt *elt) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5015 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5016 return new tree_decl_init_list (elt); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5017 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5018 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5019 tree_decl_init_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5020 base_parser::append_decl_init_list (tree_decl_init_list *list, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5021 tree_decl_elt *elt) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5022 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5023 return list_append (list, elt); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5024 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5025 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5026 tree_decl_elt * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5027 base_parser::make_decl_elt (tree_identifier *id, token */*eq_op*/, |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5028 tree_expression *expr) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5029 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5030 return expr ? new tree_decl_elt (id, expr) : new tree_decl_elt (id); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5031 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5032 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5033 bool |
23654
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5034 base_parser::validate_param_list (tree_parameter_list *lst, |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5035 tree_parameter_list::in_or_out type) |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5036 { |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5037 std::set<std::string> dict; |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5038 |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5039 for (tree_decl_elt *elt : *lst) |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5040 { |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5041 tree_identifier *id = elt->ident (); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5042 |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5043 if (id) |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5044 { |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5045 std::string name = id->name (); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5046 |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5047 if (id->is_black_hole ()) |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5048 { |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5049 if (type != tree_parameter_list::in) |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5050 { |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5051 bison_error ("invalid use of ~ in output list"); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5052 return false; |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5053 } |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5054 } |
28647
f0414ee0fefe
disallow keywords in function parameter lists (bug #58945)
John W. Eaton <jwe@octave.org>
parents:
28582
diff
changeset
|
5055 else if (iskeyword (name)) |
f0414ee0fefe
disallow keywords in function parameter lists (bug #58945)
John W. Eaton <jwe@octave.org>
parents:
28582
diff
changeset
|
5056 { |
f0414ee0fefe
disallow keywords in function parameter lists (bug #58945)
John W. Eaton <jwe@octave.org>
parents:
28582
diff
changeset
|
5057 bison_error ("invalid use of keyword '" + name |
f0414ee0fefe
disallow keywords in function parameter lists (bug #58945)
John W. Eaton <jwe@octave.org>
parents:
28582
diff
changeset
|
5058 + "' in parameter list"); |
f0414ee0fefe
disallow keywords in function parameter lists (bug #58945)
John W. Eaton <jwe@octave.org>
parents:
28582
diff
changeset
|
5059 return false; |
f0414ee0fefe
disallow keywords in function parameter lists (bug #58945)
John W. Eaton <jwe@octave.org>
parents:
28582
diff
changeset
|
5060 } |
23654
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5061 else if (dict.find (name) != dict.end ()) |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5062 { |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5063 bison_error ("'" + name |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5064 + "' appears more than once in parameter list"); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5065 return false; |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5066 } |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5067 else |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5068 dict.insert (name); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5069 } |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5070 } |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5071 |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5072 std::string va_type = (type == tree_parameter_list::in |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5073 ? "varargin" : "varargout"); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5074 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
5075 std::size_t len = lst->length (); |
23654
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5076 |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5077 if (len > 0) |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5078 { |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5079 tree_decl_elt *elt = lst->back (); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5080 |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5081 tree_identifier *id = elt->ident (); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5082 |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5083 if (id && id->name () == va_type) |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5084 { |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5085 if (len == 1) |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5086 lst->mark_varargs_only (); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5087 else |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5088 lst->mark_varargs (); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5089 |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5090 tree_parameter_list::iterator p = lst->end (); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5091 --p; |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5092 delete *p; |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5093 lst->erase (p); |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5094 } |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5095 } |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5096 |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5097 return true; |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5098 } |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5099 |
da89ce0d49eb
avoid possible memory leak in parser
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
5100 bool |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5101 base_parser::validate_array_list (tree_expression *e) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5102 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5103 bool retval = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5104 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5105 tree_array_list *al = dynamic_cast<tree_array_list *> (e); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5106 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22785
diff
changeset
|
5107 for (tree_argument_list* row : *al) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5108 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5109 if (row && row->has_magic_tilde ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5110 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5111 retval = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5112 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5113 if (e->is_matrix ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5114 bison_error ("invalid use of tilde (~) in matrix expression"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5115 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5116 bison_error ("invalid use of tilde (~) in cell expression"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5117 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5118 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5119 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5120 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5121 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5122 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5123 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5124 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5125 tree_argument_list * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5126 base_parser::validate_matrix_for_assignment (tree_expression *e) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5127 { |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
5128 tree_argument_list *retval = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5129 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5130 if (e->is_constant ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5131 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
5132 tree_evaluator& tw |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
5133 = __get_evaluator__ ("validate_matrix_for_assignment"); |
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
5134 |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
5135 octave_value ov = e->evaluate (tw); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5136 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5137 delete e; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5138 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
5139 if (ov.isempty ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5140 bison_error ("invalid empty left hand side of assignment"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5141 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5142 bison_error ("invalid constant left hand side of assignment"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5143 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5144 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5145 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5146 bool is_simple_assign = true; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5147 |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
5148 tree_argument_list *tmp = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5149 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5150 if (e->is_matrix ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5151 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5152 tree_matrix *mat = dynamic_cast<tree_matrix *> (e); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5153 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5154 if (mat && mat->size () == 1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5155 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5156 tmp = mat->front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5157 mat->pop_front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5158 delete e; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5159 is_simple_assign = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5160 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5161 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5162 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5163 tmp = new tree_argument_list (e); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5164 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5165 if (tmp && tmp->is_valid_lvalue_list ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5166 { |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
5167 m_lexer.mark_as_variables (tmp->variable_names ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5168 retval = tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5169 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5170 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5171 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5172 delete tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5173 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5174 bison_error ("invalid left hand side of assignment"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5175 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5176 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5177 if (retval && is_simple_assign) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5178 retval->mark_as_simple_assign_lhs (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5179 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5180 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5181 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5182 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5183 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5184 // Finish building an array_list. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5185 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5186 tree_expression * |
27764
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5187 base_parser::finish_array_list (tree_array_list *array_list, |
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5188 token */*open_delim*/, token *close_delim) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5189 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5190 tree_expression *retval = array_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5191 |
27764
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5192 array_list->set_location (close_delim->line (), close_delim->column ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5193 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5194 if (array_list->all_elements_are_constant ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5195 { |
27516
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5196 interpreter& interp = __get_interpreter__ ("finish_array_list"); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5197 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5198 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5199 { |
27516
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5200 // If the evaluation generates a warning message, restore |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5201 // the previous value of last_warning_message and skip the |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5202 // conversion to a constant value. |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5203 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5204 error_system& es = interp.get_error_system (); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5205 |
29253
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
5206 unwind_action restore_last_warning_message |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
5207 (&error_system::set_last_warning_message, &es, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
5208 es.last_warning_message ("")); |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
5209 |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
5210 unwind_action restore_discard_warning_messages |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
5211 (&error_system::set_discard_warning_messages, &es, |
28913793f678
prefer unwind_action over unwind_protect in more places
John W. Eaton <jwe@octave.org>
parents:
29007
diff
changeset
|
5212 es.discard_warning_messages (true)); |
27516
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5213 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
5214 tree_evaluator& tw = interp.get_evaluator (); |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
5215 |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
5216 octave_value tmp = array_list->evaluate (tw); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5217 |
27516
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5218 std::string msg = es.last_warning_message (); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5219 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5220 if (msg.empty ()) |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5221 { |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5222 tree_constant *tc_retval |
27764
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5223 = new tree_constant (tmp, close_delim->line (), |
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5224 close_delim->column ()); |
27516
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5225 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5226 std::ostringstream buf; |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5227 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5228 tree_print_code tpc (buf); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5229 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5230 array_list->accept (tpc); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5231 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5232 tc_retval->stash_original_text (buf.str ()); |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5233 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5234 delete array_list; |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5235 |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5236 retval = tc_retval; |
c3e24c82157f
skip constant folding if expression evaluation generates warning
John W. Eaton <jwe@octave.org>
parents:
27511
diff
changeset
|
5237 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5238 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
5239 catch (const execution_exception&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5240 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
5241 interp.recover_from_exception (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5242 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5243 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5244 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5245 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5246 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5247 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5248 // Finish building a matrix list. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5249 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5250 tree_expression * |
27764
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5251 base_parser::finish_matrix (tree_matrix *m, token *open_delim, |
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5252 token *close_delim) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5253 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5254 return (m |
27764
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5255 ? finish_array_list (m, open_delim, close_delim) |
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5256 : new tree_constant (octave_null_matrix::instance, |
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5257 close_delim->line (), close_delim->column ())); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5258 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5259 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5260 tree_matrix * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5261 base_parser::make_matrix (tree_argument_list *row) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5262 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5263 return row ? new tree_matrix (row) : nullptr; |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5264 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5265 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5266 tree_matrix * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5267 base_parser::append_matrix_row (tree_matrix *matrix, tree_argument_list *row) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5268 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5269 if (! matrix) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5270 return make_matrix (row); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5271 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5272 return row ? list_append (matrix, row) : matrix; |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5273 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5274 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5275 // Finish building a cell list. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5276 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5277 tree_expression * |
27764
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5278 base_parser::finish_cell (tree_cell *c, token *open_delim, |
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5279 token *close_delim) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5280 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5281 return (c |
27764
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5282 ? finish_array_list (c, open_delim, close_delim) |
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5283 : new tree_constant (octave_value (Cell ()), |
f64e399b6dda
report missing semicolon location for array expressions (bug #57159)
John W. Eaton <jwe@octave.org>
parents:
27762
diff
changeset
|
5284 close_delim->line (), close_delim->column ())); |
9474
25ed2d6aacf6
Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents:
9471
diff
changeset
|
5285 } |
1623 | 5286 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5287 tree_cell * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5288 base_parser::make_cell (tree_argument_list *row) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5289 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5290 return row ? new tree_cell (row) : nullptr; |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5291 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5292 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5293 tree_cell * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5294 base_parser::append_cell_row (tree_cell *cell, tree_argument_list *row) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5295 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5296 if (! cell) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5297 return make_cell (row); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5298 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5299 return row ? list_append (cell, row) : cell; |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5300 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5301 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5302 tree_identifier * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5303 base_parser::make_identifier (token *ident) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5304 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5305 // Find the token in the symbol table. |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5306 symbol_scope scope = m_lexer.m_symtab_context.curr_scope (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5307 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5308 std::string nm = ident->text (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5309 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5310 symbol_record sr = (scope ? scope.insert (nm) : symbol_record (nm)); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5311 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5312 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5313 int l = ident->line (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5314 int c = ident->column (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5315 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5316 return new tree_identifier (sr, l, c); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5317 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5318 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5319 tree_superclass_ref * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5320 base_parser::make_superclass_ref (token *superclassref) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5321 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5322 std::string meth = superclassref->superclass_method_name (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5323 std::string cls = superclassref->superclass_class_name (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5324 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5325 int l = superclassref->line (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5326 int c = superclassref->column (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5327 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5328 return new tree_superclass_ref (meth, cls, l, c); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5329 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5330 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5331 tree_metaclass_query * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5332 base_parser::make_metaclass_query (token *metaquery) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5333 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5334 std::string cls = metaquery->text (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5335 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5336 int l = metaquery->line (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5337 int c = metaquery->column (); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5338 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5339 return new tree_metaclass_query (cls, l, c); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5340 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5341 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5342 tree_statement_list * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5343 base_parser::set_stmt_print_flag (tree_statement_list *list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5344 char sep, bool warn_missing_semi) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5345 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5346 tree_statement *tmp = list->back (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5347 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5348 switch (sep) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5349 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5350 case ';': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5351 tmp->set_print_flag (false); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5352 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5353 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5354 case 0: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5355 case ',': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5356 case '\n': |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5357 tmp->set_print_flag (true); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5358 if (warn_missing_semi) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5359 maybe_warn_missing_semi (list); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5360 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5361 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5362 default: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5363 warning ("unrecognized separator type!"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5364 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5365 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5366 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5367 // Even if a statement is null, we add it to the list then remove it |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5368 // here so that the print flag is applied to the correct statement. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5369 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5370 if (tmp->is_null_statement ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5371 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5372 list->pop_back (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5373 delete tmp; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5374 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5375 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5376 return list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5377 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5378 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5379 // Finish building a statement. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5380 template <typename T> |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5381 tree_statement * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5382 base_parser::make_statement (T *arg) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5383 { |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
5384 comment_list *comment = m_lexer.get_comment (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5385 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5386 return new tree_statement (arg, comment); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5387 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5388 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5389 tree_statement_list * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5390 base_parser::make_statement_list (tree_statement *stmt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5391 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5392 return new tree_statement_list (stmt); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5393 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5394 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5395 tree_statement_list * |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5396 base_parser::append_statement_list (tree_statement_list *list, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5397 char sep, tree_statement *stmt, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5398 bool warn_missing_semi) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5399 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5400 set_stmt_print_flag (list, sep, warn_missing_semi); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5401 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5402 return list_append (list, stmt); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5403 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5404 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5405 tree_argument_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5406 base_parser::make_argument_list (tree_expression *expr) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5407 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5408 return new tree_argument_list (expr); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5409 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5410 |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5411 tree_argument_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5412 base_parser::append_argument_list (tree_argument_list *list, |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5413 tree_expression *expr) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5414 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5415 return list_append (list, expr); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5416 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5417 |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5418 tree_parameter_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5419 base_parser::make_parameter_list (tree_parameter_list::in_or_out io) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5420 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5421 return new tree_parameter_list (io); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5422 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5423 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5424 tree_parameter_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5425 base_parser::make_parameter_list (tree_parameter_list::in_or_out io, |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5426 tree_decl_elt *t) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5427 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5428 return new tree_parameter_list (io, t); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5429 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5430 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5431 tree_parameter_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5432 base_parser::make_parameter_list (tree_parameter_list::in_or_out io, |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5433 tree_identifier *id) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5434 { |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5435 return new tree_parameter_list (io, id); |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5436 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5437 |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5438 tree_parameter_list * |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5439 base_parser::append_parameter_list (tree_parameter_list *list, |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5440 tree_decl_elt *t) |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5441 { |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5442 return list_append (list, t); |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5443 } |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5444 |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5445 tree_parameter_list * |
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5446 base_parser::append_parameter_list (tree_parameter_list *list, |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5447 tree_identifier *id) |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5448 { |
30144
3c2dee80b542
attempt more uniform handling of list concatenation in the parser
John W. Eaton <jwe@octave.org>
parents:
30140
diff
changeset
|
5449 return list_append (list, new tree_decl_elt (id)); |
30140
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5450 } |
a001811a68e6
use parser functions to build parse tree objects in grammar rule actions
John W. Eaton <jwe@octave.org>
parents:
30130
diff
changeset
|
5451 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5452 void |
26662
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
5453 base_parser::disallow_command_syntax (void) |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
5454 { |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
5455 m_lexer.m_allow_command_syntax = false; |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
5456 } |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
5457 |
27049
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5458 // FIXME: this function partially duplicates do_dbtype in debug.cc. |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5459 static std::string |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5460 get_file_line (const std::string& name, int line) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5461 { |
27049
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5462 // NAME should be an absolute file name and the file should exist. |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5463 |
29006
139df373c107
Use wide character overload to open file streams on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
28804
diff
changeset
|
5464 std::ifstream fs = sys::ifstream (name.c_str (), std::ios::in); |
27049
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5465 |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5466 std::string text; |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5467 |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5468 if (fs) |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5469 { |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5470 int i = 1; |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5471 |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5472 do |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5473 { |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5474 if (! std::getline (fs, text)) |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5475 { |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5476 text = ""; |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5477 break; |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5478 } |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5479 } |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5480 while (i++ < line); |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5481 } |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5482 |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5483 return text; |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5484 } |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5485 |
26662
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
5486 void |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5487 base_parser::bison_error (const std::string& str) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5488 { |
27778
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5489 bison_error (str, m_lexer.m_filepos); |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5490 } |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5491 |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5492 void |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5493 base_parser::bison_error (const std::string& str, const filepos& pos) |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5494 { |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5495 bison_error (str, pos.line (), pos.column ()); |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5496 } |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5497 |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5498 void |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5499 base_parser::bison_error (const std::string& str, int err_line, int err_col) |
2f8559459314
store beginning and ending location info for tokens recognized by lexer
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
5500 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5501 std::ostringstream output_buf; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5502 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
5503 if (m_lexer.m_reading_fcn_file || m_lexer.m_reading_script_file |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
5504 || m_lexer.m_reading_classdef_file) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5505 output_buf << "parse error near line " << err_line |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
5506 << " of file " << m_lexer.m_fcn_file_full_name; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5507 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5508 output_buf << "parse error:"; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5509 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5510 if (str != "parse error") |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5511 output_buf << "\n\n " << str; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5512 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5513 output_buf << "\n\n"; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5514 |
27049
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5515 std::string curr_line; |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5516 |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5517 if (m_lexer.m_reading_fcn_file || m_lexer.m_reading_script_file |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5518 || m_lexer.m_reading_classdef_file) |
27077
4e69b99978b0
display correct source line for parse errors in scripts (bug #56266)
John W. Eaton <jwe@octave.org>
parents:
27050
diff
changeset
|
5519 curr_line = get_file_line (m_lexer.m_fcn_file_full_name, err_line); |
28145
9e983eb1749d
display code and error location when input is from terminal (bug #57536)
John W. Eaton <jwe@octave.org>
parents:
28026
diff
changeset
|
5520 else |
9e983eb1749d
display code and error location when input is from terminal (bug #57536)
John W. Eaton <jwe@octave.org>
parents:
28026
diff
changeset
|
5521 curr_line = m_lexer.m_current_input_line; |
9e983eb1749d
display code and error location when input is from terminal (bug #57536)
John W. Eaton <jwe@octave.org>
parents:
28026
diff
changeset
|
5522 |
9e983eb1749d
display code and error location when input is from terminal (bug #57536)
John W. Eaton <jwe@octave.org>
parents:
28026
diff
changeset
|
5523 // Adjust the error column for display because it is 1-based in the |
28149
026bff6a54d7
improve position tracking in the lexer (bug #57924)
John W. Eaton <jwe@octave.org>
parents:
28147
diff
changeset
|
5524 // lexer for easier reporting. |
026bff6a54d7
improve position tracking in the lexer (bug #57924)
John W. Eaton <jwe@octave.org>
parents:
28147
diff
changeset
|
5525 err_col--; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5526 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5527 if (! curr_line.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5528 { |
27049
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5529 // FIXME: we could do better if we just cached lines from the |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5530 // input file in a list. See also functions for managing input |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5531 // buffers in lex.ll. |
eb522480d44c
improve error reporting for parse errors when reading from files
John W. Eaton <jwe@octave.org>
parents:
27020
diff
changeset
|
5532 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
5533 std::size_t len = curr_line.length (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5534 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5535 if (curr_line[len-1] == '\n') |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5536 curr_line.resize (len-1); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5537 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5538 // Print the line, maybe with a pointer near the error token. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5539 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5540 output_buf << ">>> " << curr_line << "\n"; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5541 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5542 if (err_col == 0) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5543 err_col = len; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5544 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5545 for (int i = 0; i < err_col + 3; i++) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5546 output_buf << " "; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5547 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5548 output_buf << "^"; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5549 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5550 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5551 output_buf << "\n"; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5552 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
5553 m_parse_error_msg = output_buf.str (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5554 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5555 |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5556 void |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5557 base_parser::bison_error (const parse_exception& pe) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5558 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5559 bison_error (pe.message (), pe.line (), pe.column ()); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5560 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5561 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5562 void |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5563 base_parser::bison_error (const std::list<parse_exception>& pe_list) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5564 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5565 // For now, we just report the first error found. Reporting all |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5566 // errors will require a bit more refactoring. |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5567 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5568 parse_exception pe = pe_list.front (); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5569 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5570 bison_error (pe.message (), pe.line (), pe.column ()); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5571 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5572 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5573 int |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5574 parser::run (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5575 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5576 int status = -1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5577 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
5578 yypstate *pstate = static_cast<yypstate *> (m_parser_state); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5579 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5580 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5581 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5582 status = octave_pull_parse (pstate, *this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5583 } |
27481
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
5584 catch (const execution_exception&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5585 { |
27481
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
5586 // FIXME: In previous versions, we emitted a parse error here |
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
5587 // but that is not always correct because the error could have |
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
5588 // happened inside a GUI callback functions executing in the |
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
5589 // readline event_hook loop. Maybe we need a separate exception |
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
5590 // class for parse errors? |
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
5591 |
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
5592 throw; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5593 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
5594 catch (const exit_exception&) |
23049
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
5595 { |
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
5596 throw; |
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
5597 } |
27481
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27474
diff
changeset
|
5598 catch (const interrupt_exception&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5599 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5600 throw; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5601 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5602 catch (...) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5603 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
5604 std::string file = m_lexer.m_fcn_file_full_name; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5605 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5606 if (file.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5607 error ("unexpected exception while parsing input"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5608 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5609 error ("unexpected exception while parsing %s", file.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5610 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5611 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5612 if (status != 0) |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
5613 parse_error ("%s", m_parse_error_msg.c_str ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5614 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5615 return status; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5616 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5617 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5618 // Parse input from INPUT. Pass TRUE for EOF if the end of INPUT should |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5619 // finish the parse. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5620 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5621 int |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5622 push_parser::run (const std::string& input, bool eof) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5623 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5624 int status = -1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5625 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
5626 dynamic_cast<push_lexer&> (m_lexer).append_input (input, eof); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5627 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5628 do |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5629 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5630 YYSTYPE lval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5631 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
5632 int token = octave_lex (&lval, m_lexer.m_scanner); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5633 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5634 if (token < 0) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5635 { |
28147
648202bebcb0
improve treatment of comments at interactive command line (bug #57924)
John W. Eaton <jwe@octave.org>
parents:
28145
diff
changeset
|
5636 // TOKEN == -2 means that the lexer recognized a comment |
648202bebcb0
improve treatment of comments at interactive command line (bug #57924)
John W. Eaton <jwe@octave.org>
parents:
28145
diff
changeset
|
5637 // and we should be at the end of the buffer but not the |
648202bebcb0
improve treatment of comments at interactive command line (bug #57924)
John W. Eaton <jwe@octave.org>
parents:
28145
diff
changeset
|
5638 // end of the file so we should return 0 to indicate |
648202bebcb0
improve treatment of comments at interactive command line (bug #57924)
John W. Eaton <jwe@octave.org>
parents:
28145
diff
changeset
|
5639 // "complete input" instead of -1 to request more input. |
648202bebcb0
improve treatment of comments at interactive command line (bug #57924)
John W. Eaton <jwe@octave.org>
parents:
28145
diff
changeset
|
5640 |
648202bebcb0
improve treatment of comments at interactive command line (bug #57924)
John W. Eaton <jwe@octave.org>
parents:
28145
diff
changeset
|
5641 status = (token == -2 ? 0 : -1); |
27511
257105b5193a
fix push parser to return status indicating more input is needed
John W. Eaton <jwe@octave.org>
parents:
27510
diff
changeset
|
5642 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
5643 if (! eof && m_lexer.at_end_of_buffer ()) |
27511
257105b5193a
fix push parser to return status indicating more input is needed
John W. Eaton <jwe@octave.org>
parents:
27510
diff
changeset
|
5644 return status; |
257105b5193a
fix push parser to return status indicating more input is needed
John W. Eaton <jwe@octave.org>
parents:
27510
diff
changeset
|
5645 |
257105b5193a
fix push parser to return status indicating more input is needed
John W. Eaton <jwe@octave.org>
parents:
27510
diff
changeset
|
5646 break; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5647 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5648 |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
5649 yypstate *pstate = static_cast<yypstate *> (m_parser_state); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5650 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5651 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5652 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5653 status = octave_push_parse (pstate, token, &lval, *this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5654 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
5655 catch (execution_exception& e) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5656 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
5657 std::string file = m_lexer.m_fcn_file_full_name; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5658 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5659 if (file.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5660 error (e, "parse error"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5661 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5662 error (e, "parse error in %s", file.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5663 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
5664 catch (const exit_exception&) |
23049
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
5665 { |
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
5666 throw; |
7351f2c93389
rethrow octave::exit_exception (bug #49304)
Olaf Till <i7tiol@t-online.de>
parents:
22879
diff
changeset
|
5667 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
5668 catch (interrupt_exception &) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5669 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5670 throw; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5671 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5672 catch (...) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5673 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
5674 std::string file = m_lexer.m_fcn_file_full_name; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5675 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5676 if (file.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5677 error ("unexpected exception while parsing input"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5678 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5679 error ("unexpected exception while parsing %s", file.c_str ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5680 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5681 } |
28407
808e3964987b
accept multi-line interactive input (bug #58370)
John W. Eaton <jwe@octave.org>
parents:
28266
diff
changeset
|
5682 while (status == YYPUSH_MORE || ! m_lexer.at_end_of_buffer ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5683 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5684 if (status != 0) |
23694
4a62da62af09
use m_ prefix for member variables in parser
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
5685 parse_error ("%s", m_parse_error_msg.c_str ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5686 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5687 return status; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22094
diff
changeset
|
5688 } |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5689 |
28266
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5690 int |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5691 push_parser::run (void) |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5692 { |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5693 if (! m_reader) |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5694 error ("push_parser::run requires valid input_reader"); |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5695 |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5696 int exit_status = 0; |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5697 |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5698 input_system& input_sys = m_interpreter.get_input_system (); |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5699 |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5700 std::string prompt |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5701 = command_editor::decode_prompt_string (input_sys.PS1 ()); |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5702 |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5703 do |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5704 { |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5705 // Reset status each time through the read loop so that |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5706 // it won't be set to -1 and cause us to exit the outer |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5707 // loop early if there is an exception while reading |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5708 // input or parsing. |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5709 |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5710 exit_status = 0; |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5711 |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5712 bool eof = false; |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5713 std::string input_line = m_reader->get_input (prompt, eof); |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5714 |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5715 if (eof) |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5716 { |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5717 exit_status = EOF; |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5718 break; |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5719 } |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5720 |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5721 exit_status = run (input_line, false); |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5722 |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5723 prompt = command_editor::decode_prompt_string (input_sys.PS2 ()); |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5724 } |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5725 while (exit_status < 0); |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5726 |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5727 return exit_status; |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5728 } |
ce7a5b60e102
restore pull parser interface when input is not interactive (bug #58198)
John W. Eaton <jwe@octave.org>
parents:
28257
diff
changeset
|
5729 |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5730 octave_value |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5731 parse_fcn_file (interpreter& interp, const std::string& full_file, |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5732 const std::string& file, const std::string& dir_name, |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5733 const std::string& dispatch_type, |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5734 const std::string& package_name, bool require_file, |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5735 bool force_script, bool autoload, bool relative_lookup) |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5736 { |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5737 octave_value retval; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5738 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5739 FILE *ffile = nullptr; |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5740 |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5741 if (! full_file.empty ()) |
28368
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5742 { |
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5743 // Check that m-file is not overly large which can segfault interpreter. |
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5744 const int max_file_size = 512 * 1024 * 1024; // 512 MB |
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5745 sys::file_stat fs (full_file); |
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5746 |
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5747 if (fs && fs.size () > max_file_size) |
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5748 { |
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5749 error ("file '%s' is too large, > 512 MB", full_file.c_str ()); |
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5750 |
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5751 return octave_value (); |
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5752 } |
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5753 |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5754 ffile = sys::fopen (full_file, "rb"); |
28368
6870068fb34e
Emit an error if m-file size is >512 MB to prevent segfault in interpreter (bug #58345).
Rik <rik@octave.org>
parents:
28267
diff
changeset
|
5755 } |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5756 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5757 if (! ffile) |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5758 { |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5759 if (require_file) |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5760 error ("no such file, '%s'", full_file.c_str ()); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5761 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5762 return octave_value (); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5763 } |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5764 |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28806
diff
changeset
|
5765 unwind_action act ([=] (void) { ::fclose (ffile); }); |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5766 |
28953
dff830c84726
Add function "dir_encoding" to set a file encoding per directory (bug #49685).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28857
diff
changeset
|
5767 // get the encoding for this folder |
29950
6549fa7558ba
eliminate some unnecessary octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
29864
diff
changeset
|
5768 input_system& input_sys = interp.get_input_system (); |
28953
dff830c84726
Add function "dir_encoding" to set a file encoding per directory (bug #49685).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28857
diff
changeset
|
5769 parser parser (ffile, interp, input_sys.dir_encoding (dir_name)); |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5770 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5771 parser.m_curr_class_name = dispatch_type; |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5772 parser.m_curr_package_name = package_name; |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5773 parser.m_autoloading = autoload; |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5774 parser.m_fcn_file_from_relative_lookup = relative_lookup; |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5775 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5776 parser.m_lexer.m_force_script = force_script; |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5777 parser.m_lexer.prep_for_file (); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5778 parser.m_lexer.m_parsing_class_method = ! dispatch_type.empty (); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5779 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5780 parser.m_lexer.m_fcn_file_name = file; |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5781 parser.m_lexer.m_fcn_file_full_name = full_file; |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5782 parser.m_lexer.m_dir_name = dir_name; |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5783 parser.m_lexer.m_package_name = package_name; |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5784 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5785 int err = parser.run (); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5786 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5787 if (err) |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5788 error ("parse error while reading file %s", full_file.c_str ()); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5789 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5790 octave_value ov_fcn = parser.m_primary_fcn; |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5791 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5792 if (parser.m_lexer.m_reading_classdef_file |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5793 && parser.classdef_object ()) |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5794 { |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5795 // Convert parse tree for classdef object to |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5796 // meta.class info (and stash it in the symbol |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5797 // table?). Return pointer to constructor? |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5798 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5799 if (ov_fcn.is_defined ()) |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5800 panic_impossible (); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5801 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5802 bool is_at_folder = ! dispatch_type.empty (); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5803 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5804 std::shared_ptr<tree_classdef> cdef_obj |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5805 = parser.classdef_object(); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5806 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5807 return cdef_obj->make_meta_class (interp, is_at_folder); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5808 } |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5809 else if (ov_fcn.is_defined ()) |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5810 { |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5811 octave_function *fcn = ov_fcn.function_value (); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5812 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5813 fcn->maybe_relocate_end (); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5814 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5815 if (parser.m_parsing_subfunctions) |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5816 { |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5817 if (! parser.m_endfunction_found) |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5818 parser.m_subfunction_names.reverse (); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5819 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5820 fcn->stash_subfunction_names (parser.m_subfunction_names); |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5821 } |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5822 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5823 return ov_fcn; |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5824 } |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5825 |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5826 return octave_value (); |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5827 } |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5828 |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5829 bool |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5830 base_parser::finish_input (tree_statement_list *lst, bool at_eof) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5831 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5832 m_lexer.m_end_of_input = at_eof; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5833 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5834 if (lst) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5835 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5836 parse_tree_validator validator; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5837 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5838 lst->accept (validator); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5839 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5840 if (! validator.ok ()) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5841 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5842 delete lst; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5843 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5844 bison_error (validator.error_list ()); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5845 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5846 return false; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5847 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5848 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5849 |
29950
6549fa7558ba
eliminate some unnecessary octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
29864
diff
changeset
|
5850 std::shared_ptr<tree_statement_list> tmp_lst (lst); |
29864
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5851 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5852 statement_list (tmp_lst); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5853 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5854 return true; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5855 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5856 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5857 // Check script or function for semantic errors. |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5858 bool |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5859 base_parser::validate_primary_fcn (void) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5860 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5861 octave_user_code *code = m_primary_fcn.user_code_value (); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5862 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5863 if (code) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5864 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5865 parse_tree_validator validator; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5866 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5867 code->accept (validator); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5868 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5869 if (! validator.ok ()) |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5870 { |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5871 bison_error (validator.error_list ()); |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5872 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5873 return false; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5874 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5875 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5876 |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5877 return true; |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5878 } |
e2e493712818
improve previous change for command syntax parsing (bug #60882)
John W. Eaton <jwe@octave.org>
parents:
29857
diff
changeset
|
5879 |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5880 // Maybe print a warning if an assignment expression is used as the |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5881 // test in a logical expression. |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5882 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5883 void |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5884 base_parser::maybe_warn_assign_as_truth_value (tree_expression *expr) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5885 { |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5886 if (expr->is_assignment_expression () |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5887 && expr->paren_count () < 2) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5888 { |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5889 if (m_lexer.m_fcn_file_full_name.empty ()) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5890 warning_with_id |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5891 ("Octave:assign-as-truth-value", |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5892 "suggest parenthesis around assignment used as truth value"); |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5893 else |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5894 warning_with_id |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5895 ("Octave:assign-as-truth-value", |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5896 "suggest parenthesis around assignment used as truth value near line %d, column %d in file '%s'", |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5897 expr->line (), expr->column (), m_lexer.m_fcn_file_full_name.c_str ()); |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5898 } |
27510
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5899 } |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5900 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5901 // Maybe print a warning about switch labels that aren't constants. |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5902 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5903 void |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5904 base_parser::maybe_warn_variable_switch_label (tree_expression *expr) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5905 { |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5906 if (! expr->is_constant ()) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5907 { |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5908 if (m_lexer.m_fcn_file_full_name.empty ()) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5909 warning_with_id ("Octave:variable-switch-label", |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5910 "variable switch label"); |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5911 else |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5912 warning_with_id |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5913 ("Octave:variable-switch-label", |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5914 "variable switch label near line %d, column %d in file '%s'", |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5915 expr->line (), expr->column (), m_lexer.m_fcn_file_full_name.c_str ()); |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5916 } |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5917 } |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5918 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5919 void |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5920 base_parser::maybe_warn_missing_semi (tree_statement_list *t) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5921 { |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5922 if (m_curr_fcn_depth >= 0) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5923 { |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5924 tree_statement *tmp = t->back (); |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5925 |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5926 if (tmp->is_expression ()) |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5927 warning_with_id |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5928 ("Octave:missing-semicolon", |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5929 "missing semicolon near line %d, column %d in file '%s'", |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5930 tmp->line (), tmp->column (), m_lexer.m_fcn_file_full_name.c_str ()); |
5438a82a18fb
declare base_parser class data protected
John W. Eaton <jwe@octave.org>
parents:
27509
diff
changeset
|
5931 } |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5932 } |
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
5933 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5934 std::string |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5935 get_help_from_file (const std::string& nm, bool& symbol_found, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5936 std::string& full_file) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5937 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5938 std::string retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5939 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5940 full_file = fcn_file_in_path (nm); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5941 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5942 std::string file = full_file; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5943 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
5944 std::size_t file_len = file.length (); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5945 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5946 if ((file_len > 4 && file.substr (file_len-4) == ".oct") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5947 || (file_len > 4 && file.substr (file_len-4) == ".mex") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5948 || (file_len > 2 && file.substr (file_len-2) == ".m")) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5949 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
5950 file = sys::env::base_pathname (file); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5951 file = file.substr (0, file.find_last_of ('.')); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5952 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
5953 std::size_t pos = file.find_last_of (sys::file_ops::dir_sep_str ()); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5954 if (pos != std::string::npos) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5955 file = file.substr (pos+1); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5956 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5957 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5958 if (! file.empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5959 { |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
5960 interpreter& interp = __get_interpreter__ ("get_help_from_file"); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
5961 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5962 symbol_found = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5963 |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
5964 octave_value ov_fcn |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5965 = parse_fcn_file (interp, full_file, file, "", "", "", true, |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
5966 false, false, false); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5967 |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
5968 if (ov_fcn.is_defined ()) |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5969 { |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
5970 octave_function *fcn = ov_fcn.function_value (); |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
5971 |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
5972 if (fcn) |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
5973 retval = fcn->doc_string (); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5974 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5975 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5976 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5977 return retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5978 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5979 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5980 std::string |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5981 get_help_from_file (const std::string& nm, bool& symbol_found) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5982 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5983 std::string file; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5984 return get_help_from_file (nm, symbol_found, file); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5985 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5986 |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
5987 octave_value |
23667
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23655
diff
changeset
|
5988 load_fcn_from_file (const std::string& file_name, |
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23655
diff
changeset
|
5989 const std::string& dir_name, |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5990 const std::string& dispatch_type, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5991 const std::string& package_name, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5992 const std::string& fcn_name, bool autoload) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5993 { |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
5994 octave_value retval; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5995 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
5996 unwind_protect frame; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5997 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5998 std::string nm = file_name; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
5999 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
6000 std::size_t nm_len = nm.length (); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6001 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6002 std::string file; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6003 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6004 bool relative_lookup = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6005 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6006 file = nm; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6007 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6008 if ((nm_len > 4 && nm.substr (nm_len-4) == ".oct") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6009 || (nm_len > 4 && nm.substr (nm_len-4) == ".mex") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6010 || (nm_len > 2 && nm.substr (nm_len-2) == ".m")) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6011 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
6012 nm = sys::env::base_pathname (file); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6013 nm = nm.substr (0, nm.find_last_of ('.')); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6014 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
6015 std::size_t pos = nm.find_last_of (sys::file_ops::dir_sep_str ()); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6016 if (pos != std::string::npos) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6017 nm = nm.substr (pos+1); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6018 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6019 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
6020 relative_lookup = ! sys::env::absolute_pathname (file); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
6021 |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23694
diff
changeset
|
6022 file = sys::env::make_absolute (file); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6023 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6024 int len = file.length (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6025 |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6026 interpreter& interp = __get_interpreter__ ("load_fcn_from_file"); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6027 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6028 dynamic_loader& dyn_loader = interp.get_dynamic_loader (); |
23627
0a6e87804cab
don't use singleton pattern for dynamic_loader class
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
6029 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6030 if (len > 4 && file.substr (len-4, len-1) == ".oct") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6031 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6032 if (autoload && ! fcn_name.empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6033 nm = fcn_name; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6034 |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6035 octave_function *tmpfcn |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6036 = dyn_loader.load_oct (nm, file, relative_lookup); |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6037 |
25206
cbe53b5ea5ce
check success of loading oct-file (bug #52977)
Olaf Till <i7tiol@t-online.de>
parents:
25193
diff
changeset
|
6038 if (tmpfcn) |
cbe53b5ea5ce
check success of loading oct-file (bug #52977)
Olaf Till <i7tiol@t-online.de>
parents:
25193
diff
changeset
|
6039 { |
cbe53b5ea5ce
check success of loading oct-file (bug #52977)
Olaf Till <i7tiol@t-online.de>
parents:
25193
diff
changeset
|
6040 tmpfcn->stash_package_name (package_name); |
cbe53b5ea5ce
check success of loading oct-file (bug #52977)
Olaf Till <i7tiol@t-online.de>
parents:
25193
diff
changeset
|
6041 retval = octave_value (tmpfcn); |
cbe53b5ea5ce
check success of loading oct-file (bug #52977)
Olaf Till <i7tiol@t-online.de>
parents:
25193
diff
changeset
|
6042 } |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6043 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6044 else if (len > 4 && file.substr (len-4, len-1) == ".mex") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6045 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6046 // Temporarily load m-file version of mex-file, if it exists, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6047 // to get the help-string to use. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6048 |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6049 std::string doc_string; |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6050 |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6051 octave_value ov_fcn |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
6052 = parse_fcn_file (interp, file.substr (0, len - 2), nm, dir_name, |
23667
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23655
diff
changeset
|
6053 dispatch_type, package_name, false, |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
6054 autoload, autoload, relative_lookup); |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6055 |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6056 if (ov_fcn.is_defined ()) |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6057 { |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6058 octave_function *tmpfcn = ov_fcn.function_value (); |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6059 |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6060 if (tmpfcn) |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6061 doc_string = tmpfcn->doc_string (); |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6062 } |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6063 |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6064 octave_function *tmpfcn |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6065 = dyn_loader.load_mex (nm, file, relative_lookup); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6066 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6067 if (tmpfcn) |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6068 { |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6069 tmpfcn->document (doc_string); |
25193
6f1fde568e46
make .oct and .mex files in +package dirs work again (bug #51960)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
6070 tmpfcn->stash_package_name (package_name); |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6071 |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6072 retval = octave_value (tmpfcn); |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6073 } |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6074 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6075 else if (len > 2) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6076 { |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
6077 retval = parse_fcn_file (interp, file, nm, dir_name, |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
6078 dispatch_type, package_name, true, |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
6079 autoload, autoload, relative_lookup); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6080 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6081 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6082 return retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6083 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
6084 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
6085 DEFMETHOD (autoload, interp, args, , |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
6086 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6087 @deftypefn {} {@var{autoload_map} =} autoload () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6088 @deftypefnx {} {} autoload (@var{function}, @var{file}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6089 @deftypefnx {} {} autoload (@dots{}, "remove") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6090 Define @var{function} to autoload from @var{file}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6091 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6092 The second argument, @var{file}, should be an absolute filename or a file |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6093 name in the same directory as the function or script from which the autoload |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6094 command was run. @var{file} @emph{should not} depend on the Octave load |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6095 path. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6096 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6097 Normally, calls to @code{autoload} appear in PKG_ADD script files that are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6098 evaluated when a directory is added to Octave's load path. To avoid having |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6099 to hardcode directory names in @var{file}, if @var{file} is in the same |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6100 directory as the PKG_ADD script then |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6101 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6102 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6103 autoload ("foo", "bar.oct"); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6104 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6105 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6106 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6107 will load the function @code{foo} from the file @code{bar.oct}. The above |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6108 usage when @code{bar.oct} is not in the same directory, or usages such as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6109 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6110 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6111 autoload ("foo", file_in_loadpath ("bar.oct")) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6112 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6113 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6114 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6115 are strongly discouraged, as their behavior may be unpredictable. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6116 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6117 With no arguments, return a structure containing the current autoload map. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6118 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6119 If a third argument @qcode{"remove"} is given, the function is cleared and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6120 not loaded anymore during the current Octave session. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6121 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6122 @seealso{PKG_ADD} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6123 @end deftypefn */) |
5484 | 6124 { |
6125 int nargin = args.length (); | |
6126 | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6127 if (nargin == 1 || nargin > 3) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6128 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6129 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
6130 tree_evaluator& tw = interp.get_evaluator (); |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
6131 |
5626 | 6132 if (nargin == 0) |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
6133 return octave_value (tw.get_autoload_map ()); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6134 else |
5484 | 6135 { |
6136 string_vector argv = args.make_argv ("autoload"); | |
6137 | |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
6138 if (nargin == 2) |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
6139 tw.add_autoload (argv[1], argv[2]); |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
6140 else if (nargin == 3) |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
6141 { |
21021
a5b99b09f8fd
maint: Use comparison operators rather than compare() for strings.
Rik <rik@octave.org>
parents:
20957
diff
changeset
|
6142 if (argv[3] != "remove") |
20547
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
6143 error_with_id ("Octave:invalid-input-arg", |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
6144 "autoload: third argument can only be 'remove'"); |
52ce821a52fd
eliminate simple uses of error_state in parser and lexer
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
6145 |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
6146 tw.remove_autoload (argv[1], argv[2]); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
6147 } |
5484 | 6148 } |
6149 | |
27016
9b261300a001
move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents:
27015
diff
changeset
|
6150 return octave_value_list (); |
4486 | 6151 } |
6152 | |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
6153 DEFMETHOD (mfilename, interp, args, , |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
6154 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6155 @deftypefn {} {} mfilename () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6156 @deftypefnx {} {} mfilename ("fullpath") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6157 @deftypefnx {} {} mfilename ("fullpathext") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6158 Return the name of the currently executing file. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6159 |
25294
01ad54f997f5
Allow filenames which begin with a '.' to be returned from mfilename (bug #53707).
Rik <rik@octave.org>
parents:
25206
diff
changeset
|
6160 The base name of the currently executing script or function is returned without |
01ad54f997f5
Allow filenames which begin with a '.' to be returned from mfilename (bug #53707).
Rik <rik@octave.org>
parents:
25206
diff
changeset
|
6161 any extension. If called from outside an m-file, such as the command line, |
01ad54f997f5
Allow filenames which begin with a '.' to be returned from mfilename (bug #53707).
Rik <rik@octave.org>
parents:
25206
diff
changeset
|
6162 return the empty string. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6163 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6164 Given the argument @qcode{"fullpath"}, include the directory part of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6165 filename, but not the extension. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6166 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6167 Given the argument @qcode{"fullpathext"}, include the directory part of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6168 the filename and the extension. |
25294
01ad54f997f5
Allow filenames which begin with a '.' to be returned from mfilename (bug #53707).
Rik <rik@octave.org>
parents:
25206
diff
changeset
|
6169 @seealso{inputname, dbstack} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6170 @end deftypefn */) |
5739 | 6171 { |
6172 int nargin = args.length (); | |
6173 | |
6174 if (nargin > 1) | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6175 print_usage (); |
5739 | 6176 |
27015
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
6177 std::string opt; |
5739 | 6178 |
6179 if (nargin == 1) | |
27015
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
6180 opt = args(0).xstring_value ("mfilename: option argument must be a string"); |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
6181 |
4d9e1a832a55
move core of mfilename function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27014
diff
changeset
|
6182 return octave_value (interp.mfilename (opt)); |
5739 | 6183 } |
6184 | |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6185 // Execute the contents of a script file. For compatibility with |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6186 // Matlab, also execute a function file by calling the function it |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6187 // defines with no arguments and nargout = 0. |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6188 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6189 void |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6190 source_file (const std::string& file_name, const std::string& context, |
27507
2d537a089e5d
eliminate warn_for argument for source_file and parse_fcn_file functions
John W. Eaton <jwe@octave.org>
parents:
27505
diff
changeset
|
6191 bool verbose, bool require_file) |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6192 { |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6193 interpreter& interp = __get_interpreter__ ("source_file"); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6194 |
27507
2d537a089e5d
eliminate warn_for argument for source_file and parse_fcn_file functions
John W. Eaton <jwe@octave.org>
parents:
27505
diff
changeset
|
6195 interp.source_file (file_name, context, verbose, require_file); |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6196 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
6197 |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6198 DEFMETHOD (source, interp, args, , |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6199 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6200 @deftypefn {} {} source (@var{file}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6201 @deftypefnx {} {} source (@var{file}, @var{context}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6202 Parse and execute the contents of @var{file}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6203 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6204 Without specifying @var{context}, this is equivalent to executing commands |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6205 from a script file, but without requiring the file to be named |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6206 @file{@var{file}.m} or to be on the execution path. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6207 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6208 Instead of the current context, the script may be executed in either the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6209 context of the function that called the present function |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6210 (@qcode{"caller"}), or the top-level context (@qcode{"base"}). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6211 @seealso{run} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6212 @end deftypefn */) |
3021 | 6213 { |
6214 int nargin = args.length (); | |
6215 | |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6216 if (nargin < 1 || nargin > 2) |
5823 | 6217 print_usage (); |
3021 | 6218 |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6219 std::string file_name |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6220 = args(0).xstring_value ("source: FILE must be a string"); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6221 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6222 std::string context; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6223 if (nargin == 2) |
21861
a55f1fa2c94a
oct-parse.in.yy: Shorten lines to < 80 characters where possible.
Rik <rik@octave.org>
parents:
21748
diff
changeset
|
6224 context = args(1).xstring_value ("source: CONTEXT must be a string"); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6225 |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6226 interp.source_file (file_name, context); |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6227 |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6228 return octave_value_list (); |
3021 | 6229 } |
6230 | |
24624
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
6231 //! Evaluate an Octave function (built-in or interpreted) and return |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
6232 //! the list of result values. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
6233 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
6234 //! @param name The name of the function to call. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
6235 //! @param args The arguments to the function. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
6236 //! @param nargout The number of output arguments expected. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
6237 //! @return A list of output values. The length of the list is not |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
6238 //! necessarily the same as @c nargout. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
6239 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6240 octave_value_list |
26883
a2aed4b49be3
fix const-ness of feval arguments
John W. Eaton <jwe@octave.org>
parents:
26799
diff
changeset
|
6241 feval (const char *name, const octave_value_list& args, int nargout) |
a2aed4b49be3
fix const-ness of feval arguments
John W. Eaton <jwe@octave.org>
parents:
26799
diff
changeset
|
6242 { |
27020
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6243 interpreter& interp = __get_interpreter__ ("feval"); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6244 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6245 return interp.feval (name, args, nargout); |
26883
a2aed4b49be3
fix const-ness of feval arguments
John W. Eaton <jwe@octave.org>
parents:
26799
diff
changeset
|
6246 } |
a2aed4b49be3
fix const-ness of feval arguments
John W. Eaton <jwe@octave.org>
parents:
26799
diff
changeset
|
6247 |
a2aed4b49be3
fix const-ness of feval arguments
John W. Eaton <jwe@octave.org>
parents:
26799
diff
changeset
|
6248 octave_value_list |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6249 feval (const std::string& name, const octave_value_list& args, int nargout) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6250 { |
27020
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6251 interpreter& interp = __get_interpreter__ ("feval"); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6252 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6253 return interp.feval (name, args, nargout); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6254 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6255 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6256 octave_value_list |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6257 feval (octave_function *fcn, const octave_value_list& args, int nargout) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6258 { |
27020
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6259 interpreter& interp = __get_interpreter__ ("feval"); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6260 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6261 return interp.feval (fcn, args, nargout); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6262 } |
23502
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
6263 |
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
6264 octave_value_list |
26883
a2aed4b49be3
fix const-ness of feval arguments
John W. Eaton <jwe@octave.org>
parents:
26799
diff
changeset
|
6265 feval (const octave_value& val, const octave_value_list& args, int nargout) |
23502
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
6266 { |
27020
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6267 interpreter& interp = __get_interpreter__ ("feval"); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6268 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6269 return interp.feval (val, args, nargout); |
23502
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23479
diff
changeset
|
6270 } |
25442
47a3e4b9b6fe
tmp-parser-namespace-fixes
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
6271 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6272 octave_value_list |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6273 feval (const octave_value_list& args, int nargout) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6274 { |
27020
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6275 interpreter& interp = __get_interpreter__ ("feval"); |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6276 |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6277 return interp.feval (args, nargout); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6278 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
6279 |
27020
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6280 DEFMETHOD (feval, interp, args, nargout, |
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6281 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6282 @deftypefn {} {} feval (@var{name}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6283 Evaluate the function named @var{name}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6284 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6285 Any arguments after the first are passed as inputs to the named function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6286 For example, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6287 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6288 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6289 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6290 feval ("acos", -1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6291 @result{} 3.1416 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6292 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6293 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6294 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6295 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6296 calls the function @code{acos} with the argument @samp{-1}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6297 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6298 The function @code{feval} can also be used with function handles of any sort |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6299 (@pxref{Function Handles}). Historically, @code{feval} was the only way to |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6300 call user-supplied functions in strings, but function handles are now |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6301 preferred due to the cleaner syntax they offer. For example, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6302 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6303 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6304 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6305 @var{f} = @@exp; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6306 feval (@var{f}, 1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6307 @result{} 2.7183 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6308 @var{f} (1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6309 @result{} 2.7183 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6310 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6311 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6312 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6313 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6314 are equivalent ways to call the function referred to by @var{f}. If it |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6315 cannot be predicted beforehand whether @var{f} is a function handle, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6316 function name in a string, or inline function then @code{feval} can be used |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6317 instead. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6318 @end deftypefn */) |
3021 | 6319 { |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20798
diff
changeset
|
6320 if (args.length () == 0) |
5823 | 6321 print_usage (); |
3021 | 6322 |
27020
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6323 return interp.feval (args, nargout); |
3021 | 6324 } |
6325 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
6326 DEFMETHOD (builtin, interp, args, nargout, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
6327 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6328 @deftypefn {} {[@dots{}] =} builtin (@var{f}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6329 Call the base function @var{f} even if @var{f} is overloaded to another |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6330 function for the given type signature. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6331 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6332 This is normally useful when doing object-oriented programming and there is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6333 a requirement to call one of Octave's base functions rather than the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6334 overloaded one of a new class. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6335 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6336 A trivial example which redefines the @code{sin} function to be the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6337 @code{cos} function shows how @code{builtin} works. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6338 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6339 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6340 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6341 sin (0) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6342 @result{} 0 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6343 function y = sin (x), y = cos (x); endfunction |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6344 sin (0) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6345 @result{} 1 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6346 builtin ("sin", 0) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6347 @result{} 0 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6348 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6349 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6350 @end deftypefn */) |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
6351 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
6352 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
|
6353 |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20798
diff
changeset
|
6354 if (args.length () == 0) |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6355 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6356 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6357 const std::string name (args(0).xstring_value ("builtin: function name (F) must be a string")); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6358 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
6359 symbol_table& symtab = interp.get_symbol_table (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
6360 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23577
diff
changeset
|
6361 octave_value fcn = symtab.builtin_find (name); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6362 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6363 if (fcn.is_defined ()) |
27020
30e9204de313
move feval functions to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27019
diff
changeset
|
6364 retval = interp.feval (fcn.function_value (), args.splice (0, 1), nargout); |
11225
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
6365 else |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6366 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
|
6367 |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
6368 return retval; |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
6369 } |
8d8e10058df6
move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents:
11138
diff
changeset
|
6370 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6371 void |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6372 cleanup_statement_list (tree_statement_list **lst) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6373 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6374 if (*lst) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6375 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6376 delete *lst; |
23796
4f12819a634f
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
6377 *lst = nullptr; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6378 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23054
diff
changeset
|
6379 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
6380 |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
6381 DEFMETHOD (eval, interp, args, nargout, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
6382 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6383 @deftypefn {} {} eval (@var{try}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6384 @deftypefnx {} {} eval (@var{try}, @var{catch}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6385 Parse the string @var{try} and evaluate it as if it were an Octave |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6386 program. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6387 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6388 If execution fails, evaluate the optional string @var{catch}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6389 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6390 The string @var{try} is evaluated in the current context, so any results |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6391 remain available after @code{eval} returns. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6392 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6393 The following example creates the variable @var{A} with the approximate |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6394 value of 3.1416 in the current workspace. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6395 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6396 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6397 eval ("A = acos(-1);"); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6398 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6399 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6400 If an error occurs during the evaluation of @var{try} then the @var{catch} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6401 string is evaluated, as the following example shows: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6402 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6403 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6404 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6405 eval ('error ("This is a bad example");', |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6406 'printf ("This error occurred:\n%s\n", lasterr ());'); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6407 @print{} This error occurred: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6408 This is a bad example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6409 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6410 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6411 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6412 Programming Note: if you are only using @code{eval} as an error-capturing |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6413 mechanism, rather than for the execution of arbitrary code strings, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6414 Consider using try/catch blocks or unwind_protect/unwind_protect_cleanup |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6415 blocks instead. These techniques have higher performance and don't |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6416 introduce the security considerations that the evaluation of arbitrary code |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6417 does. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6418 @seealso{evalin, evalc, assignin, feval} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6419 @end deftypefn */) |
3021 | 6420 { |
6421 int nargin = args.length (); | |
6422 | |
27019
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
6423 if (nargin < 1 || nargin > 2) |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6424 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6425 |
27797
5dcdd5bd46e2
maint: remove trailing spaces from code.
Rik <rik@octave.org>
parents:
27778
diff
changeset
|
6426 if (! args(0).is_string () || args(0).rows () > 1 || args(0).ndims () != 2) |
27165
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6427 error ("eval: TRY must be a string"); |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6428 |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6429 std::string try_code = args(0).string_value (); |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6430 |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6431 if (nargin == 1) |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6432 return interp.eval (try_code, nargout); |
3021 | 6433 else |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6434 { |
27165
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6435 if (! args(1).is_string () || args(1).rows () > 1 |
27797
5dcdd5bd46e2
maint: remove trailing spaces from code.
Rik <rik@octave.org>
parents:
27778
diff
changeset
|
6436 || args(1).ndims () != 2) |
27165
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6437 error ("eval: CATCH must be a string"); |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6438 |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6439 std::string catch_code = args(1).string_value (); |
27019
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
6440 |
6cb675912f2b
move core of eval function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27018
diff
changeset
|
6441 return interp.eval (try_code, catch_code, nargout); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6442 } |
3021 | 6443 } |
6444 | |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
6445 /* |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
6446 |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6447 %!shared x |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
6448 %! x = 1; |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6449 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6450 %!assert (eval ("x"), 1) |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6451 %!assert (eval ("x;")) |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
6452 %!assert (eval ("x;"), 1) |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6453 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
6454 %!test |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6455 %! y = eval ("x"); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6456 %! assert (y, 1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6457 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6458 %!test |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6459 %! y = eval ("x;"); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6460 %! assert (y, 1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6461 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6462 %!test |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21416
diff
changeset
|
6463 %! eval ("x = 1;"); |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6464 %! assert (x,1); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6465 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
6466 %!test |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
6467 %! eval ("flipud = 2;"); |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6468 %! assert (flipud, 2); |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6469 |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6470 %!function y = __f () |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
6471 %! eval ("flipud = 2;"); |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
6472 %! y = flipud; |
14084
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6473 %!endfunction |
5aba9fa234cf
Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents:
13970
diff
changeset
|
6474 %!assert (__f(), 2) |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
6475 |
27165
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6476 %!test <*35645> |
14533
e6aa044253eb
Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents:
14512
diff
changeset
|
6477 %! [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
|
6478 %! [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
|
6479 |
27165
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6480 ## Can't assign to a keyword |
21581
6fab85c1538f
maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
6481 %!error eval ("switch = 13;") |
21369
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
6482 |
27165
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6483 %!shared str |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6484 %! str = "disp ('hello');"; |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6485 %! str(:,:,2) = str(:,:,1); |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6486 |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6487 %!error <TRY must be a string> eval (1) |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6488 %!error <TRY must be a string> eval (['a';'b']) |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6489 %!error <TRY must be a string> eval (str) |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6490 |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6491 %!error <CATCH must be a string> eval (str(:,:,1), 1) |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6492 %!error <CATCH must be a string> eval (str(:,:,1), ['a';'b']) |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6493 %!error <CATCH must be a string> eval (str(:,:,1), str) |
58bdc2d98481
Only accept 1xN character vectors as string input to eval (bug #49696).
Rik <rik@octave.org>
parents:
27160
diff
changeset
|
6494 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
6495 */ |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7351
diff
changeset
|
6496 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
6497 DEFMETHOD (assignin, interp, args, , |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
6498 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6499 @deftypefn {} {} assignin (@var{context}, @var{varname}, @var{value}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6500 Assign @var{value} to @var{varname} in context @var{context}, which |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6501 may be either @qcode{"base"} or @qcode{"caller"}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6502 @seealso{evalin} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6503 @end deftypefn */) |
4297 | 6504 { |
20818
cef0448a6ed2
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20798
diff
changeset
|
6505 if (args.length () != 3) |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6506 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6507 |
27014
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26998
diff
changeset
|
6508 std::string context |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26998
diff
changeset
|
6509 = args(0).xstring_value ("assignin: CONTEXT must be a string"); |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26998
diff
changeset
|
6510 |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26998
diff
changeset
|
6511 std::string varname |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26998
diff
changeset
|
6512 = args(1).xstring_value ("assignin: VARNAME must be a string"); |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26998
diff
changeset
|
6513 |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26998
diff
changeset
|
6514 interp.assignin (context, varname, args(2)); |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26998
diff
changeset
|
6515 |
daab1b311a98
move core of assignin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
26998
diff
changeset
|
6516 return octave_value_list (); |
4297 | 6517 } |
6518 | |
21369
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
6519 /* |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
6520 |
21581
6fab85c1538f
maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
6521 %!error assignin ("base", "switch", "13") |
21369
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
6522 |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
6523 */ |
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
6524 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
6525 DEFMETHOD (evalin, interp, args, nargout, |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23533
diff
changeset
|
6526 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6527 @deftypefn {} {} evalin (@var{context}, @var{try}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6528 @deftypefnx {} {} evalin (@var{context}, @var{try}, @var{catch}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6529 Like @code{eval}, except that the expressions are evaluated in the context |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6530 @var{context}, which may be either @qcode{"caller"} or @qcode{"base"}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6531 @seealso{eval, assignin} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6532 @end deftypefn */) |
4245 | 6533 { |
6534 int nargin = args.length (); | |
6535 | |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6536 if (nargin < 2 || nargin > 3) |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6537 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6538 |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6539 std::string context |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6540 = args(0).xstring_value ("evalin: CONTEXT must be a string"); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6541 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6542 std::string try_code |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6543 = args(1).xstring_value ("evalin: TRY must be a string"); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6544 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6545 if (nargin == 3) |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6546 { |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6547 std::string catch_code |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6548 = args(2).xstring_value ("evalin: CATCH must be a string"); |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6549 |
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6550 return interp.evalin (context, try_code, catch_code, nargout); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6551 } |
4245 | 6552 |
27018
a20ead51515d
move core of evalin function to evaluator
John W. Eaton <jwe@octave.org>
parents:
27017
diff
changeset
|
6553 return interp.evalin (context, try_code, nargout); |
22504
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
6554 } |
2aa9e8893ea9
Fix crash in evalc (bug #49057).
Mike Miller <mtmiller@octave.org>
parents:
22327
diff
changeset
|
6555 |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
6556 DEFMETHOD (evalc, interp, args, nargout, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
6557 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6558 @deftypefn {} {@var{s} =} evalc (@var{try}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6559 @deftypefnx {} {@var{s} =} evalc (@var{try}, @var{catch}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6560 Parse and evaluate the string @var{try} as if it were an Octave program, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6561 while capturing the output into the return variable @var{s}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6562 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6563 If execution fails, evaluate the optional string @var{catch}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6564 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6565 This function behaves like @code{eval}, but any output or warning messages |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6566 which would normally be written to the console are captured and returned in |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6567 the string @var{s}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6568 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6569 The @code{diary} is disabled during the execution of this function. When |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6570 @code{system} is used, any output produced by external programs is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6571 @emph{not} captured, unless their output is captured by the @code{system} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6572 function itself. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6573 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6574 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6575 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6576 s = evalc ("t = 42"), t |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6577 @result{} s = t = 42 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6578 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6579 @result{} t = 42 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6580 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6581 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6582 @seealso{eval, diary} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6583 @end deftypefn */) |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6584 { |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6585 int nargin = args.length (); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6586 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6587 if (nargin == 0 || nargin > 2) |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6588 print_usage (); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6589 |
27930
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6590 // Flush pending output and redirect stdout/stderr to capturing |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6591 // buffer. |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6592 |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6593 octave_stdout.flush (); |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6594 std::cerr.flush (); |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6595 |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6596 std::stringbuf buffer; |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6597 |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6598 std::streambuf *old_out_buf = octave_stdout.rdbuf (&buffer); |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6599 std::streambuf *old_err_buf = std::cerr.rdbuf (&buffer); |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6600 |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6601 // Restore previous output buffers no matter how control exits this |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6602 // function. There's no need to flush here. That has already |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6603 // happened for the normal execution path. If an error happens during |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6604 // the eval, then the message is stored in the exception object and we |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6605 // will display it later, after the buffers have been restored. |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6606 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
6607 unwind_action act ([=] (void) |
27930
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6608 { |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6609 octave_stdout.rdbuf (old_out_buf); |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6610 std::cerr.rdbuf (old_err_buf); |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6611 }); |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6612 |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6613 // Call standard eval function. |
27471 | 6614 |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6615 int eval_nargout = std::max (0, nargout - 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6616 |
27930
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6617 octave_value_list retval = Feval (interp, args, eval_nargout); |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6618 |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6619 // Make sure we capture all pending output. |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6620 |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6621 octave_stdout.flush (); |
ea1898178973
simplify handling of temporary output buffer in evalc
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6622 std::cerr.flush (); |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6623 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6624 retval.prepend (buffer.str ()); |
27471 | 6625 |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6626 return retval; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6627 } |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6628 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6629 /* |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6630 |
26716
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6631 %!test |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6632 %! [old_fmt, old_spacing] = format (); |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6633 %! unwind_protect |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6634 %! format short; |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6635 %! str = evalc ("1"); |
27458
2f4e8dce06da
Don't print leading spaces before scalar values in interpeter (bug #56939)
Rik <rik@octave.org>
parents:
27408
diff
changeset
|
6636 %! assert (str, "ans = 1\n"); |
26716
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6637 %! unwind_protect_cleanup |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6638 %! format (old_fmt); |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6639 %! format (old_spacing); |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6640 %! end_unwind_protect |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6641 |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6642 %!assert (evalc ("1;"), "") |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6643 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6644 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6645 %! [s, y] = evalc ("1"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6646 %! assert (s, ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6647 %! assert (y, 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6648 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6649 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6650 %! [s, y] = evalc ("1;"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6651 %! assert (s, ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6652 %! assert (y, 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6653 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6654 %!test |
26716
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6655 %! [old_fmt, old_spacing] = format (); |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6656 %! unwind_protect |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6657 %! format short; |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6658 %! str = evalc ("y = 2"); |
27458
2f4e8dce06da
Don't print leading spaces before scalar values in interpeter (bug #56939)
Rik <rik@octave.org>
parents:
27408
diff
changeset
|
6659 %! assert (str, "y = 2\n"); |
26716
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6660 %! assert (y, 2); |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6661 %! unwind_protect_cleanup |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6662 %! format (old_fmt); |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6663 %! format (old_spacing); |
daa281e03d9a
Harden BIST tests against changes in format().
Rik <rik@octave.org>
parents:
26709
diff
changeset
|
6664 %! end_unwind_protect |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6665 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6666 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6667 %! assert (evalc ("y = 3;"), ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6668 %! assert (y, 3); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6669 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6670 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6671 %! [s, a, b] = evalc ("deal (1, 2)"); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6672 %! assert (s, ""); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6673 %! assert (a, 1); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6674 %! assert (b, 2); |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6675 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6676 %!function [a, b] = __f_evalc () |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6677 %! printf ("foo"); |
27458
2f4e8dce06da
Don't print leading spaces before scalar values in interpeter (bug #56939)
Rik <rik@octave.org>
parents:
27408
diff
changeset
|
6678 %! fprintf (stdout, "bar "); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21416
diff
changeset
|
6679 %! disp (pi); |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6680 %! a = 1; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6681 %! b = 2; |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6682 %!endfunction |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6683 %!test |
26585
d673b506f382
test: use "format short" in tests depending on output format (bug #55539)
Mike Miller <mtmiller@octave.org>
parents:
26423
diff
changeset
|
6684 %! [old_fmt, old_spacing] = format (); |
d673b506f382
test: use "format short" in tests depending on output format (bug #55539)
Mike Miller <mtmiller@octave.org>
parents:
26423
diff
changeset
|
6685 %! unwind_protect |
d673b506f382
test: use "format short" in tests depending on output format (bug #55539)
Mike Miller <mtmiller@octave.org>
parents:
26423
diff
changeset
|
6686 %! format short; |
d673b506f382
test: use "format short" in tests depending on output format (bug #55539)
Mike Miller <mtmiller@octave.org>
parents:
26423
diff
changeset
|
6687 %! [s, a, b] = evalc ("__f_evalc ()"); |
d673b506f382
test: use "format short" in tests depending on output format (bug #55539)
Mike Miller <mtmiller@octave.org>
parents:
26423
diff
changeset
|
6688 %! assert (s, "foobar 3.1416\n"); |
d673b506f382
test: use "format short" in tests depending on output format (bug #55539)
Mike Miller <mtmiller@octave.org>
parents:
26423
diff
changeset
|
6689 %! assert (a, 1); |
d673b506f382
test: use "format short" in tests depending on output format (bug #55539)
Mike Miller <mtmiller@octave.org>
parents:
26423
diff
changeset
|
6690 %! assert (b, 2); |
d673b506f382
test: use "format short" in tests depending on output format (bug #55539)
Mike Miller <mtmiller@octave.org>
parents:
26423
diff
changeset
|
6691 %! unwind_protect_cleanup |
d673b506f382
test: use "format short" in tests depending on output format (bug #55539)
Mike Miller <mtmiller@octave.org>
parents:
26423
diff
changeset
|
6692 %! format (old_fmt); |
d673b506f382
test: use "format short" in tests depending on output format (bug #55539)
Mike Miller <mtmiller@octave.org>
parents:
26423
diff
changeset
|
6693 %! format (old_spacing); |
d673b506f382
test: use "format short" in tests depending on output format (bug #55539)
Mike Miller <mtmiller@octave.org>
parents:
26423
diff
changeset
|
6694 %! end_unwind_protect |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6695 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6696 %!error <foo> (evalc ("error ('foo')")) |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6697 %!error <bar> (evalc ("error ('foo')", "error ('bar')")) |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6698 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6699 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6700 %! warning ("off", "quiet", "local"); |
27471 | 6701 %! str = evalc ("warning ('foo')"); |
6702 %! assert (str(1:13), "warning: foo\n"); | |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6703 |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6704 %!test |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6705 %! warning ("off", "quiet", "local"); |
27471 | 6706 %! str = evalc ("error ('foo')", "warning ('bar')"); |
6707 %! assert (str(1:13), "warning: bar\n"); | |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6708 |
21581
6fab85c1538f
maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
6709 %!error evalc ("switch = 13;") |
21369
105224df2330
also disallow assignment to keywords in assignin (bug #46459)
John W. Eaton <jwe@octave.org>
parents:
21361
diff
changeset
|
6710 |
21075
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6711 */ |
5ed379c8decd
Add new function evalc to core.
Oliver Heimlich <oheim@posteo.de>
parents:
21073
diff
changeset
|
6712 |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6713 DEFUN (__parser_debug_flag__, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6714 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6715 @deftypefn {} {@var{val} =} __parser_debug_flag__ () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6716 @deftypefnx {} {@var{old_val} =} __parser_debug_flag__ (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6717 Query or set the internal flag that determines whether Octave's parser |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6718 prints debug information as it processes an expression. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6719 @seealso{__lexer_debug_flag__} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6720 @end deftypefn */) |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6721 { |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6722 octave_value retval; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6723 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6724 bool debug_flag = octave_debug; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6725 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6726 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
|
6727 "__parser_debug_flag__"); |
8311
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6728 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6729 octave_debug = debug_flag; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6730 |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6731 return retval; |
7124bffc89c7
parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents:
8283
diff
changeset
|
6732 } |
17342
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
6733 |
27017
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6734 DEFMETHOD (__parse_file__, interp, args, , |
24b7e6326e26
move parse_fcn_file to interpreter; source_file to evaluator
John W. Eaton <jwe@octave.org>
parents:
27016
diff
changeset
|
6735 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6736 @deftypefn {} {} __parse_file__ (@var{file}, @var{verbose}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6737 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21942
diff
changeset
|
6738 @end deftypefn */) |
17342
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
6739 { |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
6740 octave_value retval; |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
6741 |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
6742 int nargin = args.length (); |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
6743 |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6744 if (nargin < 1 || nargin > 2) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6745 print_usage (); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6746 |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
6747 std::string file |
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
6748 = args(0).xstring_value ("__parse_file__: expecting filename as argument"); |
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
6749 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
6750 std::string full_file = sys::file_ops::tilde_expand (file); |
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
6751 |
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
6752 full_file = sys::env::make_absolute (full_file); |
23667
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23655
diff
changeset
|
6753 |
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23655
diff
changeset
|
6754 std::string dir_name; |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6755 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
6756 std::size_t file_len = file.length (); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6757 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6758 if ((file_len > 4 && file.substr (file_len-4) == ".oct") |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6759 || (file_len > 4 && file.substr (file_len-4) == ".mex") |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6760 || (file_len > 2 && file.substr (file_len-2) == ".m")) |
17342
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
6761 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
6762 file = sys::env::base_pathname (file); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6763 file = file.substr (0, file.find_last_of ('.')); |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6764 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
6765 std::size_t pos = file.find_last_of (sys::file_ops::dir_sep_str ()); |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6766 if (pos != std::string::npos) |
23667
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23655
diff
changeset
|
6767 { |
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23655
diff
changeset
|
6768 dir_name = file.substr (0, pos); |
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23655
diff
changeset
|
6769 file = file.substr (pos+1); |
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23655
diff
changeset
|
6770 } |
17342
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
6771 } |
20798
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6772 |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6773 if (nargin == 2) |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6774 octave_stdout << "parsing " << full_file << std::endl; |
bb585db6dee2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
6775 |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23641
diff
changeset
|
6776 octave_value ov_fcn |
27509
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
6777 = parse_fcn_file (interp, full_file, file, dir_name, "", "", true, |
fefc780b4e2e
move parse_fcn_file from interpreter member function to parser friend
John W. Eaton <jwe@octave.org>
parents:
27507
diff
changeset
|
6778 false, false, false); |
17342
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
6779 |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
6780 return retval; |
091e4df179de
new function to help with debugging by parsing .m files without executing them
John W. Eaton <jwe@octave.org>
parents:
17326
diff
changeset
|
6781 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
6782 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
6783 OCTAVE_NAMESPACE_END |