annotate libinterp/parse-tree/pt-check.cc @ 27923:bd51beb6205e

update formatting of copyright notices * Use <https://octave.org/copyright/> instead of <https://octave.org/COPYRIGHT.html/>. * For consistency with other comments in the Octave sources, use C++-style comments for copyright blocks in C and C++ files. * Use delimiters above and below copyright blocks that are appropriate for the language used in the file. * Eliminate extra spacing inside copyright blocks. * lex.ll (looks_like_copyright): Also allow newlines and carriage returns before the word "Copyright". * scripts/mk-doc.pl (gethelp): Also skip empty comment lines. * bp-table.cc, type.m: Adjust tests.
author John W. Eaton <jwe@octave.org>
date Wed, 08 Jan 2020 11:59:41 -0500
parents 1891570abac8
children 0a5b15007766
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 1996-2020 The Octave Project Developers
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 ////////////////////////////////////////////////////////////////////////
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
28 #endif
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
29
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
30 #include "error.h"
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
31 #include "input.h"
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
32 #include "ov-usr-fcn.h"
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
33 #include "pt-all.h"
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
34
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
35 namespace octave
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
36 {
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
37 void
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
38 tree_checker::visit_argument_list (tree_argument_list& lst)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
39 {
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
40 auto p = lst.begin ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
41
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
42 while (p != lst.end ())
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
43 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
44 tree_expression *elt = *p++;
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
45
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
46 if (elt)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
47 {
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
48 if (m_do_lvalue_check && ! elt->lvalue_ok ())
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
49 errmsg ("invalid lvalue in multiple assignment", elt->line ());
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
50 }
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
51 }
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
52 }
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
53
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
54 void
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
55 tree_checker::visit_simple_for_command (tree_simple_for_command& cmd)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
56 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
57 tree_expression *lhs = cmd.left_hand_side ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
58
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
59 if (lhs)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
60 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
61 if (! lhs->lvalue_ok ())
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
62 errmsg ("invalid lvalue in for command", cmd.line ());
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
63 }
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
64
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
65 tree_expression *expr = cmd.control_expr ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
66
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
67 if (expr)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
68 expr->accept (*this);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
69
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
70 tree_expression *maxproc = cmd.maxproc_expr ();
13245
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
71
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
72 if (maxproc)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
73 maxproc->accept (*this);
13245
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
74
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
75 tree_statement_list *list = cmd.body ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
76
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
77 if (list)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
78 list->accept (*this);
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
79 }
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
80
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
81 void
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
82 tree_checker::visit_complex_for_command (tree_complex_for_command& cmd)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
83 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
84 tree_argument_list *lhs = cmd.left_hand_side ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
85
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
86 if (lhs)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
87 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
88 int len = lhs->length ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
89
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
90 if (len == 0 || len > 2)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
91 errmsg ("invalid number of output arguments in for command",
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
92 cmd.line ());
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
93
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
94 m_do_lvalue_check = true;
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
95
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
96 lhs->accept (*this);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
97
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
98 m_do_lvalue_check = false;
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
99 }
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
100
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
101 tree_expression *expr = cmd.control_expr ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
102
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
103 if (expr)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
104 expr->accept (*this);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
105
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
106 tree_statement_list *list = cmd.body ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
107
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
108 if (list)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
109 list->accept (*this);
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
110 }
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
111
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
112 void
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
113 tree_checker::visit_multi_assignment (tree_multi_assignment& expr)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
114 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
115 tree_argument_list *lhs = expr.left_hand_side ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
116
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
117 if (lhs)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
118 {
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
119 m_do_lvalue_check = true;
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
120
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
121 lhs->accept (*this);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
122
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
123 m_do_lvalue_check = false;
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
124 }
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
125
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
126 tree_expression *rhs = expr.right_hand_side ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
127
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
128 if (rhs)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
129 rhs->accept (*this);
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
130 }
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
131
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
132 void
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
133 tree_checker::visit_simple_assignment (tree_simple_assignment& expr)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
134 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
135 tree_expression *lhs = expr.left_hand_side ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
136
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
137 if (lhs)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
138 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
139 if (! lhs->lvalue_ok ())
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
140 errmsg ("invalid lvalue in assignment", expr.line ());
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
141 }
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
142
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
143 tree_expression *rhs = expr.right_hand_side ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
144
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
145 if (rhs)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
146 rhs->accept (*this);
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
147 }
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
148
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
149 void
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
150 tree_checker::visit_try_catch_command (tree_try_catch_command& cmd)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
151 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
152 tree_statement_list *try_code = cmd.body ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
153
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
154 tree_identifier *expr_id = cmd.identifier ();
17249
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16203
diff changeset
155
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
156 if (expr_id)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
157 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
158 if (! expr_id->lvalue_ok ())
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
159 errmsg ("invalid lvalue used for identifier in try-catch command",
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
160 cmd.line ());
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
161 }
17249
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16203
diff changeset
162
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
163 if (try_code)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
164 try_code->accept (*this);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
165
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
166 tree_statement_list *catch_code = cmd.cleanup ();
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
167
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
168 if (catch_code)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
169 catch_code->accept (*this);
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
170 }
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents:
diff changeset
171
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
172 void
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
173 tree_checker::errmsg (const std::string& msg, int line)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
174 {
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
175 if (m_file_name.empty ())
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
176 error ("%s", msg.c_str ());
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
177 else
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
178 error ("%s: %d: %s", m_file_name.c_str (), line, msg.c_str ());
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22872
diff changeset
179 }
4229
40153a2affd6 [project @ 2002-12-18 20:37:32 by jwe]
jwe
parents: 4219
diff changeset
180 }