annotate libinterp/parse-tree/oct-parse.yy @ 15954:46ca8488de92 classdef

Re-engineer tree_expression postfix handling to make it more flexible. * libinterp/octave-value/ov-fcn.h (octave_function::is_postfix_index_handled): New method. * libinterp/parse-tree/oct-parse.yy (make_index_expression, make_indirect_ref): Set expression postfix index type. * libinterp/parse-tree/pt-exp.h (tree_expression::postfix_index): Remove field. (tree_expression::postfix_index_type): New field. (tree_expression::tree_expression): Initialize it. (tree_expression::copy_base): Copy it. (tree_expression::set_postfix_index, tree_expression::postfix_index): New methods. (tree_expression::mark_postfix_indexed): Remove method. (tree_expression::is_postfix_indexed): Use postfix_index_type field. * libinterp/parse-tree/pt-id.cc (tree_identifier::rvalue): Let the function object determine whether it can handle the first postfix index and call do_multi_index_op if it can't.
author Michael Goffioul <michael.goffioul@gmail.com>
date Tue, 15 Jan 2013 17:01:10 -0500
parents ce8ad12ce8a0
children 0259254a3ccc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1829
7d2982b55242 [project @ 1996-02-02 14:12:59 by jwe]
jwe
parents: 1826
diff changeset
1 /*
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14084
diff changeset
3 Copyright (C) 1993-2012 John W. Eaton
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
4 Copyright (C) 2009 David Grundberg
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11464
diff changeset
5 Copyright (C) 2009-2010 VZLU Prague
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
12 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
18
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
20 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
21 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
23 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
24
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25 // Parser for Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 751
diff changeset
27 // C decarations.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 751
diff changeset
28
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
29 %{
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
30 #define YYDEBUG 1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
31
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 206
diff changeset
32 #ifdef HAVE_CONFIG_H
1229
7d7c3eaa1d3b [project @ 1995-04-10 01:04:13 by jwe]
jwe
parents: 1162
diff changeset
33 #include <config.h>
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 206
diff changeset
34 #endif
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 206
diff changeset
35
3178
09a3064a3a17 [project @ 1998-06-23 03:46:42 by jwe]
jwe
parents: 3165
diff changeset
36 #include <cassert>
10463
bbe99b2a5ba7 undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents: 10447
diff changeset
37 #include <cstdio>
bbe99b2a5ba7 undo recent gnulib-related changes
John W. Eaton <jwe@octave.org>
parents: 10447
diff changeset
38 #include <cstdlib>
2427
2f50b24ce84f [project @ 1996-10-25 06:15:28 by jwe]
jwe
parents: 2375
diff changeset
39
8950
d865363208d6 include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
40 #include <iostream>
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
41 #include <map>
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5760
diff changeset
42 #include <sstream>
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
43
3928
e8627dc4bdf2 [project @ 2002-05-03 19:56:01 by jwe]
jwe
parents: 3903
diff changeset
44 #include "Cell.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
45 #include "Matrix.h"
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
46 #include "cmd-edit.h"
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
47 #include "cmd-hist.h"
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
48 #include "file-ops.h"
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
49 #include "file-stat.h"
4243
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4240
diff changeset
50 #include "oct-env.h"
3712
7066a8065e7e [project @ 2000-08-22 06:21:20 by jwe]
jwe
parents: 3665
diff changeset
51 #include "oct-time.h"
4171
04694e5b4239 [project @ 2002-11-12 20:27:24 by jwe]
jwe
parents: 4131
diff changeset
52 #include "quit.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
53
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
54 #include "comment-list.h"
4243
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4240
diff changeset
55 #include "defaults.h"
2166
d68119516779 [project @ 1996-05-13 13:41:55 by jwe]
jwe
parents: 2124
diff changeset
56 #include "defun.h"
4243
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4240
diff changeset
57 #include "dirfns.h"
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
58 #include "dynamic-ld.h"
1351
8256c4c57419 [project @ 1995-09-05 08:02:08 by jwe]
jwe
parents: 1315
diff changeset
59 #include "error.h"
8256c4c57419 [project @ 1995-09-05 08:02:08 by jwe]
jwe
parents: 1315
diff changeset
60 #include "input.h"
8256c4c57419 [project @ 1995-09-05 08:02:08 by jwe]
jwe
parents: 1315
diff changeset
61 #include "lex.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
62 #include "load-path.h"
1743
ab8612a09449 [project @ 1996-01-12 11:25:30 by jwe]
jwe
parents: 1740
diff changeset
63 #include "oct-hist.h"
5626
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
64 #include "oct-map.h"
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
65 #include "ov-classdef.h"
4935
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
66 #include "ov-fcn-handle.h"
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
67 #include "ov-usr-fcn.h"
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
68 #include "ov-null-mat.h"
1670
6708c53892c1 [project @ 1995-12-27 04:33:00 by jwe]
jwe
parents: 1623
diff changeset
69 #include "toplev.h"
1351
8256c4c57419 [project @ 1995-09-05 08:02:08 by jwe]
jwe
parents: 1315
diff changeset
70 #include "pager.h"
8256c4c57419 [project @ 1995-09-05 08:02:08 by jwe]
jwe
parents: 1315
diff changeset
71 #include "parse.h"
14329
8d1ae996c122 also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents: 14294
diff changeset
72 #include "parse-private.h"
2987
ae20b3f37f5e [project @ 1997-05-16 07:05:15 by jwe]
jwe
parents: 2982
diff changeset
73 #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
74 #include "pt-eval.h"
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
75 #include "pt-funcall.h"
1351
8256c4c57419 [project @ 1995-09-05 08:02:08 by jwe]
jwe
parents: 1315
diff changeset
76 #include "symtab.h"
8256c4c57419 [project @ 1995-09-05 08:02:08 by jwe]
jwe
parents: 1315
diff changeset
77 #include "token.h"
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
78 #include "unwind-prot.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
79 #include "utils.h"
1351
8256c4c57419 [project @ 1995-09-05 08:02:08 by jwe]
jwe
parents: 1315
diff changeset
80 #include "variables.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
81
10426
4db7beace28e oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10411
diff changeset
82 #if defined (GNULIB_NAMESPACE)
4db7beace28e oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10411
diff changeset
83 // Calls to the following functions appear in the generated output from
4db7beace28e oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10411
diff changeset
84 // Bison without the namespace tag. Redefine them so we will use them
4db7beace28e oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10411
diff changeset
85 // via the gnulib namespace.
4db7beace28e oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10411
diff changeset
86 #define fclose GNULIB_NAMESPACE::fclose
4db7beace28e oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10411
diff changeset
87 #define fprintf GNULIB_NAMESPACE::fprintf
4db7beace28e oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10411
diff changeset
88 #define malloc GNULIB_NAMESPACE::malloc
4db7beace28e oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10411
diff changeset
89 #endif
4db7beace28e oct-parse.yy, lex.ll: use symbols via gnulib namespace
John W. Eaton <jwe@octave.org>
parents: 10411
diff changeset
90
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
91 // The current input line number.
8447
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
92 int input_line_number = 1;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
93
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
94 // The column of the current token.
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
95 int current_input_column = 1;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
96
338
82d30a23c979 [project @ 1994-02-07 07:09:33 by jwe]
jwe
parents: 336
diff changeset
97 // Buffer for help text snagged from function files.
4426
51a0dcde8778 [project @ 2003-06-13 19:16:37 by jwe]
jwe
parents: 4343
diff changeset
98 std::stack<std::string> help_buf;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
99
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
100 // Buffer for comments appearing before a function statement.
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
101 static std::string fcn_comment_header;
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
102
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
103 // TRUE means we are using readline.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
104 // (--no-line-editing)
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
105 bool line_editing = true;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
106
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
107 // TRUE means we printed messages about reading startup files.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
108 bool reading_startup_message_printed = false;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
109
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
110 // TRUE means input is coming from startup file.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
111 bool input_from_startup_file = false;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
112
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
113 // = 0 currently outside any function.
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
114 // = 1 inside the primary function or a subfunction.
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
115 // > 1 means we are looking at a function definition that seems to be
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
116 // inside a function. Note that the function still might not be a
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
117 // nested function.
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
118 static int current_function_depth = 0;
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
119
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
120 // A stack holding the nested function scopes being parsed.
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
121 // We don't use std::stack, because we want the clear method. Also, we
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
122 // must access one from the top
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
123 static std::vector<symbol_table::scope_id> function_scopes;
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
124
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
125 // Maximum function depth detected. Just here to determine whether
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
126 // we have nested functions or just implicitly ended subfunctions.
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
127 static int max_function_depth = 0;
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
128
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
129 // FALSE if we are still at the primary function. Subfunctions can
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
130 // only be declared inside function files.
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
131 static int parsing_subfunctions = false;
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
132
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
133 // Have we found an explicit end to a function?
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
134 static bool endfunction_found = false;
4238
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4237
diff changeset
135
3903
1dbe160ea0d1 [project @ 2002-04-23 03:40:25 by jwe]
jwe
parents: 3883
diff changeset
136 // Keep track of symbol table information when parsing functions.
14329
8d1ae996c122 also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents: 14294
diff changeset
137 symtab_context parser_symtab_context;
4238
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4237
diff changeset
138
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
139 // Name of the current class when we are parsing class methods or
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
140 // constructors.
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
141 std::string current_class_name;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
142
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
143 // TRUE means we are in the process of autoloading a function.
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
144 static bool autoloading = false;
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
145
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6238
diff changeset
146 // TRUE means the current function file was found in a relative path
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6238
diff changeset
147 // element.
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6238
diff changeset
148 static bool fcn_file_from_relative_lookup = false;
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6238
diff changeset
149
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
150 // Pointer to the primary user function or user script function.
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
151 static octave_function *primary_fcn_ptr = 0;
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
152
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
153 // Scope where we install all subfunctions and nested functions. Only
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
154 // used while reading function files.
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
155 static symbol_table::scope_id primary_fcn_scope;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
156
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
157 // Pointer to the classdef object we just parsed, if any.
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
158 static tree_classdef *classdef_object = 0;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
159
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
160 // List of autoloads (function -> file mapping).
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
161 static std::map<std::string, std::string> autoload_map;
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
162
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
163 // Forward declarations for some functions defined at the bottom of
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
164 // the file.
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
165
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
166 // Generic error messages.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
167 static void
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
168 yyerror (const char *s);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
169
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
170 // Error mesages for mismatched end tokens.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
171 static void
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
172 end_error (const char *type, token::end_tok_type ettype, int l, int c);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
173
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
174 // Check to see that end tokens are properly matched.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
175 static bool
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
176 end_token_ok (token *tok, token::end_tok_type expected);
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
177
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
178 // Maybe print a warning if an assignment expression is used as the
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
179 // test in a logical expression.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
180 static void
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
181 maybe_warn_assign_as_truth_value (tree_expression *expr);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
182
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
183 // Maybe print a warning about switch labels that aren't constants.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
184 static void
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
185 maybe_warn_variable_switch_label (tree_expression *expr);
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
186
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
187 // Finish building a range.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
188 static tree_expression *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
189 finish_colon_expression (tree_colon_expression *e);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
190
1607
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
191 // Build a constant.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
192 static tree_constant *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
193 make_constant (int op, token *tok_val);
1607
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
194
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
195 // Build a function handle.
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
196 static tree_fcn_handle *
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
197 make_fcn_handle (token *tok_val);
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
198
4935
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
199 // Build an anonymous function handle.
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5848
diff changeset
200 static tree_anon_fcn_handle *
4935
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
201 make_anon_fcn_handle (tree_parameter_list *param_list, tree_statement *stmt);
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
202
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
203 // Build a binary expression.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
204 static tree_expression *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
205 make_binary_op (int op, tree_expression *op1, token *tok_val,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
206 tree_expression *op2);
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
207
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
208 // Build a boolean expression.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
209 static tree_expression *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
210 make_boolean_op (int op, tree_expression *op1, token *tok_val,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
211 tree_expression *op2);
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
212
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
213 // Build a prefix expression.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
214 static tree_expression *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
215 make_prefix_op (int op, tree_expression *op1, token *tok_val);
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
216
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
217 // Build a postfix expression.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
218 static tree_expression *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
219 make_postfix_op (int op, tree_expression *op1, token *tok_val);
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
220
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
221 // Build an unwind-protect command.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
222 static tree_command *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
223 make_unwind_command (token *unwind_tok, tree_statement_list *body,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
224 tree_statement_list *cleanup, token *end_tok,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
225 octave_comment_list *lc, octave_comment_list *mc);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
226
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
227 // Build a try-catch command.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
228 static tree_command *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
229 make_try_command (token *try_tok, tree_statement_list *body,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
230 tree_statement_list *cleanup, token *end_tok,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
231 octave_comment_list *lc, octave_comment_list *mc);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
232
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
233 // Build a while command.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
234 static tree_command *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
235 make_while_command (token *while_tok, tree_expression *expr,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
236 tree_statement_list *body, token *end_tok,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
237 octave_comment_list *lc);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
238
3484
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
239 // Build a do-until command.
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
240 static tree_command *
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
241 make_do_until_command (token *until_tok, tree_statement_list *body,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
242 tree_expression *expr, octave_comment_list *lc);
3484
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
243
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
244 // Build a for command.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
245 static tree_command *
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
246 make_for_command (int tok_id, token *for_tok, tree_argument_list *lhs,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
247 tree_expression *expr, tree_expression *maxproc,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
248 tree_statement_list *body, token *end_tok,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
249 octave_comment_list *lc);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
250
4207
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
251 // Build a break command.
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
252 static tree_command *
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
253 make_break_command (token *break_tok);
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
254
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
255 // Build a continue command.
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
256 static tree_command *
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
257 make_continue_command (token *continue_tok);
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
258
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
259 // Build a return command.
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
260 static tree_command *
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
261 make_return_command (token *return_tok);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
262
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
263 // Start an if command.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
264 static tree_if_command_list *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
265 start_if_command (tree_expression *expr, tree_statement_list *list);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
266
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
267 // Finish an if command.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
268 static tree_if_command *
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
269 finish_if_command (token *if_tok, tree_if_command_list *list,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
270 token *end_tok, octave_comment_list *lc);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
271
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
272 // Build an elseif clause.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
273 static tree_if_clause *
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
274 make_elseif_clause (token *elseif_tok, tree_expression *expr,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
275 tree_statement_list *list, octave_comment_list *lc);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
276
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
277 // Finish a switch command.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
278 static tree_switch_command *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
279 finish_switch_command (token *switch_tok, tree_expression *expr,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
280 tree_switch_case_list *list, token *end_tok,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
281 octave_comment_list *lc);
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
282
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
283 // Build a switch case.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
284 static tree_switch_case *
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
285 make_switch_case (token *case_tok, tree_expression *expr,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
286 tree_statement_list *list, octave_comment_list *lc);
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
287
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
288 // Build an assignment to a variable.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
289 static tree_expression *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
290 make_assign_op (int op, tree_argument_list *lhs, token *eq_tok,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
291 tree_expression *rhs);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
292
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
293 // Define a script.
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
294 static void
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
295 make_script (tree_statement_list *cmds, tree_statement *end_script);
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
296
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
297 // Begin defining a function.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
298 static octave_user_function *
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
299 start_function (tree_parameter_list *param_list, tree_statement_list *body,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
300 tree_statement *end_function);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
301
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
302 // Create a no-op statement for end_function.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
303 static tree_statement *
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
304 make_end (const std::string& type, int l, int c);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
305
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
306 // Do most of the work for defining a function.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
307 static octave_user_function *
4872
fe71c458f438 [project @ 2004-04-21 20:09:32 by jwe]
jwe
parents: 4844
diff changeset
308 frob_function (const std::string& fname, octave_user_function *fcn);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
309
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
310 // Finish defining a function.
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
311 static tree_function_def *
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
312 finish_function (tree_parameter_list *ret_list,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
313 octave_user_function *fcn, octave_comment_list *lc);
751
c9f3cb77478d [project @ 1994-09-30 18:46:17 by jwe]
jwe
parents: 723
diff changeset
314
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
315 // Reset state after parsing function.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
316 static void
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
317 recover_from_parsing_function (void);
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
318
751
c9f3cb77478d [project @ 1994-09-30 18:46:17 by jwe]
jwe
parents: 723
diff changeset
319 // Make an index expression.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
320 static tree_index_expression *
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
321 make_index_expression (tree_expression *expr,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
322 tree_argument_list *args, char type);
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
323
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
324 // Make an indirect reference expression.
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
325 static tree_index_expression *
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
326 make_indirect_ref (tree_expression *expr, const std::string&);
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
327
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
328 // Make an indirect reference expression with dynamic field name.
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
329 static tree_index_expression *
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
330 make_indirect_ref (tree_expression *expr, tree_expression *field);
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
331
2846
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
332 // Make a declaration command.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
333 static tree_decl_command *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
334 make_decl_command (int tok, token *tok_val, tree_decl_init_list *lst);
2846
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
335
10207
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
336 // Validate argument list forming a matrix or cell row.
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
337 static tree_argument_list *
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
338 validate_matrix_row (tree_argument_list *row);
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
339
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
340 // Finish building a matrix list.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
341 static tree_expression *
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
342 finish_matrix (tree_matrix *m);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
343
3351
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
344 // Finish building a cell list.
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
345 static tree_expression *
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
346 finish_cell (tree_cell *c);
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
347
1511
74f9e88a2c12 [project @ 1995-10-03 10:49:31 by jwe]
jwe
parents: 1491
diff changeset
348 // Maybe print a warning. Duh.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
349 static void
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
350 maybe_warn_missing_semi (tree_statement_list *);
1511
74f9e88a2c12 [project @ 1995-10-03 10:49:31 by jwe]
jwe
parents: 1491
diff changeset
351
2525
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
352 // Set the print flag for a statement based on the separator type.
8471
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
353 static tree_statement_list *
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
354 set_stmt_print_flag (tree_statement_list *, char, bool);
2525
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
355
8448
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
356 // Create a statement list.
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
357 static tree_statement_list *make_statement_list (tree_statement *stmt);
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
358
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
359 // Append a statement to an existing statement list.
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
360 static tree_statement_list *
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
361 append_statement_list (tree_statement_list *list, char sep,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
362 tree_statement *stmt, bool warn_missing_semi);
8448
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
363
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
364 static tree_funcall *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
365 make_superclass_ref (const std::string& method_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
366 const std::string& package_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
367 const std::string& class_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
368 int l, int c);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
369
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
370 static tree_funcall *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
371 make_meta_class_query (const std::string& package_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
372 const std::string& class_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
373 int l, int c);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
374
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
375 static tree_classdef *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
376 make_classdef (token *tok_val, tree_classdef_attribute_list *a,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
377 tree_identifier *id, tree_classdef_superclass_list *sc,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
378 tree_classdef_body *body, token *end_tok,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
379 octave_comment_list *lc);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
380
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
381 static tree_classdef_properties_block *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
382 make_classdef_properties_block (token *tok_val,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
383 tree_classdef_attribute_list *a,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
384 tree_classdef_property_list *plist,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
385 token *end_tok, octave_comment_list *lc);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
386
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
387 static tree_classdef_methods_block *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
388 make_classdef_methods_block (token *tok_val,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
389 tree_classdef_attribute_list *a,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
390 tree_classdef_methods_list *mlist,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
391 token *end_tok, octave_comment_list *lc);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
392
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
393 static tree_classdef_events_block *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
394 make_classdef_events_block (token *tok_val,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
395 tree_classdef_attribute_list *a,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
396 tree_classdef_events_list *elist,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
397 token *end_tok, octave_comment_list *lc);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
398
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
399 static tree_classdef_enum_block *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
400 make_classdef_enum_block (token *tok_val,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
401 tree_classdef_attribute_list *a,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
402 tree_classdef_enum_list *elist,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
403 token *end_tok, octave_comment_list *lc);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
404
8448
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
405 // Finish building a statement.
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
406 template <class T>
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
407 static tree_statement *
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
408 make_statement (T *arg)
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
409 {
8471
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
410 octave_comment_list *comment = octave_comment_buffer::get_comment ();
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
411
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
412 return new tree_statement (arg, comment);
8448
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
413 }
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
414
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
415 #define ABORT_PARSE \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
416 do \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
417 { \
522
2dba380d2d85 [project @ 1994-07-20 18:31:40 by jwe]
jwe
parents: 504
diff changeset
418 global_command = 0; \
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
419 yyerrok; \
14329
8d1ae996c122 also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents: 14294
diff changeset
420 if (! parser_symtab_context.empty ()) \
8d1ae996c122 also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents: 14294
diff changeset
421 parser_symtab_context.pop (); \
14584
3a10d5bdada8 src/symtab.yy (ABORT_PARSE): Prevent multiple parse errors in eval (bug #35154)
Max Brister <max@2bass.com>
parents: 14544
diff changeset
422 if ((interactive || forced_interactive) \
3a10d5bdada8 src/symtab.yy (ABORT_PARSE): Prevent multiple parse errors in eval (bug #35154)
Max Brister <max@2bass.com>
parents: 14544
diff changeset
423 && ! get_input_from_eval_string) \
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
424 YYACCEPT; \
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
425 else \
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
426 YYABORT; \
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
427 } \
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
428 while (0)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
429
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
430 %}
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
431
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
432 // Bison declarations.
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
433
4813
fba5c6e96e0f [project @ 2004-03-03 23:35:43 by jwe]
jwe
parents: 4753
diff changeset
434 // Don't add spaces around the = here; it causes some versions of
fba5c6e96e0f [project @ 2004-03-03 23:35:43 by jwe]
jwe
parents: 4753
diff changeset
435 // bison to fail to properly recognize the directive.
fba5c6e96e0f [project @ 2004-03-03 23:35:43 by jwe]
jwe
parents: 4753
diff changeset
436
fba5c6e96e0f [project @ 2004-03-03 23:35:43 by jwe]
jwe
parents: 4753
diff changeset
437 %name-prefix="octave_"
4753
9f0ce1536368 [project @ 2004-02-13 17:55:24 by jwe]
jwe
parents: 4699
diff changeset
438
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
439 %union
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
440 {
2891
1a30f46e1870 [project @ 1997-04-28 01:49:00 by jwe]
jwe
parents: 2884
diff changeset
441 // The type of the basic tokens returned by the lexer.
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
442 token *tok_val;
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
443
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
444 // Comment strings that we need to deal with mid-rule.
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
445 octave_comment_list *comment_type;
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
446
2891
1a30f46e1870 [project @ 1997-04-28 01:49:00 by jwe]
jwe
parents: 2884
diff changeset
447 // Types for the nonterminals we generate.
2525
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
448 char sep_type;
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
449 token *tok_type;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
450 tree *tree_type;
1829
7d2982b55242 [project @ 1996-02-02 14:12:59 by jwe]
jwe
parents: 1826
diff changeset
451 tree_matrix *tree_matrix_type;
3351
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
452 tree_cell *tree_cell_type;
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
453 tree_expression *tree_expression_type;
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
454 tree_constant *tree_constant_type;
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
455 tree_fcn_handle *tree_fcn_handle_type;
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
456 tree_funcall *tree_funcall_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
457 tree_function_def *tree_function_def_type;
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5848
diff changeset
458 tree_anon_fcn_handle *tree_anon_fcn_handle_type;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
459 tree_identifier *tree_identifier_type;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
460 tree_index_expression *tree_index_expression_type;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
461 tree_colon_expression *tree_colon_expression_type;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
462 tree_argument_list *tree_argument_list_type;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
463 tree_parameter_list *tree_parameter_list_type;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
464 tree_command *tree_command_type;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
465 tree_if_command *tree_if_command_type;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
466 tree_if_clause *tree_if_clause_type;
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
467 tree_if_command_list *tree_if_command_list_type;
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
468 tree_switch_command *tree_switch_command_type;
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
469 tree_switch_case *tree_switch_case_type;
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
470 tree_switch_case_list *tree_switch_case_list_type;
2846
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
471 tree_decl_elt *tree_decl_elt_type;
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
472 tree_decl_init_list *tree_decl_init_list_type;
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
473 tree_decl_command *tree_decl_command_type;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
474 tree_statement *tree_statement_type;
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
475 tree_statement_list *tree_statement_list_type;
2891
1a30f46e1870 [project @ 1997-04-28 01:49:00 by jwe]
jwe
parents: 2884
diff changeset
476 octave_user_function *octave_user_function_type;
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
477
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
478 tree_classdef *tree_classdef_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
479 tree_classdef_attribute* tree_classdef_attribute_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
480 tree_classdef_attribute_list* tree_classdef_attribute_list_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
481 tree_classdef_superclass* tree_classdef_superclass_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
482 tree_classdef_superclass_list* tree_classdef_superclass_list_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
483 tree_classdef_body* tree_classdef_body_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
484 tree_classdef_property* tree_classdef_property_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
485 tree_classdef_property_list* tree_classdef_property_list_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
486 tree_classdef_properties_block* tree_classdef_properties_block_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
487 tree_classdef_methods_list* tree_classdef_methods_list_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
488 tree_classdef_methods_block* tree_classdef_methods_block_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
489 tree_classdef_event* tree_classdef_event_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
490 tree_classdef_events_list* tree_classdef_events_list_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
491 tree_classdef_events_block* tree_classdef_events_block_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
492 tree_classdef_enum* tree_classdef_enum_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
493 tree_classdef_enum_list* tree_classdef_enum_list_type;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
494 tree_classdef_enum_block* tree_classdef_enum_block_type;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
495 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
496
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
497 // Tokens with line and column information.
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
498 %token <tok_val> '=' ':' '-' '+' '*' '/'
4018
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4009
diff changeset
499 %token <tok_val> ADD_EQ SUB_EQ MUL_EQ DIV_EQ LEFTDIV_EQ POW_EQ
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4009
diff changeset
500 %token <tok_val> EMUL_EQ EDIV_EQ ELEFTDIV_EQ EPOW_EQ AND_EQ OR_EQ
2899
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
501 %token <tok_val> LSHIFT_EQ RSHIFT_EQ LSHIFT RSHIFT
428
fa0453b25410 [project @ 1994-05-25 01:06:28 by jwe]
jwe
parents: 341
diff changeset
502 %token <tok_val> EXPR_AND_AND EXPR_OR_OR
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
503 %token <tok_val> EXPR_AND EXPR_OR EXPR_NOT
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
504 %token <tok_val> EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT
1276
cbdf7db98554 [project @ 1995-04-24 15:31:24 by jwe]
jwe
parents: 1266
diff changeset
505 %token <tok_val> LEFTDIV EMUL EDIV ELEFTDIV EPLUS EMINUS
cbdf7db98554 [project @ 1995-04-24 15:31:24 by jwe]
jwe
parents: 1266
diff changeset
506 %token <tok_val> QUOTE TRANSPOSE
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
507 %token <tok_val> PLUS_PLUS MINUS_MINUS POW EPOW
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
508 %token <tok_val> NUM IMAG_NUM
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
509 %token <tok_val> STRUCT_ELT
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
510 %token <tok_val> NAME
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
511 %token <tok_val> END
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5189
diff changeset
512 %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
513 %token <tok_val> FOR PARFOR WHILE DO UNTIL
1491
893b416bb919 [project @ 1995-09-29 04:03:01 by jwe]
jwe
parents: 1489
diff changeset
514 %token <tok_val> IF ELSEIF ELSE
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
515 %token <tok_val> SWITCH CASE OTHERWISE
1491
893b416bb919 [project @ 1995-09-29 04:03:01 by jwe]
jwe
parents: 1489
diff changeset
516 %token <tok_val> BREAK CONTINUE FUNC_RET
924
8b0920cc1d64 [project @ 1994-11-15 00:40:50 by jwe]
jwe
parents: 922
diff changeset
517 %token <tok_val> UNWIND CLEANUP
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1371
diff changeset
518 %token <tok_val> TRY CATCH
14294
9e3983c8963c deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents: 14293
diff changeset
519 %token <tok_val> GLOBAL PERSISTENT
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
520 %token <tok_val> FCN_HANDLE
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
521 %token <tok_val> CLASSDEF
13249
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
522 %token <tok_val> PROPERTIES METHODS EVENTS ENUMERATION
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
523 %token <tok_val> METAQUERY
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
524 %token <tok_val> SUPERCLASSREF
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
525 %token <tok_val> GET SET
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
526
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
527 // Other tokens.
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
528 %token END_OF_INPUT LEXICAL_ERROR
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
529 %token FCN SCRIPT_FILE CLASSDEF_FILE FUNCTION_FILE
7587
1f662945c2be handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents: 7562
diff changeset
530 // %token VARARGIN VARARGOUT
5296
4e753a157ed2 [project @ 2005-04-21 17:52:41 by jwe]
jwe
parents: 5279
diff changeset
531 %token CLOSE_BRACE
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
532
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
533 // Nonterminals we construct.
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
534 %type <comment_type> stash_comment function_beg
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
535 %type <tok_type> classdef_beg
14533
e6aa044253eb Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents: 14512
diff changeset
536 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep opt_comma
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
537 %type <tree_type> input
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5848
diff changeset
538 %type <tree_constant_type> string constant magic_colon
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5848
diff changeset
539 %type <tree_anon_fcn_handle_type> anon_fcn_handle
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
540 %type <tree_fcn_handle_type> fcn_handle
3351
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
541 %type <tree_matrix_type> matrix_rows matrix_rows1
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
542 %type <tree_cell_type> cell_rows cell_rows1
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents: 5013
diff changeset
543 %type <tree_expression_type> matrix cell
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
544 %type <tree_expression_type> primary_expr oper_expr
4207
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
545 %type <tree_expression_type> simple_expr colon_expr assign_expr expression
10206
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10188
diff changeset
546 %type <tree_identifier_type> identifier fcn_name magic_tilde
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
547 %type <tree_funcall_type> superclass_identifier meta_identifier
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
548 %type <octave_user_function_type> function1 function2
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
549 %type <tree_index_expression_type> word_list_cmd
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
550 %type <tree_colon_expression_type> colon_expr1
3351
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
551 %type <tree_argument_list_type> arg_list word_list assign_lhs
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
552 %type <tree_argument_list_type> cell_or_matrix_row
4935
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
553 %type <tree_parameter_list_type> param_list param_list1 param_list2
723
1c072f20b522 [project @ 1994-09-21 16:00:10 by jwe]
jwe
parents: 666
diff changeset
554 %type <tree_parameter_list_type> return_list return_list1
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
555 %type <tree_command_type> command select_command loop_command
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
556 %type <tree_command_type> jump_command except_command
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
557 %type <tree_function_def_type> function
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
558 %type <tree_classdef_type> classdef
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
559 %type <tree_command_type> script_file classdef_file
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
560 %type <tree_command_type> function_file function_list
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
561 %type <tree_if_command_type> if_command
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
562 %type <tree_if_clause_type> elseif_clause else_clause
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
563 %type <tree_if_command_list_type> if_cmd_list1 if_cmd_list
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
564 %type <tree_switch_command_type> switch_command
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
565 %type <tree_switch_case_type> switch_case default_case
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
566 %type <tree_switch_case_list_type> case_list1 case_list
2846
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
567 %type <tree_decl_elt_type> decl2
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
568 %type <tree_decl_init_list_type> decl1
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
569 %type <tree_decl_command_type> declaration
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
570 %type <tree_statement_type> statement function_end
627
739d16c30481 [project @ 1994-08-19 13:23:14 by jwe]
jwe
parents: 620
diff changeset
571 %type <tree_statement_list_type> simple_list simple_list1 list list1
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
572 %type <tree_statement_list_type> opt_list input1
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
573
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
574 %type <tree_classdef_attribute_type> attr
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
575 %type <tree_classdef_attribute_list_type> attr_list opt_attr_list
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
576 %type <tree_classdef_superclass_type> superclass
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
577 %type <tree_classdef_superclass_list_type> superclass_list opt_superclass_list
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
578 %type <tree_classdef_body_type> class_body
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
579 %type <tree_classdef_property_type> class_property
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
580 %type <tree_classdef_property_list_type> property_list
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
581 %type <tree_classdef_properties_block_type> properties_block
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
582 %type <tree_classdef_methods_list_type> methods_list
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
583 %type <tree_classdef_methods_block_type> methods_block
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
584 %type <tree_classdef_event_type> class_event
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
585 %type <tree_classdef_events_list_type> events_list
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
586 %type <tree_classdef_events_block_type> events_block
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
587 %type <tree_classdef_enum_type> class_enum
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
588 %type <tree_classdef_enum_list_type> enum_list
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
589 %type <tree_classdef_enum_block_type> enum_block
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
590
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
591 // Precedence and associativity.
4018
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4009
diff changeset
592 %right '=' ADD_EQ SUB_EQ MUL_EQ DIV_EQ LEFTDIV_EQ POW_EQ EMUL_EQ EDIV_EQ ELEFTDIV_EQ EPOW_EQ OR_EQ AND_EQ LSHIFT_EQ RSHIFT_EQ
4023
ef3caf27cb9c [project @ 2002-08-07 06:54:41 by jwe]
jwe
parents: 4018
diff changeset
593 %left EXPR_OR_OR
ef3caf27cb9c [project @ 2002-08-07 06:54:41 by jwe]
jwe
parents: 4018
diff changeset
594 %left EXPR_AND_AND
ef3caf27cb9c [project @ 2002-08-07 06:54:41 by jwe]
jwe
parents: 4018
diff changeset
595 %left EXPR_OR
ef3caf27cb9c [project @ 2002-08-07 06:54:41 by jwe]
jwe
parents: 4018
diff changeset
596 %left EXPR_AND
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
597 %left EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT
2899
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
598 %left LSHIFT RSHIFT
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
599 %left ':'
1276
cbdf7db98554 [project @ 1995-04-24 15:31:24 by jwe]
jwe
parents: 1266
diff changeset
600 %left '-' '+' EPLUS EMINUS
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
601 %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
602 %right UNARY EXPR_NOT
5667
ec3ffbf9982b [project @ 2006-03-15 02:51:39 by jwe]
jwe
parents: 5626
diff changeset
603 %left POW EPOW QUOTE TRANSPOSE
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
604 %right PLUS_PLUS MINUS_MINUS
3351
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
605 %left '(' '.' '{'
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
606
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
607 // Where to start.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
608 %start input
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
609
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
610 %%
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
611
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
612 // ==============================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
613 // Statements and statement lists
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
614 // ==============================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
615
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
616 input : input1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
617 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
618 global_command = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
619 promptflag = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
620 YYACCEPT;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
621 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
622 | function_file
11258
795c97ace02c eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents: 11225
diff changeset
623 { YYACCEPT; }
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
624 | classdef_file
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
625 { YYACCEPT; }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
626 | simple_list parse_error
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
627 { ABORT_PARSE; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
628 | parse_error
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
629 { ABORT_PARSE; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
630 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
631
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
632 input1 : '\n'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
633 { $$ = 0; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
634 | END_OF_INPUT
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
635 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
636 parser_end_of_input = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
637 $$ = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
638 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
639 | simple_list
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
640 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
641 | simple_list '\n'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
642 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
643 | simple_list END_OF_INPUT
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
644 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
645 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
646
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
647 simple_list : simple_list1 opt_sep_no_nl
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
648 { $$ = set_stmt_print_flag ($1, $2, false); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
649 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
650
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
651 simple_list1 : statement
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
652 { $$ = make_statement_list ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
653 | simple_list1 sep_no_nl statement
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
654 { $$ = append_statement_list ($1, $2, $3, false); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
655 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
656
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
657 opt_list : // empty
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
658 { $$ = new tree_statement_list (); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
659 | list
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
660 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
661 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
662
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
663 list : list1 opt_sep
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
664 { $$ = set_stmt_print_flag ($1, $2, true); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
665 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
666
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
667 list1 : statement
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
668 { $$ = make_statement_list ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
669 | list1 sep statement
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
670 { $$ = append_statement_list ($1, $2, $3, true); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
671 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
672
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
673 statement : expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
674 { $$ = make_statement ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
675 | command
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
676 { $$ = make_statement ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
677 | word_list_cmd
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
678 { $$ = make_statement ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
679 ;
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8745
diff changeset
680
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8745
diff changeset
681 // =================
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8745
diff changeset
682 // Word-list command
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8745
diff changeset
683 // =================
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8745
diff changeset
684
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8745
diff changeset
685 // 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
686 // 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
687 // WHILE, etc.
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8745
diff changeset
688
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
689 word_list_cmd : identifier word_list
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
690 { $$ = make_index_expression ($1, $2, '('); }
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
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
693 word_list : string
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
694 { $$ = new tree_argument_list ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
695 | word_list string
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
696 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
697 $1->append ($2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
698 $$ = $1;
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 ;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
701
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
702 // ===========
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
703 // Expressions
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
704 // ===========
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
705
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
706 identifier : NAME
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
707 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
708 symbol_table::symbol_record *sr = $1->sym_rec ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
709 $$ = new tree_identifier (*sr, $1->line (), $1->column ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
710 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
711 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
712
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
713 superclass_identifier
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
714 : SUPERCLASSREF
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
715 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
716 std::string method_nm = $1->superclass_method_name ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
717 std::string package_nm = $1->superclass_package_name ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
718 std::string class_nm = $1->superclass_class_name ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
719
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
720 $$ = make_superclass_ref (method_nm, package_nm, class_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
721 $1->line (), $1->column ());
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
722 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
723 ;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
724
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
725 meta_identifier : METAQUERY
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
726 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
727 std::string package_nm = $1->meta_package_name ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
728 std::string class_nm = $1->meta_class_name ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
729
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
730 $$ = make_meta_class_query (package_nm, class_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
731 $1->line (), $1->column ());
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
732 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
733 ;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
734
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
735 string : DQ_STRING
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
736 { $$ = make_constant (DQ_STRING, $1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
737 | SQ_STRING
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
738 { $$ = make_constant (SQ_STRING, $1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
739 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
740
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
741 constant : NUM
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
742 { $$ = make_constant (NUM, $1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
743 | IMAG_NUM
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
744 { $$ = make_constant (IMAG_NUM, $1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
745 | string
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
746 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
747 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
748
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
749 matrix : '[' ']'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
750 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
751 $$ = new tree_constant (octave_null_matrix::instance);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
752 lexer_flags.looking_at_matrix_or_assign_lhs = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
753 lexer_flags.pending_local_variables.clear ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
754 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
755 | '[' ';' ']'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
756 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
757 $$ = new tree_constant (octave_null_matrix::instance);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
758 lexer_flags.looking_at_matrix_or_assign_lhs = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
759 lexer_flags.pending_local_variables.clear ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
760 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
761 | '[' ',' ']'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
762 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
763 $$ = new tree_constant (octave_null_matrix::instance);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
764 lexer_flags.looking_at_matrix_or_assign_lhs = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
765 lexer_flags.pending_local_variables.clear ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
766 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
767 | '[' matrix_rows ']'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
768 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
769 $$ = finish_matrix ($2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
770 lexer_flags.looking_at_matrix_or_assign_lhs = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
771 lexer_flags.pending_local_variables.clear ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
772 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
773 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
774
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
775 matrix_rows : matrix_rows1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
776 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
777 | matrix_rows1 ';' // Ignore trailing semicolon.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
778 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
779 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
780
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
781 matrix_rows1 : cell_or_matrix_row
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
782 { $$ = new tree_matrix ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
783 | matrix_rows1 ';' cell_or_matrix_row
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
784 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
785 $1->append ($3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
786 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
787 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
788 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
789
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
790 cell : '{' '}'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
791 { $$ = new tree_constant (octave_value (Cell ())); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
792 | '{' ';' '}'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
793 { $$ = new tree_constant (octave_value (Cell ())); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
794 | '{' cell_rows '}'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
795 { $$ = finish_cell ($2); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
796 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
797
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
798 cell_rows : cell_rows1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
799 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
800 | cell_rows1 ';' // Ignore trailing semicolon.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
801 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
802 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
803
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
804 cell_rows1 : cell_or_matrix_row
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
805 { $$ = new tree_cell ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
806 | cell_rows1 ';' cell_or_matrix_row
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
807 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
808 $1->append ($3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
809 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
810 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
811 ;
3351
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
812
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
813 cell_or_matrix_row
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
814 : arg_list
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
815 { $$ = validate_matrix_row ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
816 | arg_list ',' // Ignore trailing comma.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
817 { $$ = validate_matrix_row ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
818 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
819
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
820 fcn_handle : '@' FCN_HANDLE
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
821 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
822 $$ = make_fcn_handle ($2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
823 lexer_flags.looking_at_function_handle--;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
824 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
825 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
826
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
827 anon_fcn_handle : '@' param_list statement
13237
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 13125
diff changeset
828 {
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 13125
diff changeset
829 lexer_flags.quote_is_transpose = false;
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 13125
diff changeset
830 $$ = make_anon_fcn_handle ($2, $3);
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 13125
diff changeset
831 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
832 ;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
833
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
834 primary_expr : identifier
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
835 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
836 | constant
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
837 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
838 | fcn_handle
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
839 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
840 | matrix
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
841 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
842 | cell
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
843 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
844 | meta_identifier
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
845 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
846 | superclass_identifier
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
847 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
848 | '(' expression ')'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
849 { $$ = $2->mark_in_parens (); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
850 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
851
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
852 magic_colon : ':'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
853 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
854 octave_value tmp (octave_value::magic_colon_t);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
855 $$ = new tree_constant (tmp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
856 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
857 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
858
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
859 magic_tilde : EXPR_NOT
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
860 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
861 $$ = new tree_black_hole ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
862 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
863 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
864
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
865 arg_list : expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
866 { $$ = new tree_argument_list ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
867 | magic_colon
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
868 { $$ = new tree_argument_list ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
869 | magic_tilde
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
870 { $$ = new tree_argument_list ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
871 | arg_list ',' magic_colon
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
872 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
873 $1->append ($3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
874 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
875 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
876 | arg_list ',' magic_tilde
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
877 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
878 $1->append ($3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
879 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
880 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
881 | arg_list ',' expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
882 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
883 $1->append ($3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
884 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
885 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
886 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
887
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
888 indirect_ref_op : '.'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
889 { lexer_flags.looking_at_indirect_ref = true; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
890 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
891
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
892 oper_expr : primary_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
893 { $$ = $1; }
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
894 | oper_expr PLUS_PLUS
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
895 { $$ = make_postfix_op (PLUS_PLUS, $1, $2); }
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
896 | oper_expr MINUS_MINUS
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
897 { $$ = make_postfix_op (MINUS_MINUS, $1, $2); }
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
898 | oper_expr '(' ')'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
899 { $$ = make_index_expression ($1, 0, '('); }
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
900 | oper_expr '(' arg_list ')'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
901 { $$ = make_index_expression ($1, $3, '('); }
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
902 | oper_expr '{' '}'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
903 { $$ = make_index_expression ($1, 0, '{'); }
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
904 | oper_expr '{' arg_list '}'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
905 { $$ = make_index_expression ($1, $3, '{'); }
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
906 | oper_expr QUOTE
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
907 { $$ = make_postfix_op (QUOTE, $1, $2); }
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
908 | oper_expr TRANSPOSE
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
909 { $$ = 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
910 | oper_expr indirect_ref_op STRUCT_ELT
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
911 { $$ = 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
912 | oper_expr indirect_ref_op '(' expression ')'
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
913 { $$ = make_indirect_ref ($1, $4); }
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
914 | PLUS_PLUS oper_expr %prec UNARY
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
915 { $$ = 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
916 | MINUS_MINUS oper_expr %prec UNARY
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
917 { $$ = 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
918 | EXPR_NOT oper_expr %prec UNARY
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
919 { $$ = 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
920 | '+' oper_expr %prec UNARY
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
921 { $$ = 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
922 | '-' oper_expr %prec UNARY
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
923 { $$ = 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
924 | oper_expr POW oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
925 { $$ = make_binary_op (POW, $1, $2, $3); }
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
926 | oper_expr EPOW oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
927 { $$ = 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
928 | oper_expr '+' oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
929 { $$ = 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
930 | oper_expr '-' oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
931 { $$ = 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
932 | oper_expr '*' oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
933 { $$ = 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
934 | oper_expr '/' oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
935 { $$ = 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
936 | oper_expr EPLUS oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
937 { $$ = 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
938 | oper_expr EMINUS oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
939 { $$ = 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
940 | oper_expr EMUL oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
941 { $$ = 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
942 | oper_expr EDIV oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
943 { $$ = 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
944 | oper_expr LEFTDIV oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
945 { $$ = 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
946 | oper_expr ELEFTDIV oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
947 { $$ = make_binary_op (ELEFTDIV, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
948 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
949
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
950 colon_expr : colon_expr1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
951 { $$ = finish_colon_expression ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
952 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
953
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
954 colon_expr1 : oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
955 { $$ = new tree_colon_expression ($1); }
12627
002948ae5bc0 fix precedence level of transpose operators (bug #32533)
John W. Eaton <jwe@octave.org>
parents: 12483
diff changeset
956 | colon_expr1 ':' oper_expr
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
957 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
958 if (! ($$ = $1->append ($3)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
959 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
960 }
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 simple_expr : colon_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
964 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
965 | simple_expr LSHIFT simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
966 { $$ = make_binary_op (LSHIFT, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
967 | simple_expr RSHIFT simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
968 { $$ = make_binary_op (RSHIFT, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
969 | simple_expr EXPR_LT simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
970 { $$ = make_binary_op (EXPR_LT, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
971 | simple_expr EXPR_LE simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
972 { $$ = make_binary_op (EXPR_LE, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
973 | simple_expr EXPR_EQ simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
974 { $$ = make_binary_op (EXPR_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
975 | simple_expr EXPR_GE simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
976 { $$ = make_binary_op (EXPR_GE, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
977 | simple_expr EXPR_GT simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
978 { $$ = make_binary_op (EXPR_GT, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
979 | simple_expr EXPR_NE simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
980 { $$ = make_binary_op (EXPR_NE, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
981 | simple_expr EXPR_AND simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
982 { $$ = make_binary_op (EXPR_AND, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
983 | simple_expr EXPR_OR simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
984 { $$ = make_binary_op (EXPR_OR, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
985 | simple_expr EXPR_AND_AND simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
986 { $$ = make_boolean_op (EXPR_AND_AND, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
987 | simple_expr EXPR_OR_OR simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
988 { $$ = make_boolean_op (EXPR_OR_OR, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
989 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
990
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
991 // Arrange for the lexer to return CLOSE_BRACE for ']' by looking ahead
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
992 // one token for an assignment op.
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
993
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
994 assign_lhs : simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
995 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
996 $$ = new tree_argument_list ($1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
997 $$->mark_as_simple_assign_lhs ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
998 }
14533
e6aa044253eb Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents: 14512
diff changeset
999 | '[' arg_list opt_comma CLOSE_BRACE
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1000 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1001 $$ = $2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1002 lexer_flags.looking_at_matrix_or_assign_lhs = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1003 for (std::set<std::string>::const_iterator p = lexer_flags.pending_local_variables.begin ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1004 p != lexer_flags.pending_local_variables.end ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1005 p++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1006 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1007 symbol_table::force_variable (*p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1008 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1009 lexer_flags.pending_local_variables.clear ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1010 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1011 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1012
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1013 assign_expr : assign_lhs '=' expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1014 { $$ = make_assign_op ('=', $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1015 | assign_lhs ADD_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1016 { $$ = make_assign_op (ADD_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1017 | assign_lhs SUB_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1018 { $$ = make_assign_op (SUB_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1019 | assign_lhs MUL_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1020 { $$ = make_assign_op (MUL_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1021 | assign_lhs DIV_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1022 { $$ = make_assign_op (DIV_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1023 | assign_lhs LEFTDIV_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1024 { $$ = make_assign_op (LEFTDIV_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1025 | assign_lhs POW_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1026 { $$ = make_assign_op (POW_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1027 | assign_lhs LSHIFT_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1028 { $$ = make_assign_op (LSHIFT_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1029 | assign_lhs RSHIFT_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1030 { $$ = make_assign_op (RSHIFT_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1031 | assign_lhs EMUL_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1032 { $$ = make_assign_op (EMUL_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1033 | assign_lhs EDIV_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1034 { $$ = make_assign_op (EDIV_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1035 | assign_lhs ELEFTDIV_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1036 { $$ = make_assign_op (ELEFTDIV_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1037 | assign_lhs EPOW_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1038 { $$ = make_assign_op (EPOW_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1039 | assign_lhs AND_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1040 { $$ = make_assign_op (AND_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1041 | assign_lhs OR_EQ expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1042 { $$ = make_assign_op (OR_EQ, $1, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1043 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1044
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1045 expression : simple_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1046 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1047 | assign_expr
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1048 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1049 | anon_fcn_handle
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1050 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1051 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1052
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1053 // ================================================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1054 // Commands, declarations, and function definitions
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1055 // ================================================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1056
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1057 command : declaration
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1058 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1059 | select_command
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1060 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1061 | loop_command
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1062 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1063 | jump_command
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1064 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1065 | except_command
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1066 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1067 | function
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1068 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1069 | script_file
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1070 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1071 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1072
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1073 // =====================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1074 // Declaration statemnts
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1075 // =====================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1076
8701
1652e39b934e handle command names in declaration lists
John W. Eaton <jwe@octave.org>
parents: 8697
diff changeset
1077 parsing_decl_list
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1078 : // empty
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1079 { lexer_flags.looking_at_decl_list = true; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1080
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1081 declaration : GLOBAL parsing_decl_list decl1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1082 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1083 $$ = make_decl_command (GLOBAL, $1, $3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1084 lexer_flags.looking_at_decl_list = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1085 }
14294
9e3983c8963c deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents: 14293
diff changeset
1086 | PERSISTENT parsing_decl_list decl1
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1087 {
14294
9e3983c8963c deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents: 14293
diff changeset
1088 $$ = make_decl_command (PERSISTENT, $1, $3);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1089 lexer_flags.looking_at_decl_list = false;
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 decl1 : decl2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1094 { $$ = new tree_decl_init_list ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1095 | decl1 decl2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1096 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1097 $1->append ($2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1098 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1099 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1100 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1101
7634
ae90e05ad299 fix parameter list initializer bug
John W. Eaton <jwe@octave.org>
parents: 7587
diff changeset
1102 decl_param_init : // empty
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1103 { lexer_flags.looking_at_initializer_expression = true; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1104
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1105 decl2 : identifier
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1106 { $$ = new tree_decl_elt ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1107 | identifier '=' decl_param_init expression
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1108 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1109 lexer_flags.looking_at_initializer_expression = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1110 $$ = new tree_decl_elt ($1, $4);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1111 }
10206
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10188
diff changeset
1112 | magic_tilde
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10188
diff changeset
1113 {
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10188
diff changeset
1114 $$ = new tree_decl_elt ($1);
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10188
diff changeset
1115 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1116 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1117
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1118 // ====================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1119 // Selection statements
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1120 // ====================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1121
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1122 select_command : if_command
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1123 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1124 | switch_command
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1125 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1126 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1127
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1128 // ============
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1129 // If statement
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1130 // ============
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1131
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1132 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
1133 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1134 if (! ($$ = finish_if_command ($1, $3, $4, $2)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1135 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1136 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1137 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1138
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1139 if_cmd_list : if_cmd_list1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1140 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1141 | if_cmd_list1 else_clause
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 $1->append ($2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1144 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1145 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1146 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1147
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1148 if_cmd_list1 : expression opt_sep opt_list
11091
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
diff changeset
1149 {
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
diff changeset
1150 $1->mark_braindead_shortcircuit (curr_fcn_file_full_name);
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
diff changeset
1151
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
diff changeset
1152 $$ = start_if_command ($1, $3);
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
diff changeset
1153 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1154 | if_cmd_list1 elseif_clause
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1155 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1156 $1->append ($2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1157 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1158 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1159 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1160
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1161 elseif_clause : ELSEIF stash_comment opt_sep expression opt_sep opt_list
11091
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
diff changeset
1162 {
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
diff changeset
1163 $4->mark_braindead_shortcircuit (curr_fcn_file_full_name);
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
diff changeset
1164
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
diff changeset
1165 $$ = make_elseif_clause ($1, $4, $6, $2);
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
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 else_clause : ELSE stash_comment opt_sep opt_list
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1170 { $$ = new tree_if_clause ($4, $2); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1171 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1172
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1173 // ================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1174 // Switch statement
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1175 // ================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1176
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1177 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
1178 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1179 if (! ($$ = finish_switch_command ($1, $3, $5, $6, $2)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1180 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1181 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1182 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1183
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1184 case_list : // empty
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1185 { $$ = new tree_switch_case_list (); }
11317
2da532d0f41c accept otherwise clause in switch statement without preceding case statements
John W. Eaton <jwe@octave.org>
parents: 11258
diff changeset
1186 | default_case
2da532d0f41c accept otherwise clause in switch statement without preceding case statements
John W. Eaton <jwe@octave.org>
parents: 11258
diff changeset
1187 { $$ = new tree_switch_case_list ($1); }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1188 | case_list1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1189 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1190 | case_list1 default_case
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1191 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1192 $1->append ($2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1193 $$ = $1;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1194 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1195 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1196
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1197 case_list1 : switch_case
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1198 { $$ = new tree_switch_case_list ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1199 | case_list1 switch_case
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1200 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1201 $1->append ($2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1202 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1203 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1204 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1205
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1206 switch_case : CASE stash_comment opt_sep expression opt_sep opt_list
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1207 { $$ = make_switch_case ($1, $4, $6, $2); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1208 ;
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 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
1211 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1212 $$ = new tree_switch_case ($4, $2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1213 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1214 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1215
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1216 // =======
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1217 // Looping
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1218 // =======
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1219
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1220 loop_command : WHILE stash_comment expression opt_sep opt_list END
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1221 {
11091
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
diff changeset
1222 $3->mark_braindead_shortcircuit (curr_fcn_file_full_name);
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11060
diff changeset
1223
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1224 if (! ($$ = make_while_command ($1, $3, $5, $6, $2)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1225 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1226 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1227 | 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
1228 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1229 if (! ($$ = make_do_until_command ($5, $4, $6, $2)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1230 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1231 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1232 | 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
1233 {
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
1234 if (! ($$ = make_for_command (FOR, $1, $3, $5, 0,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1235 $7, $8, $2)))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1236 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1237 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1238 | 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
1239 {
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
1240 if (! ($$ = make_for_command (FOR, $1, $4, $6, 0,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1241 $9, $10, $2)))
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1242 ABORT_PARSE;
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1243 }
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1244 | PARFOR stash_comment assign_lhs '=' expression opt_sep opt_list END
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1245 {
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1246 if (! ($$ = make_for_command (PARFOR, $1, $3, $5,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1247 0, $7, $8, $2)))
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1248 ABORT_PARSE;
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1249 }
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1250 | 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
1251 {
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1252 if (! ($$ = make_for_command (PARFOR, $1, $4, $6,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
1253 $8, $11, $12, $2)))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1254 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1255 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1256 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1257
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1258 // =======
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1259 // Jumping
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1260 // =======
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1261
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1262 jump_command : BREAK
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1263 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1264 if (! ($$ = make_break_command ($1)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1265 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1266 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1267 | CONTINUE
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1268 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1269 if (! ($$ = make_continue_command ($1)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1270 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1271 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1272 | FUNC_RET
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1273 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1274 if (! ($$ = make_return_command ($1)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1275 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1276 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1277 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1278
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1279 // ==========
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1280 // Exceptions
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1281 // ==========
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1282
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1283 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
1284 stash_comment opt_sep opt_list END
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1285 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1286 if (! ($$ = make_unwind_command ($1, $4, $8, $9, $2, $6)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1287 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1288 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1289 | TRY stash_comment opt_sep opt_list CATCH
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1290 stash_comment opt_sep opt_list END
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1291 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1292 if (! ($$ = make_try_command ($1, $4, $8, $9, $2, $6)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1293 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1294 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1295 | TRY stash_comment opt_sep opt_list END
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1296 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1297 if (! ($$ = make_try_command ($1, $4, 0, $5, $2, 0)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1298 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1299 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1300 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1301
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1302 // ===========================================
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
1303 // Some 'subroutines' for function definitions
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1304 // ===========================================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1305
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1306 push_fcn_symtab : // empty
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 current_function_depth++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1309
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1310 if (max_function_depth < current_function_depth)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1311 max_function_depth = current_function_depth;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1312
14329
8d1ae996c122 also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents: 14294
diff changeset
1313 parser_symtab_context.push ();
8d1ae996c122 also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents: 14294
diff changeset
1314
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1315 symbol_table::set_scope (symbol_table::alloc_scope ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1316
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
1317 function_scopes.push_back (symbol_table::current_scope ());
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
1318
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1319 if (! reading_script_file && current_function_depth == 1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1320 && ! parsing_subfunctions)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1321 primary_fcn_scope = symbol_table::current_scope ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1322
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1323 if (reading_script_file && current_function_depth > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1324 yyerror ("nested functions not implemented in this context");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1325 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1326 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1327
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1328 // ===========================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1329 // List of function parameters
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1330 // ===========================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1331
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1332 param_list_beg : '('
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1333 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1334 lexer_flags.looking_at_parameter_list = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1335
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1336 if (lexer_flags.looking_at_function_handle)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1337 {
14329
8d1ae996c122 also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents: 14294
diff changeset
1338 parser_symtab_context.push ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1339 symbol_table::set_scope (symbol_table::alloc_scope ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1340 lexer_flags.looking_at_function_handle--;
13237
1bfca2bbea8b fix parsing of anonymous functions inside cell array lists.
John W. Eaton <jwe@octave.org>
parents: 13125
diff changeset
1341 lexer_flags.looking_at_anon_fcn_args = true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1342 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1343 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1344 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1345
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1346 param_list_end : ')'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1347 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1348 lexer_flags.looking_at_parameter_list = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1349 lexer_flags.looking_for_object_index = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1350 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1351 ;
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 param_list : param_list_beg param_list1 param_list_end
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 lexer_flags.quote_is_transpose = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1356 $$ = $2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1357 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1358 | param_list_beg error
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1359 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1360 yyerror ("invalid parameter list");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1361 $$ = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1362 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1363 }
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 param_list1 : // empty
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1367 { $$ = 0; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1368 | param_list2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1369 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1370 $1->mark_as_formal_parameters ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1371 if ($1->validate (tree_parameter_list::in))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1372 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1373 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1374 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1375 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1376 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1377
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1378 param_list2 : decl2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1379 { $$ = new tree_parameter_list ($1); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1380 | param_list2 ',' decl2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1381 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1382 $1->append ($3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1383 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1384 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1385 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1386
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1387 // ===================================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1388 // List of function return value names
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1389 // ===================================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1390
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1391 return_list : '[' ']'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1392 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1393 lexer_flags.looking_at_return_list = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1394 $$ = new tree_parameter_list ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1395 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1396 | return_list1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1397 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1398 lexer_flags.looking_at_return_list = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1399 if ($1->validate (tree_parameter_list::out))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1400 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1401 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1402 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1403 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1404 | '[' return_list1 ']'
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 lexer_flags.looking_at_return_list = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1407 if ($2->validate (tree_parameter_list::out))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1408 $$ = $2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1409 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1410 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1411 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1412 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1413
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1414 return_list1 : identifier
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1415 { $$ = new tree_parameter_list (new tree_decl_elt ($1)); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1416 | return_list1 ',' identifier
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1417 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1418 $1->append (new tree_decl_elt ($3));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1419 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1420 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1421 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1422
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
1423 // ===========
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
1424 // Script file
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
1425 // ===========
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
1426
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1427 script_file : SCRIPT_FILE opt_list END_OF_INPUT
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1428 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1429 tree_statement *end_of_script
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1430 = make_end ("endscript", input_line_number,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1431 current_input_column);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1432
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1433 make_script ($2, end_of_script);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1434
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1435 $$ = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1436 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1437 ;
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
1438
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
1439 // =============
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
1440 // Function file
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
1441 // =============
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
1442
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
1443 function_file : FUNCTION_FILE function_list opt_sep END_OF_INPUT
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1444 { $$ = 0; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1445 ;
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
1446
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
1447 function_list : function
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1448 | function_list sep function
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1449 ;
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
1450
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1451 // ===================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1452 // Function definition
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1453 // ===================
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1454
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1455 function_beg : push_fcn_symtab FCN stash_comment
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1456 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1457 $$ = $3;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1458
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1459 if (reading_classdef_file || lexer_flags.parsing_classdef)
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1460 lexer_flags.maybe_classdef_get_set_method = true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1461 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1462 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1463
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1464 function : function_beg function1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1465 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1466 $$ = finish_function (0, $2, $1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1467 recover_from_parsing_function ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1468 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1469 | function_beg return_list '=' function1
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 $$ = finish_function ($2, $4, $1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1472 recover_from_parsing_function ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1473 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1474 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1475
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1476 fcn_name : identifier
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1477 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1478 std::string id_name = $1->name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1479
11464
21b5284fa78d avoid error when parsing nested functions
John W. Eaton <jwe@octave.org>
parents: 11461
diff changeset
1480 lexer_flags.parsed_function_name.top () = true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1481 lexer_flags.maybe_classdef_get_set_method = false;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1482
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1483 $$ = $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1484 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1485 | GET '.' identifier
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1486 {
14293
71a198cca35b improve parsing of classdef methods
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
1487 lexer_flags.parsed_function_name.top () = true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1488 lexer_flags.maybe_classdef_get_set_method = false;
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1489 lexer_flags.parsing_classdef_get_method = true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1490 $$ = $3;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1491 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1492 | SET '.' identifier
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1493 {
14293
71a198cca35b improve parsing of classdef methods
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
1494 lexer_flags.parsed_function_name.top () = true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1495 lexer_flags.maybe_classdef_get_set_method = false;
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1496 lexer_flags.parsing_classdef_set_method = true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1497 $$ = $3;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1498 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1499 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1500
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1501 function1 : fcn_name function2
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1502 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1503 std::string fname = $1->name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1504
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1505 delete $1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1506
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1507 if (! ($$ = frob_function (fname, $2)))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1508 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1509 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1510 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1511
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1512 function2 : param_list opt_sep opt_list function_end
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1513 { $$ = start_function ($1, $3, $4); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1514 | opt_sep opt_list function_end
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1515 { $$ = start_function (0, $2, $3); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1516 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1517
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1518 function_end : END
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1519 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1520 endfunction_found = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1521 if (end_token_ok ($1, token::function_end))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1522 $$ = make_end ("endfunction", $1->line (), $1->column ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1523 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1524 ABORT_PARSE;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1525 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1526 | END_OF_INPUT
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1527 {
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
1528 // A lot of tests are based on the assumption that this is OK
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1529 // if (reading_script_file)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1530 // {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1531 // yyerror ("function body open at end of script");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1532 // YYABORT;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1533 // }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1534
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1535 if (endfunction_found)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1536 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1537 yyerror ("inconsistent function endings -- "
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1538 "if one function is explicitly ended, "
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1539 "so must all the others");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1540 YYABORT;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1541 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1542
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1543 if (! (reading_fcn_file || reading_script_file
10130
0c3609dd34cf oct-parse.yy (eval_string): save and set reading_{script,fcn,classdef}_file vars
John W. Eaton <jwe@octave.org>
parents: 10067
diff changeset
1544 || get_input_from_eval_string))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1545 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1546 yyerror ("function body open at end of input");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1547 YYABORT;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1548 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1549
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1550 if (reading_classdef_file)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1551 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1552 yyerror ("classdef body open at end of input");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1553 YYABORT;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1554 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1555
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1556 $$ = make_end ("endfunction", input_line_number,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1557 current_input_column);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1558 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1559 ;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1560
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1561 // =============
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1562 // Classdef file
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1563 // =============
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1564
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1565 classdef_file : CLASSDEF_FILE classdef opt_sep END_OF_INPUT
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1566 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1567 classdef_object = $2;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1568 $$ = 0;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1569 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1570 ;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1571
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1572 // ========
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1573 // Classdef
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1574 // ========
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1575
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1576 classdef_beg : CLASSDEF
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1577 {
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1578 if (! reading_classdef_file)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1579 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1580 yyerror ("classdef must appear inside a file containing only a class definition");
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1581 YYABORT;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1582 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1583
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1584 lexer_flags.parsing_classdef = true;
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1585 $$ = $1;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1586 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1587 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1588
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1589 classdef : classdef_beg stash_comment opt_attr_list identifier opt_superclass_list opt_sep class_body opt_sep END
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1590 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1591 lexer_flags.parsing_classdef = false;
15895
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
1592 if (! ($$ = make_classdef ($1, $3, $4, $5, $7, $9, $2)))
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
1593 ABORT_PARSE;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1594 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1595 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1596
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1597 opt_attr_list : // empty
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1598 { $$ = 0; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1599 | '(' attr_list ')'
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1600 { $$ = $2; }
10315
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 attr_list : attr
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1604 { $$ = new tree_classdef_attribute_list ($1); }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1605 | attr_list ',' attr
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1606 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1607 $1->append ($3);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1608 $$ = $1;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1609 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1610 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1611
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1612 attr : identifier
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1613 { $$ = new tree_classdef_attribute ($1); }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1614 | identifier '=' decl_param_init expression
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1615 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1616 lexer_flags.looking_at_initializer_expression = false;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1617 $$ = new tree_classdef_attribute ($1, $4);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1618 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1619 | EXPR_NOT identifier
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1620 { $$ = new tree_classdef_attribute ($2, false); }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1621 ;
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1622
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1623 opt_superclass_list
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1624 : // empty
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1625 { $$ = 0; }
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1626 | superclass_list
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1627 { $$ = $1; }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1628 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1629
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1630 superclass_list : EXPR_LT superclass
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1631 { $$ = new tree_classdef_superclass_list ($2); }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1632 | superclass_list EXPR_AND superclass
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1633 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1634 $1->append ($3);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1635 $$ = $1;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1636 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1637 ;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1638
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1639 superclass : identifier
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1640 { $$ = new tree_classdef_superclass ($1); }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1641 | identifier '.' identifier
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1642 { $$ = new tree_classdef_superclass ($3, $1); }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1643 ;
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 class_body : properties_block
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1646 { $$ = new tree_classdef_body ($1); }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1647 | methods_block
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1648 { $$ = new tree_classdef_body ($1); }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1649 | events_block
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1650 { $$ = new tree_classdef_body ($1); }
13249
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1651 | enum_block
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1652 { $$ = new tree_classdef_body ($1); }
13250
f6bbdea030b2 use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents: 13249
diff changeset
1653 | class_body opt_sep properties_block
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1654 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1655 $1->append ($3);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1656 $$ = $1;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1657 }
13250
f6bbdea030b2 use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents: 13249
diff changeset
1658 | class_body opt_sep methods_block
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1659 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1660 $1->append ($3);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1661 $$ = $1;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1662 }
13250
f6bbdea030b2 use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents: 13249
diff changeset
1663 | class_body opt_sep events_block
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1664 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1665 $1->append ($3);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1666 $$ = $1;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1667 }
13250
f6bbdea030b2 use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents: 13249
diff changeset
1668 | class_body opt_sep enum_block
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1669 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1670 $1->append ($3);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1671 $$ = $1;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1672 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1673 ;
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1674
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1675 properties_block
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1676 : PROPERTIES stash_comment opt_attr_list opt_sep property_list opt_sep END
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1677 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1678 if (! ($$ = make_classdef_properties_block ($1, $3, $5, $7, $2)))
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1679 ABORT_PARSE;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1680 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1681 ;
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1682
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1683 property_list
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1684 : class_property
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1685 { $$ = new tree_classdef_property_list ($1); }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1686 | property_list opt_sep class_property
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1687 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1688 $1->append ($3);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1689 $$ = $1;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1690 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1691 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1692
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1693 class_property : identifier
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1694 { $$ = new tree_classdef_property ($1); }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1695 | identifier '=' decl_param_init expression ';'
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1696 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1697 lexer_flags.looking_at_initializer_expression = false;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1698 $$ = new tree_classdef_property ($1, $4);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1699 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1700 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1701
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1702 methods_block : METHODS stash_comment opt_attr_list opt_sep methods_list opt_sep END
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1703 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1704 if (! ($$ = make_classdef_methods_block ($1, $3, $5, $7, $2)))
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1705 ABORT_PARSE;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1706 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1707 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1708
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1709 methods_list : function
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1710 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1711 octave_value fcn;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1712 if ($1)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1713 fcn = $1->function ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1714 delete $1;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1715 $$ = new tree_classdef_methods_list (fcn);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1716 }
13250
f6bbdea030b2 use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents: 13249
diff changeset
1717 | methods_list opt_sep function
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1718 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1719 octave_value fcn;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1720 if ($3)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1721 fcn = $3->function ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1722 delete $3;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1723
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1724 $1->append (fcn);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1725 $$ = $1;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1726 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1727 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1728
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1729 events_block : EVENTS stash_comment opt_attr_list opt_sep events_list opt_sep END
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1730 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1731 if (! ($$ = make_classdef_events_block ($1, $3, $5, $7, $2)))
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1732 ABORT_PARSE;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1733 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1734 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1735
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1736 events_list : class_event
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1737 { $$ = new tree_classdef_events_list ($1); }
13250
f6bbdea030b2 use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents: 13249
diff changeset
1738 | events_list opt_sep class_event
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1739 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1740 $1->append ($3);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1741 $$ = $1;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1742 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1743 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1744
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1745 class_event : identifier
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1746 { $$ = new tree_classdef_event ($1); }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1747 ;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1748
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1749 enum_block : ENUMERATION stash_comment opt_attr_list opt_sep enum_list opt_sep END
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1750 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1751 if (! ($$ = make_classdef_enum_block ($1, $3, $5, $7, $2)))
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1752 ABORT_PARSE;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1753 }
13249
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1754 ;
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1755
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1756 enum_list : class_enum
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1757 { $$ = new tree_classdef_enum_list ($1); }
13250
f6bbdea030b2 use opt_sep instead of literal '\n' in parser rules for classdef
John W. Eaton <jwe@octave.org>
parents: 13249
diff changeset
1758 | enum_list opt_sep class_enum
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1759 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1760 $1->append ($3);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1761 $$ = $1;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1762 }
13249
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1763 ;
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1764
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1765 class_enum : identifier '(' expression ')'
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
1766 { $$ = new tree_classdef_enum ($1, $3); }
13249
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1767 ;
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1768
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1769 // =============
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1770 // Miscellaneous
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1771 // =============
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
1772
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1773 stash_comment : // empty
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1774 { $$ = octave_comment_buffer::get_comment (); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1775 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1776
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1777 parse_error : LEXICAL_ERROR
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1778 { yyerror ("parse error"); }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1779 | error
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1780 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1781
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1782 sep_no_nl : ','
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1783 { $$ = ','; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1784 | ';'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1785 { $$ = ';'; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1786 | sep_no_nl ','
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1787 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1788 | sep_no_nl ';'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1789 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1790 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1791
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1792 opt_sep_no_nl : // empty
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1793 { $$ = 0; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1794 | sep_no_nl
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1795 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1796 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1797
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1798 sep : ','
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1799 { $$ = ','; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1800 | ';'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1801 { $$ = ';'; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1802 | '\n'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1803 { $$ = '\n'; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1804 | sep ','
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1805 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1806 | sep ';'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1807 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1808 | sep '\n'
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1809 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1810 ;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1811
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1812 opt_sep : // empty
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1813 { $$ = 0; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1814 | sep
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1815 { $$ = $1; }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1816 ;
2525
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
1817
14533
e6aa044253eb Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents: 14512
diff changeset
1818 opt_comma : // empty
e6aa044253eb Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents: 14512
diff changeset
1819 { $$ = 0; }
e6aa044253eb Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents: 14512
diff changeset
1820 | ','
e6aa044253eb Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents: 14512
diff changeset
1821 { $$ = ','; }
e6aa044253eb Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents: 14512
diff changeset
1822 ;
e6aa044253eb Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents: 14512
diff changeset
1823
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1824 %%
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1825
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
1826 // Generic error messages.
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
1827
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1828 static void
2805
68e6d0c93fc8 [project @ 1997-03-11 04:52:44 by jwe]
jwe
parents: 2791
diff changeset
1829 yyerror (const char *s)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1830 {
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1831 int err_col = current_input_column - 1;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1832
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5760
diff changeset
1833 std::ostringstream output_buf;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1834
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1835 if (reading_fcn_file || reading_script_file || reading_classdef_file)
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 991
diff changeset
1836 output_buf << "parse error near line " << input_line_number
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1837 << " of file " << curr_fcn_file_full_name;
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 991
diff changeset
1838 else
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 991
diff changeset
1839 output_buf << "parse error:";
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 578
diff changeset
1840
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 991
diff changeset
1841 if (s && strcmp (s, "parse error") != 0)
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 991
diff changeset
1842 output_buf << "\n\n " << s;
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 991
diff changeset
1843
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 991
diff changeset
1844 output_buf << "\n\n";
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1845
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1743
diff changeset
1846 if (! current_input_line.empty ())
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1847 {
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1743
diff changeset
1848 size_t len = current_input_line.length ();
1060
8c1a25cdfa81 [project @ 1995-01-23 00:10:03 by jwe]
jwe
parents: 1054
diff changeset
1849
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1743
diff changeset
1850 if (current_input_line[len-1] == '\n')
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1743
diff changeset
1851 current_input_line.resize (len-1);
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 991
diff changeset
1852
4051
b79da8779a0e [project @ 2002-08-17 19:38:32 by jwe]
jwe
parents: 4044
diff changeset
1853 // Print the line, maybe with a pointer near the error token.
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 991
diff changeset
1854
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1743
diff changeset
1855 output_buf << ">>> " << current_input_line << "\n";
1060
8c1a25cdfa81 [project @ 1995-01-23 00:10:03 by jwe]
jwe
parents: 1054
diff changeset
1856
8c1a25cdfa81 [project @ 1995-01-23 00:10:03 by jwe]
jwe
parents: 1054
diff changeset
1857 if (err_col == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1858 err_col = len;
1060
8c1a25cdfa81 [project @ 1995-01-23 00:10:03 by jwe]
jwe
parents: 1054
diff changeset
1859
8c1a25cdfa81 [project @ 1995-01-23 00:10:03 by jwe]
jwe
parents: 1054
diff changeset
1860 for (int i = 0; i < err_col + 3; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1861 output_buf << " ";
1060
8c1a25cdfa81 [project @ 1995-01-23 00:10:03 by jwe]
jwe
parents: 1054
diff changeset
1862
8c1a25cdfa81 [project @ 1995-01-23 00:10:03 by jwe]
jwe
parents: 1054
diff changeset
1863 output_buf << "^";
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1864 }
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 991
diff changeset
1865
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5760
diff changeset
1866 output_buf << "\n";
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5760
diff changeset
1867
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5760
diff changeset
1868 std::string msg = output_buf.str ();
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5760
diff changeset
1869
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5760
diff changeset
1870 parse_error ("%s", msg.c_str ());
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1871 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1872
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
1873 // Error mesages for mismatched end tokens.
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
1874
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1875 static void
2805
68e6d0c93fc8 [project @ 1997-03-11 04:52:44 by jwe]
jwe
parents: 2791
diff changeset
1876 end_error (const char *type, token::end_tok_type ettype, int l, int c)
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1877 {
2805
68e6d0c93fc8 [project @ 1997-03-11 04:52:44 by jwe]
jwe
parents: 2791
diff changeset
1878 static const char *fmt
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
1879 = "'%s' command matched by '%s' near line %d column %d";
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1880
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1881 switch (ettype)
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1882 {
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1883 case token::simple_end:
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1884 error (fmt, type, "end", l, c);
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1885 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
1886
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1887 case token::for_end:
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1888 error (fmt, type, "endfor", l, c);
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1889 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
1890
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1891 case token::function_end:
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1892 error (fmt, type, "endfunction", l, c);
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1893 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
1894
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1895 case token::classdef_end:
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1896 error (fmt, type, "endclassdef", l, c);
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1897 break;
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
1898
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1899 case token::if_end:
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1900 error (fmt, type, "endif", l, c);
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1901 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
1902
3233
98d0ee053ba4 [project @ 1999-01-27 20:23:40 by jwe]
jwe
parents: 3216
diff changeset
1903 case token::switch_end:
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1904 error (fmt, type, "endswitch", l, c);
3233
98d0ee053ba4 [project @ 1999-01-27 20:23:40 by jwe]
jwe
parents: 3216
diff changeset
1905 break;
98d0ee053ba4 [project @ 1999-01-27 20:23:40 by jwe]
jwe
parents: 3216
diff changeset
1906
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1907 case token::while_end:
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1908 error (fmt, type, "endwhile", l, c);
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1909 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
1910
5400
c7e3cf2fce3e [project @ 2005-07-05 15:01:32 by jwe]
jwe
parents: 5397
diff changeset
1911 case token::try_catch_end:
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1912 error (fmt, type, "end_try_catch", l, c);
5400
c7e3cf2fce3e [project @ 2005-07-05 15:01:32 by jwe]
jwe
parents: 5397
diff changeset
1913 break;
c7e3cf2fce3e [project @ 2005-07-05 15:01:32 by jwe]
jwe
parents: 5397
diff changeset
1914
1371
766af9ca8edb [project @ 1995-09-06 21:36:02 by jwe]
jwe
parents: 1351
diff changeset
1915 case token::unwind_protect_end:
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1916 error (fmt, type, "end_unwind_protect", l, c);
1371
766af9ca8edb [project @ 1995-09-06 21:36:02 by jwe]
jwe
parents: 1351
diff changeset
1917 break;
766af9ca8edb [project @ 1995-09-06 21:36:02 by jwe]
jwe
parents: 1351
diff changeset
1918
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1919 default:
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1920 panic_impossible ();
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1921 break;
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1922 }
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1923 }
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1924
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
1925 // Check to see that end tokens are properly matched.
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
1926
2857
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
1927 static bool
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
1928 end_token_ok (token *tok, token::end_tok_type expected)
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1929 {
2857
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
1930 bool retval = true;
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
1931
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1932 token::end_tok_type ettype = tok->ettype ();
2857
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
1933
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1934 if (ettype != expected && ettype != token::simple_end)
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1935 {
2857
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
1936 retval = false;
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
1937
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1938 yyerror ("parse error");
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1939
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1940 int l = tok->line ();
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1941 int c = tok->column ();
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1942
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1943 switch (expected)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1944 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1945 case token::classdef_end:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1946 end_error ("classdef", ettype, l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1947 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1948
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1949 case token::for_end:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1950 end_error ("for", ettype, l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1951 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1952
13249
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1953 case token::enumeration_end:
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1954 end_error ("enumeration", ettype, l, c);
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1955 break;
7861a5fd3479 accept enumeration keyword
John W. Eaton <jwe@octave.org>
parents: 13246
diff changeset
1956
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1957 case token::function_end:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1958 end_error ("function", ettype, l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1959 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1960
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1961 case token::if_end:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1962 end_error ("if", ettype, l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1963 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1964
13246
0c69a564f2be additional parfor changes
John W. Eaton <jwe@octave.org>
parents: 13245
diff changeset
1965 case token::parfor_end:
0c69a564f2be additional parfor changes
John W. Eaton <jwe@octave.org>
parents: 13245
diff changeset
1966 end_error ("parfor", ettype, l, c);
0c69a564f2be additional parfor changes
John W. Eaton <jwe@octave.org>
parents: 13245
diff changeset
1967 break;
0c69a564f2be additional parfor changes
John W. Eaton <jwe@octave.org>
parents: 13245
diff changeset
1968
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1969 case token::try_catch_end:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1970 end_error ("try", ettype, l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1971 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1972
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1973 case token::switch_end:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1974 end_error ("switch", ettype, l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1975 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1976
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1977 case token::unwind_protect_end:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1978 end_error ("unwind_protect", ettype, l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1979 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1980
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1981 case token::while_end:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1982 end_error ("while", ettype, l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1983 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1984
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1985 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1986 panic_impossible ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1987 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
1988 }
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1989 }
2857
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
1990
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
1991 return retval;
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1992 }
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 118
diff changeset
1993
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
1994 // Maybe print a warning if an assignment expression is used as the
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
1995 // test in a logical expression.
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
1996
496
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1997 static void
e7c5b23b34d3 [project @ 1994-07-06 15:02:26 by jwe]
jwe
parents: 482
diff changeset
1998 maybe_warn_assign_as_truth_value (tree_expression *expr)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1999 {
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
2000 if (expr->is_assignment_expression ()
2961
8a77d52c9d02 [project @ 1997-05-12 01:36:04 by jwe]
jwe
parents: 2960
diff changeset
2001 && expr->paren_count () < 2)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2002 {
8974
fde2a916b2ac include line and file info in parser warnings
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
2003 if (curr_fcn_file_full_name.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2004 warning_with_id
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2005 ("Octave:assign-as-truth-value",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2006 "suggest parenthesis around assignment used as truth value");
8974
fde2a916b2ac include line and file info in parser warnings
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
2007 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2008 warning_with_id
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2009 ("Octave:assign-as-truth-value",
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
2010 "suggest parenthesis around assignment used as truth value near line %d, column %d in file '%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2011 expr->line (), expr->column (), curr_fcn_file_full_name.c_str ());
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2012 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2013 }
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2014
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2015 // Maybe print a warning about switch labels that aren't constants.
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2016
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2017 static void
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2018 maybe_warn_variable_switch_label (tree_expression *expr)
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2019 {
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
2020 if (! expr->is_constant ())
8974
fde2a916b2ac include line and file info in parser warnings
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
2021 {
fde2a916b2ac include line and file info in parser warnings
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
2022 if (curr_fcn_file_full_name.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2023 warning_with_id ("Octave:variable-switch-label",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2024 "variable switch label");
8974
fde2a916b2ac include line and file info in parser warnings
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
2025 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2026 warning_with_id
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2027 ("Octave:variable-switch-label",
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
2028 "variable switch label near line %d, column %d in file '%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2029 expr->line (), expr->column (), curr_fcn_file_full_name.c_str ());
8974
fde2a916b2ac include line and file info in parser warnings
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
2030 }
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2031 }
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2032
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2033 static tree_expression *
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2034 fold (tree_binary_expression *e)
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2035 {
3110
fe2d1ae8926b [project @ 1997-11-21 02:11:19 by jwe]
jwe
parents: 3099
diff changeset
2036 tree_expression *retval = e;
fe2d1ae8926b [project @ 1997-11-21 02:11:19 by jwe]
jwe
parents: 3099
diff changeset
2037
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2038 unwind_protect frame;
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2039
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2040 frame.protect_var (error_state);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2041 frame.protect_var (warning_state);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2042
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2043 frame.protect_var (discard_error_messages);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2044 frame.protect_var (discard_warning_messages);
4452
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4426
diff changeset
2045
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3802
diff changeset
2046 discard_error_messages = true;
4452
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4426
diff changeset
2047 discard_warning_messages = true;
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2048
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2049 tree_expression *op1 = e->lhs ();
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2050 tree_expression *op2 = e->rhs ();
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2051
13844
e48529b3dbd4 eliminate warnings for changes in operator precedence made years ago
John W. Eaton <jwe@octave.org>
parents: 13250
diff changeset
2052 if (op1->is_constant () && op2->is_constant ())
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2053 {
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2054 octave_value tmp = e->rvalue1 ();
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2055
3489
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3485
diff changeset
2056 if (! (error_state || warning_state))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2057 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2058 tree_constant *tc_retval
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2059 = new tree_constant (tmp, op1->line (), op1->column ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2060
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2061 std::ostringstream buf;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2062
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2063 tree_print_code tpc (buf);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2064
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2065 e->accept (tpc);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2066
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2067 tc_retval->stash_original_text (buf.str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2068
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2069 delete e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2070
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2071 retval = tc_retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2072 }
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2073 }
3110
fe2d1ae8926b [project @ 1997-11-21 02:11:19 by jwe]
jwe
parents: 3099
diff changeset
2074
3292
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2075 return retval;
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2076 }
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2077
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2078 static tree_expression *
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2079 fold (tree_unary_expression *e)
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2080 {
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2081 tree_expression *retval = e;
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2082
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2083 unwind_protect frame;
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2084
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2085 frame.protect_var (error_state);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2086 frame.protect_var (warning_state);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2087
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2088 frame.protect_var (discard_error_messages);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2089 frame.protect_var (discard_warning_messages);
4452
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4426
diff changeset
2090
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3802
diff changeset
2091 discard_error_messages = true;
4452
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4426
diff changeset
2092 discard_warning_messages = true;
3292
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2093
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2094 tree_expression *op = e->operand ();
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2095
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2096 if (op->is_constant ())
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2097 {
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2098 octave_value tmp = e->rvalue1 ();
3292
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2099
3489
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3485
diff changeset
2100 if (! (error_state || warning_state))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2101 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2102 tree_constant *tc_retval
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2103 = new tree_constant (tmp, op->line (), op->column ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2104
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2105 std::ostringstream buf;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2106
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2107 tree_print_code tpc (buf);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2108
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2109 e->accept (tpc);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2110
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2111 tc_retval->stash_original_text (buf.str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2112
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2113 delete e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2114
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2115 retval = tc_retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2116 }
3292
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2117 }
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2118
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2119 return retval;
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2120 }
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2121
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2122 // Finish building a range.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2123
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2124 static tree_expression *
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2125 finish_colon_expression (tree_colon_expression *e)
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2126 {
3110
fe2d1ae8926b [project @ 1997-11-21 02:11:19 by jwe]
jwe
parents: 3099
diff changeset
2127 tree_expression *retval = e;
fe2d1ae8926b [project @ 1997-11-21 02:11:19 by jwe]
jwe
parents: 3099
diff changeset
2128
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2129 unwind_protect frame;
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2130
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2131 frame.protect_var (error_state);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2132 frame.protect_var (warning_state);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2133
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2134 frame.protect_var (discard_error_messages);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
2135 frame.protect_var (discard_warning_messages);
4452
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4426
diff changeset
2136
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3802
diff changeset
2137 discard_error_messages = true;
4452
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4426
diff changeset
2138 discard_warning_messages = true;
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2139
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2140 tree_expression *base = e->base ();
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2141 tree_expression *limit = e->limit ();
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2142 tree_expression *incr = e->increment ();
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2143
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2144 if (base)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2145 {
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2146 if (limit)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2147 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2148 if (base->is_constant () && limit->is_constant ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2149 && (! incr || (incr && incr->is_constant ())))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2150 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2151 octave_value tmp = e->rvalue1 ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2152
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2153 if (! (error_state || warning_state))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2154 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2155 tree_constant *tc_retval
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2156 = new tree_constant (tmp, base->line (), base->column ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2157
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2158 std::ostringstream buf;
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 tree_print_code tpc (buf);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2161
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2162 e->accept (tpc);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2163
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2164 tc_retval->stash_original_text (buf.str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2165
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2166 delete e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2167
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2168 retval = tc_retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2169 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2170 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2171 }
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2172 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2173 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2174 e->preserve_base ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2175 delete e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2176
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2177 // FIXME -- need to attempt constant folding here
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2178 // too (we need a generic way to do that).
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2179 retval = base;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2180 }
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2181 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2182
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2183 return retval;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2184 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2185
1607
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2186 // Make a constant.
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2187
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2188 static tree_constant *
1607
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2189 make_constant (int op, token *tok_val)
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2190 {
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2191 int l = tok_val->line ();
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2192 int c = tok_val->column ();
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2193
3216
60a89a69a70a [project @ 1998-11-11 20:47:03 by jwe]
jwe
parents: 3208
diff changeset
2194 tree_constant *retval = 0;
1607
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2195
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2196 switch (op)
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2197 {
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2198 case NUM:
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2199 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2200 octave_value tmp (tok_val->number ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2201 retval = new tree_constant (tmp, l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2202 retval->stash_original_text (tok_val->text_rep ());
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2203 }
1607
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2204 break;
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2205
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2206 case IMAG_NUM:
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2207 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2208 octave_value tmp (Complex (0.0, tok_val->number ()));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2209 retval = new tree_constant (tmp, l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2210 retval->stash_original_text (tok_val->text_rep ());
1607
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2211 }
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2212 break;
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2213
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5189
diff changeset
2214 case DQ_STRING:
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5189
diff changeset
2215 case SQ_STRING:
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2216 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2217 std::string txt = tok_val->text ();
7699
27a5f578750c make_constant: handle escape sequences in dq-strings
John W. Eaton <jwe@octave.org>
parents: 7690
diff changeset
2218
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
2219 char delim = op == DQ_STRING ? '"' : '\'';
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
2220 octave_value tmp (txt, delim);
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
2221
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
2222 if (txt.empty ())
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
2223 {
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
2224 if (op == DQ_STRING)
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
2225 tmp = octave_null_str::instance;
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
2226 else
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
2227 tmp = octave_null_sq_str::instance;
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
2228 }
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8064
diff changeset
2229
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2230 retval = new tree_constant (tmp, l, c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2231
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2232 if (op == DQ_STRING)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2233 txt = undo_string_escapes (txt);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2234
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2235 // FIXME -- maybe this should also be handled by
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2236 // tok_val->text_rep () for character strings?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2237 retval->stash_original_text (delim + txt + delim);
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2238 }
1607
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2239 break;
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2240
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2241 default:
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2242 panic_impossible ();
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2243 break;
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2244 }
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2245
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2246 return retval;
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2247 }
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
2248
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2249 // Make a function handle.
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2250
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2251 static tree_fcn_handle *
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2252 make_fcn_handle (token *tok_val)
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2253 {
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2254 int l = tok_val->line ();
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2255 int c = tok_val->column ();
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2256
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2257 tree_fcn_handle *retval = new tree_fcn_handle (tok_val->text (), l, c);
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2258
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2259 return retval;
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2260 }
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
2261
4935
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2262 // Make an anonymous function handle.
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2263
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5848
diff changeset
2264 static tree_anon_fcn_handle *
4935
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2265 make_anon_fcn_handle (tree_parameter_list *param_list, tree_statement *stmt)
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2266 {
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5774
diff changeset
2267 // FIXME -- need to get these from the location of the @ symbol.
13125
34a49d076155 Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents: 13029
diff changeset
2268 int l = input_line_number;
34a49d076155 Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents: 13029
diff changeset
2269 int c = current_input_column;
4935
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2270
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2271 tree_parameter_list *ret_list = 0;
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2272
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
2273 symbol_table::scope_id fcn_scope = symbol_table::current_scope ();
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5848
diff changeset
2274
14329
8d1ae996c122 also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents: 14294
diff changeset
2275 if (parser_symtab_context.empty ())
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5848
diff changeset
2276 panic_impossible ();
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5848
diff changeset
2277
14329
8d1ae996c122 also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents: 14294
diff changeset
2278 parser_symtab_context.pop ();
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5848
diff changeset
2279
7351
8470a6b0b769 [project @ 2008-01-07 17:57:24 by jwe]
jwe
parents: 7336
diff changeset
2280 stmt->set_print_flag (false);
4935
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2281
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2282 tree_statement_list *body = new tree_statement_list (stmt);
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2283
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2284 body->mark_as_anon_function_body ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2285
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5848
diff changeset
2286 tree_anon_fcn_handle *retval
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
2287 = new tree_anon_fcn_handle (param_list, ret_list, body, fcn_scope, l, c);
13125
34a49d076155 Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents: 13029
diff changeset
2288 // FIXME: Stash the filename. This does not work and produces
34a49d076155 Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents: 13029
diff changeset
2289 // errors when executed.
34a49d076155 Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents: 13029
diff changeset
2290 //retval->stash_file_name (curr_fcn_file_name);
4935
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2291
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2292 return retval;
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2293 }
4fc993a4e072 [project @ 2004-08-06 03:17:12 by jwe]
jwe
parents: 4930
diff changeset
2294
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
2295 // Build a binary expression.
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
2296
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2297 static tree_expression *
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2298 make_binary_op (int op, tree_expression *op1, token *tok_val,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2299 tree_expression *op2)
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2300 {
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2301 octave_value::binary_op t = octave_value::unknown_binary_op;
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2302
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2303 switch (op)
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2304 {
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2305 case POW:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2306 t = octave_value::op_pow;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2307 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2308
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2309 case EPOW:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2310 t = octave_value::op_el_pow;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2311 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2312
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2313 case '+':
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2314 t = octave_value::op_add;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2315 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2316
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2317 case '-':
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2318 t = octave_value::op_sub;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2319 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2320
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2321 case '*':
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2322 t = octave_value::op_mul;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2323 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2324
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2325 case '/':
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2326 t = octave_value::op_div;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2327 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2328
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2329 case EMUL:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2330 t = octave_value::op_el_mul;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2331 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2332
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2333 case EDIV:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2334 t = octave_value::op_el_div;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2335 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2336
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2337 case LEFTDIV:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2338 t = octave_value::op_ldiv;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2339 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2340
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2341 case ELEFTDIV:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2342 t = octave_value::op_el_ldiv;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2343 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2344
2899
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2345 case LSHIFT:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2346 t = octave_value::op_lshift;
2899
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2347 break;
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2348
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2349 case RSHIFT:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2350 t = octave_value::op_rshift;
2899
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2351 break;
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2352
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2353 case EXPR_LT:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2354 t = octave_value::op_lt;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2355 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2356
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2357 case EXPR_LE:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2358 t = octave_value::op_le;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2359 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2360
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2361 case EXPR_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2362 t = octave_value::op_eq;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2363 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2364
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2365 case EXPR_GE:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2366 t = octave_value::op_ge;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2367 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2368
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2369 case EXPR_GT:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2370 t = octave_value::op_gt;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2371 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2372
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2373 case EXPR_NE:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2374 t = octave_value::op_ne;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2375 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2376
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2377 case EXPR_AND:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2378 t = octave_value::op_el_and;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2379 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2380
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2381 case EXPR_OR:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2382 t = octave_value::op_el_or;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2383 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2384
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2385 default:
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2386 panic_impossible ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2387 break;
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2388 }
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2389
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2390 int l = tok_val->line ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2391 int c = tok_val->column ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2392
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2393 tree_binary_expression *e
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents: 7787
diff changeset
2394 = maybe_compound_binary_expression (op1, op2, l, c, t);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2395
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2396 return fold (e);
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2397 }
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2398
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2399 // Build a boolean expression.
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
2400
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2401 static tree_expression *
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2402 make_boolean_op (int op, tree_expression *op1, token *tok_val,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2403 tree_expression *op2)
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2404 {
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2405 tree_boolean_expression::type t;
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2406
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2407 switch (op)
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2408 {
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2409 case EXPR_AND_AND:
2805
68e6d0c93fc8 [project @ 1997-03-11 04:52:44 by jwe]
jwe
parents: 2791
diff changeset
2410 t = tree_boolean_expression::bool_and;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2411 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2412
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2413 case EXPR_OR_OR:
2805
68e6d0c93fc8 [project @ 1997-03-11 04:52:44 by jwe]
jwe
parents: 2791
diff changeset
2414 t = tree_boolean_expression::bool_or;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2415 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2416
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2417 default:
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2418 panic_impossible ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2419 break;
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2420 }
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2421
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2422 int l = tok_val->line ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2423 int c = tok_val->column ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2424
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2425 tree_boolean_expression *e
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2426 = new tree_boolean_expression (op1, op2, l, c, t);
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2427
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
2428 return fold (e);
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2429 }
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2430
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2431 // Build a prefix expression.
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
2432
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2433 static tree_expression *
2960
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2434 make_prefix_op (int op, tree_expression *op1, token *tok_val)
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2435 {
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3195
diff changeset
2436 octave_value::unary_op t = octave_value::unknown_unary_op;
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2437
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2438 switch (op)
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2439 {
2960
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2440 case EXPR_NOT:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2441 t = octave_value::op_not;
2960
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2442 break;
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2443
4965
c0d8e8afa82f [project @ 2004-09-06 20:19:57 by jwe]
jwe
parents: 4935
diff changeset
2444 case '+':
c0d8e8afa82f [project @ 2004-09-06 20:19:57 by jwe]
jwe
parents: 4935
diff changeset
2445 t = octave_value::op_uplus;
c0d8e8afa82f [project @ 2004-09-06 20:19:57 by jwe]
jwe
parents: 4935
diff changeset
2446 break;
c0d8e8afa82f [project @ 2004-09-06 20:19:57 by jwe]
jwe
parents: 4935
diff changeset
2447
2960
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2448 case '-':
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2449 t = octave_value::op_uminus;
2960
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2450 break;
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2451
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2452 case PLUS_PLUS:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2453 t = octave_value::op_incr;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2454 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2455
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2456 case MINUS_MINUS:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2457 t = octave_value::op_decr;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2458 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2459
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2460 default:
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2461 panic_impossible ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2462 break;
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2463 }
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2464
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2465 int l = tok_val->line ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2466 int c = tok_val->column ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2467
3292
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2468 tree_prefix_expression *e
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2469 = new tree_prefix_expression (op1, l, c, t);
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2470
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2471 return fold (e);
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2472 }
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2473
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2474 // Build a postfix expression.
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
2475
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2476 static tree_expression *
2960
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2477 make_postfix_op (int op, tree_expression *op1, token *tok_val)
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2478 {
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3195
diff changeset
2479 octave_value::unary_op t = octave_value::unknown_unary_op;
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2480
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2481 switch (op)
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2482 {
2960
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2483 case QUOTE:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2484 t = octave_value::op_hermitian;
2960
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2485 break;
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2486
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2487 case TRANSPOSE:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2488 t = octave_value::op_transpose;
2960
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2489 break;
194b50e4725b [project @ 1997-05-12 00:43:54 by jwe]
jwe
parents: 2899
diff changeset
2490
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2491 case PLUS_PLUS:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2492 t = octave_value::op_incr;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2493 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2494
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2200
diff changeset
2495 case MINUS_MINUS:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2496 t = octave_value::op_decr;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2497 break;
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 773
diff changeset
2498
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2499 default:
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2500 panic_impossible ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2501 break;
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2502 }
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2503
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2504 int l = tok_val->line ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2505 int c = tok_val->column ();
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 572
diff changeset
2506
3292
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2507 tree_postfix_expression *e
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2508 = new tree_postfix_expression (op1, l, c, t);
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2509
ad0d250ebd7e [project @ 1999-10-14 22:52:28 by jwe]
jwe
parents: 3258
diff changeset
2510 return fold (e);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2511 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2512
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2513 // Build an unwind-protect command.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2514
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2515 static tree_command *
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2516 make_unwind_command (token *unwind_tok, tree_statement_list *body,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2517 tree_statement_list *cleanup, token *end_tok,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2518 octave_comment_list *lc, octave_comment_list *mc)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2519 {
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2520 tree_command *retval = 0;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2521
2857
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
2522 if (end_token_ok (end_tok, token::unwind_protect_end))
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2523 {
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2524 octave_comment_list *tc = octave_comment_buffer::get_comment ();
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2525
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2526 int l = unwind_tok->line ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2527 int c = unwind_tok->column ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2528
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2529 retval = new tree_unwind_protect_command (body, cleanup,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2530 lc, mc, tc, l, c);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2531 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2532
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2533 return retval;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2534 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2535
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2536 // Build a try-catch command.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2537
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2538 static tree_command *
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2539 make_try_command (token *try_tok, tree_statement_list *body,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2540 tree_statement_list *cleanup, token *end_tok,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2541 octave_comment_list *lc, octave_comment_list *mc)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2542 {
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2543 tree_command *retval = 0;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2544
2857
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
2545 if (end_token_ok (end_tok, token::try_catch_end))
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2546 {
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2547 octave_comment_list *tc = octave_comment_buffer::get_comment ();
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2548
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2549 int l = try_tok->line ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2550 int c = try_tok->column ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2551
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2552 retval = new tree_try_catch_command (body, cleanup,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2553 lc, mc, tc, l, c);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2554 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2555
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2556 return retval;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2557 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2558
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2559 // Build a while command.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2560
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2561 static tree_command *
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2562 make_while_command (token *while_tok, tree_expression *expr,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2563 tree_statement_list *body, token *end_tok,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2564 octave_comment_list *lc)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2565 {
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2566 tree_command *retval = 0;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2567
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2568 maybe_warn_assign_as_truth_value (expr);
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2569
2857
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
2570 if (end_token_ok (end_tok, token::while_end))
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2571 {
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2572 octave_comment_list *tc = octave_comment_buffer::get_comment ();
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2573
1826
b14829582cc4 [project @ 1996-02-02 03:05:07 by jwe]
jwe
parents: 1755
diff changeset
2574 lexer_flags.looping--;
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2575
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2576 int l = while_tok->line ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2577 int c = while_tok->column ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2578
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2579 retval = new tree_while_command (expr, body, lc, tc, l, c);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2580 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2581
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2582 return retval;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2583 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2584
3484
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2585 // Build a do-until command.
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2586
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2587 static tree_command *
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2588 make_do_until_command (token *until_tok, tree_statement_list *body,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2589 tree_expression *expr, octave_comment_list *lc)
3484
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2590 {
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2591 tree_command *retval = 0;
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2592
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2593 maybe_warn_assign_as_truth_value (expr);
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2594
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2595 octave_comment_list *tc = octave_comment_buffer::get_comment ();
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2596
3484
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2597 lexer_flags.looping--;
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2598
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2599 int l = until_tok->line ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2600 int c = until_tok->column ();
3484
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2601
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2602 retval = new tree_do_until_command (expr, body, lc, tc, l, c);
3484
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2603
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2604 return retval;
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2605 }
8b1f46ac2b64 [project @ 2000-01-27 23:30:45 by jwe]
jwe
parents: 3446
diff changeset
2606
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2607 // Build a for command.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2608
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2609 static tree_command *
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
2610 make_for_command (int tok_id, token *for_tok, tree_argument_list *lhs,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2611 tree_expression *expr, tree_expression *maxproc,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2612 tree_statement_list *body, token *end_tok,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2613 octave_comment_list *lc)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2614 {
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2615 tree_command *retval = 0;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2616
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
2617 bool parfor = tok_id == PARFOR;
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2618
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2619 if (end_token_ok (end_tok, parfor ? token::parfor_end : token::for_end))
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2620 {
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2621 octave_comment_list *tc = octave_comment_buffer::get_comment ();
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2622
1826
b14829582cc4 [project @ 1996-02-02 03:05:07 by jwe]
jwe
parents: 1755
diff changeset
2623 lexer_flags.looping--;
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2624
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2625 int l = for_tok->line ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2626 int c = for_tok->column ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2627
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2628 if (lhs->length () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2629 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2630 tree_expression *tmp = lhs->remove_front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2631
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
2632 retval = new tree_simple_for_command (parfor, tmp, expr, maxproc,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2633 body, lc, tc, l, c);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2634
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2635 delete lhs;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2636 }
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2637 else
13245
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2638 {
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2639 if (parfor)
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2640 yyerror ("invalid syntax for parfor statement");
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2641 else
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2642 retval = new tree_complex_for_command (lhs, expr, body,
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2643 lc, tc, l, c);
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13241
diff changeset
2644 }
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2645 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2646
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2647 return retval;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2648 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2649
4207
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2650 // Build a break command.
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2651
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2652 static tree_command *
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2653 make_break_command (token *break_tok)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2654 {
4207
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2655 tree_command *retval = 0;
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2656
2620
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2542
diff changeset
2657 int l = break_tok->line ();
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2542
diff changeset
2658 int c = break_tok->column ();
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2542
diff changeset
2659
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
2660 retval = new tree_break_command (l, c);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2661
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2662 return retval;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2663 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2664
4207
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2665 // Build a continue command.
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2666
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2667 static tree_command *
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2668 make_continue_command (token *continue_tok)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2669 {
4207
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2670 tree_command *retval = 0;
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2671
2620
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2542
diff changeset
2672 int l = continue_tok->line ();
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2542
diff changeset
2673 int c = continue_tok->column ();
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2542
diff changeset
2674
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
2675 retval = new tree_continue_command (l, c);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2676
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2677 return retval;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2678 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2679
4207
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2680 // Build a return command.
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2681
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2682 static tree_command *
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2683 make_return_command (token *return_tok)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2684 {
4207
fa3482b34599 [project @ 2002-12-03 18:22:05 by jwe]
jwe
parents: 4186
diff changeset
2685 tree_command *retval = 0;
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2686
2620
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2542
diff changeset
2687 int l = return_tok->line ();
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2542
diff changeset
2688 int c = return_tok->column ();
5c773d4745d6 [project @ 1997-01-23 16:26:25 by jwe]
jwe
parents: 2542
diff changeset
2689
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
2690 retval = new tree_return_command (l, c);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2691
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2692 return retval;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2693 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2694
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2695 // Start an if command.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2696
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2697 static tree_if_command_list *
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2698 start_if_command (tree_expression *expr, tree_statement_list *list)
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2699 {
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2700 maybe_warn_assign_as_truth_value (expr);
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2701
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2702 tree_if_clause *t = new tree_if_clause (expr, list);
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2703
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2704 return new tree_if_command_list (t);
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2705 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2706
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2707 // Finish an if command.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2708
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2709 static tree_if_command *
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2710 finish_if_command (token *if_tok, tree_if_command_list *list,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2711 token *end_tok, octave_comment_list *lc)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2712 {
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2713 tree_if_command *retval = 0;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2714
2857
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
2715 if (end_token_ok (end_tok, token::if_end))
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2716 {
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2717 octave_comment_list *tc = octave_comment_buffer::get_comment ();
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2718
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2719 int l = if_tok->line ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2720 int c = if_tok->column ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2721
8842
be7b30a24938 line/column info for switch and if statements
John W. Eaton <jwe@octave.org>
parents: 8828
diff changeset
2722 if (list && ! list->empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2723 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2724 tree_if_clause *elt = list->front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2725
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2726 if (elt)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2727 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2728 elt->line (l);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2729 elt->column (c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2730 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2731 }
8842
be7b30a24938 line/column info for switch and if statements
John W. Eaton <jwe@octave.org>
parents: 8828
diff changeset
2732
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2733 retval = new tree_if_command (list, lc, tc, l, c);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2734 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2735
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2736 return retval;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2737 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2738
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2739 // Build an elseif clause.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2740
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2741 static tree_if_clause *
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2742 make_elseif_clause (token *elseif_tok, tree_expression *expr,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2743 tree_statement_list *list, octave_comment_list *lc)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2744 {
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2745 maybe_warn_assign_as_truth_value (expr);
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2746
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2747 int l = elseif_tok->line ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2748 int c = elseif_tok->column ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2749
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2750 return new tree_if_clause (expr, list, lc, l, c);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2751 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2752
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2753 // Finish a switch command.
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2754
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2755 static tree_switch_command *
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2756 finish_switch_command (token *switch_tok, tree_expression *expr,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2757 tree_switch_case_list *list, token *end_tok,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2758 octave_comment_list *lc)
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2759 {
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2760 tree_switch_command *retval = 0;
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2761
2857
5448c8cba402 [project @ 1997-03-31 07:06:10 by jwe]
jwe
parents: 2856
diff changeset
2762 if (end_token_ok (end_tok, token::switch_end))
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2763 {
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2764 octave_comment_list *tc = octave_comment_buffer::get_comment ();
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2765
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2766 int l = switch_tok->line ();
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2767 int c = switch_tok->column ();
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2768
8842
be7b30a24938 line/column info for switch and if statements
John W. Eaton <jwe@octave.org>
parents: 8828
diff changeset
2769 if (list && ! list->empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2770 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2771 tree_switch_case *elt = list->front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2772
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2773 if (elt)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2774 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2775 elt->line (l);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2776 elt->column (c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2777 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2778 }
8842
be7b30a24938 line/column info for switch and if statements
John W. Eaton <jwe@octave.org>
parents: 8828
diff changeset
2779
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2780 retval = new tree_switch_command (expr, list, lc, tc, l, c);
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2781 }
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2782
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2783 return retval;
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2784 }
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2785
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2786 // Build a switch case.
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2787
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2788 static tree_switch_case *
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2789 make_switch_case (token *case_tok, tree_expression *expr,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2790 tree_statement_list *list, octave_comment_list *lc)
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2791 {
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2792 maybe_warn_variable_switch_label (expr);
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2793
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2794 int l = case_tok->line ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2795 int c = case_tok->column ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2796
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2797 return new tree_switch_case (expr, list, lc, l, c);
2764
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2798 }
2c0f259cf83d [project @ 1997-03-01 02:30:26 by jwe]
jwe
parents: 2745
diff changeset
2799
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2800 // Build an assignment to a variable.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2801
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2802 static tree_expression *
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2803 make_assign_op (int op, tree_argument_list *lhs, token *eq_tok,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2804 tree_expression *rhs)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2805 {
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2806 tree_expression *retval = 0;
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2807
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2808 octave_value::assign_op t = octave_value::unknown_assign_op;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2809
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2810 switch (op)
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2811 {
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2812 case '=':
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2813 t = octave_value::op_asn_eq;
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2814 break;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2815
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2816 case ADD_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2817 t = octave_value::op_add_eq;
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2818 break;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2819
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2820 case SUB_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2821 t = octave_value::op_sub_eq;
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2822 break;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2823
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2824 case MUL_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2825 t = octave_value::op_mul_eq;
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2826 break;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2827
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2828 case DIV_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2829 t = octave_value::op_div_eq;
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2830 break;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2831
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2832 case LEFTDIV_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2833 t = octave_value::op_ldiv_eq;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2834 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2835
4018
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4009
diff changeset
2836 case POW_EQ:
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4009
diff changeset
2837 t = octave_value::op_pow_eq;
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4009
diff changeset
2838 break;
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4009
diff changeset
2839
2899
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2840 case LSHIFT_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2841 t = octave_value::op_lshift_eq;
2899
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2842 break;
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2843
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2844 case RSHIFT_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2845 t = octave_value::op_rshift_eq;
2899
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2846 break;
0d79a8c11a2b [project @ 1997-04-30 03:09:23 by jwe]
jwe
parents: 2891
diff changeset
2847
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2848 case EMUL_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2849 t = octave_value::op_el_mul_eq;
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2850 break;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2851
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2852 case EDIV_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2853 t = octave_value::op_el_div_eq;
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2854 break;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2855
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2856 case ELEFTDIV_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2857 t = octave_value::op_el_ldiv_eq;
3204
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2858 break;
81738e630f57 [project @ 1998-10-30 23:28:29 by jwe]
jwe
parents: 3203
diff changeset
2859
4018
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4009
diff changeset
2860 case EPOW_EQ:
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4009
diff changeset
2861 t = octave_value::op_el_pow_eq;
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4009
diff changeset
2862 break;
a8621d87fbf5 [project @ 2002-08-05 03:17:25 by jwe]
jwe
parents: 4009
diff changeset
2863
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2864 case AND_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2865 t = octave_value::op_el_and_eq;
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2866 break;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2867
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2868 case OR_EQ:
3525
6cfa474c5b99 [project @ 2000-02-02 10:48:41 by jwe]
jwe
parents: 3523
diff changeset
2869 t = octave_value::op_el_or_eq;
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2870 break;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2871
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2872 default:
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2873 panic_impossible ();
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2874 break;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2875 }
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
2876
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2877 int l = eq_tok->line ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2878 int c = eq_tok->column ();
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2879
5841
fb4dea2184bf [project @ 2006-06-05 20:59:25 by jwe]
jwe
parents: 5832
diff changeset
2880 if (lhs->is_simple_assign_lhs ())
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
2881 {
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2882 tree_expression *tmp = lhs->remove_front ();
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2883
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2884 retval = new tree_simple_assignment (tmp, rhs, false, l, c, t);
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2885
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
2886 delete lhs;
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
2887 }
10230
0a5a769b8fc0 disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 10207
diff changeset
2888 else if (t == octave_value::op_asn_eq)
0a5a769b8fc0 disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 10207
diff changeset
2889 return new tree_multi_assignment (lhs, rhs, false, l, c);
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
2890 else
10230
0a5a769b8fc0 disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 10207
diff changeset
2891 yyerror ("computed multiple assignment not allowed");
666
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
2892
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
2893 return retval;
fb4f6556b443 [project @ 1994-09-06 21:22:46 by jwe]
jwe
parents: 627
diff changeset
2894 }
751
c9f3cb77478d [project @ 1994-09-30 18:46:17 by jwe]
jwe
parents: 723
diff changeset
2895
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2896 // Define a script.
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2897
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2898 static void
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2899 make_script (tree_statement_list *cmds, tree_statement *end_script)
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2900 {
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2901 std::string doc_string;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2902
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2903 if (! help_buf.empty ())
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2904 {
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2905 doc_string = help_buf.top ();
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2906 help_buf.pop ();
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2907 }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2908
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2909 if (! cmds)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2910 cmds = new tree_statement_list ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2911
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2912 cmds->append (end_script);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2913
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2914 octave_user_script *script
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2915 = new octave_user_script (curr_fcn_file_full_name, curr_fcn_file_name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2916 cmds, doc_string);
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2917
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2918 octave_time now;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2919
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2920 script->stash_fcn_file_time (now);
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2921
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2922 primary_fcn_ptr = script;
8881
8ed42c679af5 after defining a script or function, clear local variables created for parsing
John W. Eaton <jwe@octave.org>
parents: 8842
diff changeset
2923
9009
da58ec8f62e8 tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents: 8974
diff changeset
2924 // Unmark any symbols that may have been tagged as local variables
da58ec8f62e8 tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents: 8974
diff changeset
2925 // while parsing (for example, by force_local_variable in lex.l).
da58ec8f62e8 tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents: 8974
diff changeset
2926
da58ec8f62e8 tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents: 8974
diff changeset
2927 symbol_table::unmark_forced_variables ();
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2928 }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
2929
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2930 // Begin defining a function.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2931
2891
1a30f46e1870 [project @ 1997-04-28 01:49:00 by jwe]
jwe
parents: 2884
diff changeset
2932 static octave_user_function *
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2933 start_function (tree_parameter_list *param_list, tree_statement_list *body,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2934 tree_statement *end_fcn_stmt)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2935 {
2891
1a30f46e1870 [project @ 1997-04-28 01:49:00 by jwe]
jwe
parents: 2884
diff changeset
2936 // We'll fill in the return list later.
1a30f46e1870 [project @ 1997-04-28 01:49:00 by jwe]
jwe
parents: 2884
diff changeset
2937
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2938 if (! body)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2939 body = new tree_statement_list ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2940
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2941 body->append (end_fcn_stmt);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2942
2891
1a30f46e1870 [project @ 1997-04-28 01:49:00 by jwe]
jwe
parents: 2884
diff changeset
2943 octave_user_function *fcn
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
2944 = new octave_user_function (symbol_table::current_scope (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2945 param_list, 0, body);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2946
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2947 if (fcn)
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2948 {
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2949 octave_comment_list *tc = octave_comment_buffer::get_comment ();
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2950
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2951 fcn->stash_trailing_comment (tc);
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2952 }
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
2953
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2954 return fcn;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2955 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2956
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2957 static tree_statement *
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2958 make_end (const std::string& type, int l, int c)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2959 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2960 return make_statement (new tree_no_op_command (type, l, c));
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2961 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
2962
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2963 // Do most of the work for defining a function.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2964
2891
1a30f46e1870 [project @ 1997-04-28 01:49:00 by jwe]
jwe
parents: 2884
diff changeset
2965 static octave_user_function *
4872
fe71c458f438 [project @ 2004-04-21 20:09:32 by jwe]
jwe
parents: 4844
diff changeset
2966 frob_function (const std::string& fname, octave_user_function *fcn)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2967 {
4872
fe71c458f438 [project @ 2004-04-21 20:09:32 by jwe]
jwe
parents: 4844
diff changeset
2968 std::string id_name = fname;
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2969
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2970 // If input is coming from a file, issue a warning if the name of
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2971 // the file does not match the name of the function stated in the
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2972 // file. Matlab doesn't provide a diagnostic (it ignores the stated
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2973 // name).
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2974 if (! autoloading && reading_fcn_file
14507
3f21c0c34b8f check for function/file name mismatch when parsing class methods
John W. Eaton <jwe@octave.org>
parents: 14360
diff changeset
2975 && current_function_depth == 1 && ! parsing_subfunctions)
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2976 {
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2977 // FIXME -- should curr_fcn_file_name already be
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2978 // preprocessed when we get here? It seems to only be a
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2979 // problem with relative file names.
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2980
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2981 std::string nm = curr_fcn_file_name;
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2982
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2983 size_t pos = nm.find_last_of (file_ops::dir_sep_chars ());
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2984
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2985 if (pos != std::string::npos)
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2986 nm = curr_fcn_file_name.substr (pos+1);
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2987
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2988 if (nm != id_name)
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2989 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2990 warning_with_id
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2991 ("Octave:function-name-clash",
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
2992 "function name '%s' does not agree with function file name '%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2993 id_name.c_str (), curr_fcn_file_full_name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2994
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
2995 id_name = nm;
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2996 }
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
2997 }
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
2998
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
2999 if (reading_fcn_file || reading_classdef_file || autoloading)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3000 {
3712
7066a8065e7e [project @ 2000-08-22 06:21:20 by jwe]
jwe
parents: 3665
diff changeset
3001 octave_time now;
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3156
diff changeset
3002
4343
db5e0814277a [project @ 2003-02-20 16:44:16 by jwe]
jwe
parents: 4342
diff changeset
3003 fcn->stash_fcn_file_name (curr_fcn_file_full_name);
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3156
diff changeset
3004 fcn->stash_fcn_file_time (now);
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3005 fcn->mark_as_system_fcn_file ();
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3156
diff changeset
3006
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6238
diff changeset
3007 if (fcn_file_from_relative_lookup)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3008 fcn->mark_relative ();
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6238
diff changeset
3009
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3010 if (current_function_depth > 1 || parsing_subfunctions)
7968
0d607e8dbbfa eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents: 7903
diff changeset
3011 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3012 fcn->stash_parent_fcn_name (curr_fcn_file_name);
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3013
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3014 if (current_function_depth > 1)
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14584
diff changeset
3015 fcn->stash_parent_fcn_scope (function_scopes[function_scopes.size ()-2]);
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3016 else
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3017 fcn->stash_parent_fcn_scope (primary_fcn_scope);
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3018 }
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6238
diff changeset
3019
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3020 if (lexer_flags.parsing_class_method)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3021 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3022 if (current_class_name == id_name)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3023 fcn->mark_as_class_constructor ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3024 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3025 fcn->mark_as_class_method ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3026
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3027 fcn->stash_dispatch_class (current_class_name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3028 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3029
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
3030 std::string nm = fcn->fcn_file_name ();
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
3031
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
3032 file_stat fs (nm);
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
3033
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
3034 if (fs && fs.is_newer (now))
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
3035 warning_with_id ("Octave:future-time-stamp",
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
3036 "time stamp for '%s' is in the future", nm.c_str ());
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3037 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3038 else if (! (input_from_tmp_history_file || input_from_startup_file)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3039 && reading_script_file
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3040 && curr_fcn_file_name == id_name)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3041 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
3042 warning ("function '%s' defined within script file '%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3043 id_name.c_str (), curr_fcn_file_full_name.c_str ());
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3044 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3045
4872
fe71c458f438 [project @ 2004-04-21 20:09:32 by jwe]
jwe
parents: 4844
diff changeset
3046 fcn->stash_function_name (id_name);
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents: 12729
diff changeset
3047 fcn->stash_fcn_location (input_line_number, current_input_column);
4872
fe71c458f438 [project @ 2004-04-21 20:09:32 by jwe]
jwe
parents: 4844
diff changeset
3048
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3049 if (! help_buf.empty () && current_function_depth == 1
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3050 && ! parsing_subfunctions)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3051 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3052 fcn->document (help_buf.top ());
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3053
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3054 help_buf.pop ();
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3055 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3056
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3057 if (reading_fcn_file && current_function_depth == 1
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3058 && ! parsing_subfunctions)
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3059 primary_fcn_ptr = fcn;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
3060
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3061 return fcn;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3062 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3063
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3064 static tree_function_def *
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
3065 finish_function (tree_parameter_list *ret_list,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3066 octave_user_function *fcn, octave_comment_list *lc)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3067 {
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3068 tree_function_def *retval = 0;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3069
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3070 if (ret_list)
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3071 ret_list->mark_as_formal_parameters ();
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3072
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3073 if (fcn)
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3074 {
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7755
diff changeset
3075 std::string nm = fcn->name ();
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7755
diff changeset
3076 std::string file = fcn->fcn_file_name ();
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7755
diff changeset
3077
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7755
diff changeset
3078 std::string tmp = nm;
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7755
diff changeset
3079 if (! file.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3080 tmp += ": " + file;
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7755
diff changeset
3081
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7755
diff changeset
3082 symbol_table::cache_name (fcn->scope (), tmp);
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7755
diff changeset
3083
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3084 if (lc)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3085 fcn->stash_leading_comment (lc);
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3086
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3087 fcn->define_ret_list (ret_list);
7755
ea9cb4d68dbf avoid installing subfunctions twice
John W. Eaton <jwe@octave.org>
parents: 7750
diff changeset
3088
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3089 if (current_function_depth > 1 || parsing_subfunctions)
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3090 {
11461
2b8531a6a3c9 Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents: 11388
diff changeset
3091 fcn->mark_as_subfunction ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3092
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3093 if (endfunction_found && function_scopes.size () > 1)
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3094 {
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3095 symbol_table::scope_id pscope
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14584
diff changeset
3096 = function_scopes[function_scopes.size ()-2];
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3097
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3098 symbol_table::install_nestfunction (nm, octave_value (fcn),
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3099 pscope);
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3100 }
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3101 else
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3102 symbol_table::install_subfunction (nm, octave_value (fcn),
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3103 primary_fcn_scope);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3104 }
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3105
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3106 if (current_function_depth == 1 && fcn)
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3107 symbol_table::update_nest (fcn->scope ());
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3108
14512
e0d66b8b0c63 Avoid double delete for nested functions in commandline
Max Brister <max@2bass.com>
parents: 14507
diff changeset
3109 if (! reading_fcn_file && current_function_depth == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3110 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3111 // We are either reading a script file or defining a function
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3112 // at the command line, so this definition creates a
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3113 // tree_function object that is placed in the parse tree.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3114 // Otherwise, it is just inserted in the symbol table,
14512
e0d66b8b0c63 Avoid double delete for nested functions in commandline
Max Brister <max@2bass.com>
parents: 14507
diff changeset
3115 // either as a subfunction or nested function (see above),
e0d66b8b0c63 Avoid double delete for nested functions in commandline
Max Brister <max@2bass.com>
parents: 14507
diff changeset
3116 // or as the primary function for the file, via
e0d66b8b0c63 Avoid double delete for nested functions in commandline
Max Brister <max@2bass.com>
parents: 14507
diff changeset
3117 // primary_fcn_ptr (see also load_fcn_from_file,,
e0d66b8b0c63 Avoid double delete for nested functions in commandline
Max Brister <max@2bass.com>
parents: 14507
diff changeset
3118 // parse_fcn_file, and
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3119 // symbol_table::fcn_info::fcn_info_rep::find_user_function).
9761
5f8971be8e12 parse.y (finish_function): retrun function object unless parsing function file
John W. Eaton <jwe@octave.org>
parents: 9506
diff changeset
3120
5f8971be8e12 parse.y (finish_function): retrun function object unless parsing function file
John W. Eaton <jwe@octave.org>
parents: 9506
diff changeset
3121 retval = new tree_function_def (fcn);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3122 }
8282
47a3d2f829e4 clear local symbol table after parsing function
John W. Eaton <jwe@octave.org>
parents: 8150
diff changeset
3123
9009
da58ec8f62e8 tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents: 8974
diff changeset
3124 // Unmark any symbols that may have been tagged as local
da58ec8f62e8 tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents: 8974
diff changeset
3125 // variables while parsing (for example, by force_local_variable
da58ec8f62e8 tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents: 8974
diff changeset
3126 // in lex.l).
da58ec8f62e8 tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents: 8974
diff changeset
3127
da58ec8f62e8 tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents: 8974
diff changeset
3128 symbol_table::unmark_forced_variables (fcn->scope ());
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3129 }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3130
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3131 return retval;
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3132 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3133
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
3134 static void
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
3135 recover_from_parsing_function (void)
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
3136 {
14329
8d1ae996c122 also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents: 14294
diff changeset
3137 if (parser_symtab_context.empty ())
3903
1dbe160ea0d1 [project @ 2002-04-23 03:40:25 by jwe]
jwe
parents: 3883
diff changeset
3138 panic_impossible ();
1dbe160ea0d1 [project @ 2002-04-23 03:40:25 by jwe]
jwe
parents: 3883
diff changeset
3139
14329
8d1ae996c122 also save and restore symbol table context in parser (bug #35448)
John W. Eaton <jwe@octave.org>
parents: 14294
diff changeset
3140 parser_symtab_context.pop ();
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
3141
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3142 if (reading_fcn_file && current_function_depth == 1
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3143 && ! parsing_subfunctions)
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3144 parsing_subfunctions = true;
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3145
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3146 current_function_depth--;
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3147 function_scopes.pop_back ();
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3148
11367
b2191ebea12f don't process input_event_hook when we are parsing a function
John W. Eaton <jwe@octave.org>
parents: 11317
diff changeset
3149 lexer_flags.defining_func--;
11464
21b5284fa78d avoid error when parsing nested functions
John W. Eaton <jwe@octave.org>
parents: 11461
diff changeset
3150 lexer_flags.parsed_function_name.pop ();
2883
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
3151 lexer_flags.looking_at_return_list = false;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
3152 lexer_flags.looking_at_parameter_list = false;
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
3153 }
0b3954110c77 [project @ 1997-04-24 09:57:05 by jwe]
jwe
parents: 2865
diff changeset
3154
2846
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3155 // Make an index expression.
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3156
751
c9f3cb77478d [project @ 1994-09-30 18:46:17 by jwe]
jwe
parents: 723
diff changeset
3157 static tree_index_expression *
3929
cc8ae49d6e79 [project @ 2002-05-04 02:47:14 by jwe]
jwe
parents: 3928
diff changeset
3158 make_index_expression (tree_expression *expr, tree_argument_list *args,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3159 char type)
751
c9f3cb77478d [project @ 1994-09-30 18:46:17 by jwe]
jwe
parents: 723
diff changeset
3160 {
c9f3cb77478d [project @ 1994-09-30 18:46:17 by jwe]
jwe
parents: 723
diff changeset
3161 tree_index_expression *retval = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
3162
10206
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10188
diff changeset
3163 if (args && args->has_magic_tilde ())
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10188
diff changeset
3164 {
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10188
diff changeset
3165 yyerror ("invalid use of empty argument (~) in index expression");
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10188
diff changeset
3166 return retval;
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10188
diff changeset
3167 }
751
c9f3cb77478d [project @ 1994-09-30 18:46:17 by jwe]
jwe
parents: 723
diff changeset
3168
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3169 int l = expr->line ();
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3170 int c = expr->column ();
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3171
15954
46ca8488de92 Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15895
diff changeset
3172 if (! expr->is_postfix_indexed ())
46ca8488de92 Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15895
diff changeset
3173 expr->set_postfix_index (type);
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3174
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3175 if (expr->is_index_expression ())
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3176 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3177 tree_index_expression *tmp = static_cast<tree_index_expression *> (expr);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3178
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3179 tmp->append (args, type);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3180
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3181 retval = tmp;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3182 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3183 else
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3184 retval = new tree_index_expression (expr, args, l, c, type);
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3185
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3186 return retval;
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3187 }
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3188
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3189 // Make an indirect reference expression.
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3190
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
3191 static tree_index_expression *
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
3192 make_indirect_ref (tree_expression *expr, const std::string& elt)
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3193 {
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
3194 tree_index_expression *retval = 0;
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3195
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3196 int l = expr->line ();
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3197 int c = expr->column ();
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3198
15954
46ca8488de92 Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15895
diff changeset
3199 if (! expr->is_postfix_indexed ())
46ca8488de92 Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15895
diff changeset
3200 expr->set_postfix_index ('.');
46ca8488de92 Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15895
diff changeset
3201
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3202 if (expr->is_index_expression ())
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3203 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3204 tree_index_expression *tmp = static_cast<tree_index_expression *> (expr);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3205
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3206 tmp->append (elt);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3207
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3208 retval = tmp;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3209 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3210 else
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
3211 retval = new tree_index_expression (expr, elt, l, c);
2970
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3212
b9e64477f703 [project @ 1997-05-15 18:04:21 by jwe]
jwe
parents: 2961
diff changeset
3213 lexer_flags.looking_at_indirect_ref = false;
751
c9f3cb77478d [project @ 1994-09-30 18:46:17 by jwe]
jwe
parents: 723
diff changeset
3214
c9f3cb77478d [project @ 1994-09-30 18:46:17 by jwe]
jwe
parents: 723
diff changeset
3215 return retval;
c9f3cb77478d [project @ 1994-09-30 18:46:17 by jwe]
jwe
parents: 723
diff changeset
3216 }
1511
74f9e88a2c12 [project @ 1995-10-03 10:49:31 by jwe]
jwe
parents: 1491
diff changeset
3217
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3218 // Make an indirect reference expression with dynamic field name.
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3219
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3220 static tree_index_expression *
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3221 make_indirect_ref (tree_expression *expr, tree_expression *elt)
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3222 {
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3223 tree_index_expression *retval = 0;
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3224
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3225 int l = expr->line ();
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3226 int c = expr->column ();
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3227
15954
46ca8488de92 Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15895
diff changeset
3228 if (! expr->is_postfix_indexed ())
46ca8488de92 Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15895
diff changeset
3229 expr->set_postfix_index ('.');
46ca8488de92 Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15895
diff changeset
3230
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3231 if (expr->is_index_expression ())
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3232 {
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3233 tree_index_expression *tmp = static_cast<tree_index_expression *> (expr);
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3234
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3235 tmp->append (elt);
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3236
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3237 retval = tmp;
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3238 }
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3239 else
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3240 retval = new tree_index_expression (expr, elt, l, c);
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3241
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3242 lexer_flags.looking_at_indirect_ref = false;
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3243
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3244 return retval;
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3245 }
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4064
diff changeset
3246
2846
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3247 // Make a declaration command.
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3248
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3249 static tree_decl_command *
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3250 make_decl_command (int tok, token *tok_val, tree_decl_init_list *lst)
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3251 {
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3252 tree_decl_command *retval = 0;
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3253
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3254 int l = tok_val->line ();
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3255 int c = tok_val->column ();
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3256
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3257 switch (tok)
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3258 {
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3259 case GLOBAL:
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3260 retval = new tree_global_command (lst, l, c);
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3261 break;
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3262
14294
9e3983c8963c deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents: 14293
diff changeset
3263 case PERSISTENT:
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3264 if (current_function_depth > 0)
14294
9e3983c8963c deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents: 14293
diff changeset
3265 retval = new tree_persistent_command (lst, l, c);
2846
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3266 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3267 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3268 if (reading_script_file)
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
3269 warning ("ignoring persistent declaration near line %d of file '%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3270 l, curr_fcn_file_full_name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3271 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3272 warning ("ignoring persistent declaration near line %d", l);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3273 }
2846
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3274 break;
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3275
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3276 default:
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3277 panic_impossible ();
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3278 break;
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3279 }
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3280
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3281 return retval;
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3282 }
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2825
diff changeset
3283
10207
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
3284 static tree_argument_list *
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
3285 validate_matrix_row (tree_argument_list *row)
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
3286 {
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
3287 if (row && row->has_magic_tilde ())
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
3288 yyerror ("invalid use of tilde (~) in matrix expression");
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
3289 return row;
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
3290 }
76a880a588ce error when using ~ in matrix expression
Jaroslav Hajek <highegg@gmail.com>
parents: 10206
diff changeset
3291
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3292 // Finish building a matrix list.
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3293
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3294 static tree_expression *
1829
7d2982b55242 [project @ 1996-02-02 14:12:59 by jwe]
jwe
parents: 1826
diff changeset
3295 finish_matrix (tree_matrix *m)
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3296 {
3110
fe2d1ae8926b [project @ 1997-11-21 02:11:19 by jwe]
jwe
parents: 3099
diff changeset
3297 tree_expression *retval = m;
fe2d1ae8926b [project @ 1997-11-21 02:11:19 by jwe]
jwe
parents: 3099
diff changeset
3298
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3299 unwind_protect frame;
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3300
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3301 frame.protect_var (error_state);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3302 frame.protect_var (warning_state);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3303
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3304 frame.protect_var (discard_error_messages);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3305 frame.protect_var (discard_warning_messages);
4452
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4426
diff changeset
3306
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3802
diff changeset
3307 discard_error_messages = true;
4452
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4426
diff changeset
3308 discard_warning_messages = true;
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3309
2533
987e934bbb8c [project @ 1996-11-19 18:21:23 by jwe]
jwe
parents: 2525
diff changeset
3310 if (m->all_elements_are_constant ())
1829
7d2982b55242 [project @ 1996-02-02 14:12:59 by jwe]
jwe
parents: 1826
diff changeset
3311 {
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
3312 octave_value tmp = m->rvalue1 ();
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3313
3489
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3485
diff changeset
3314 if (! (error_state || warning_state))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3315 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3316 tree_constant *tc_retval
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3317 = new tree_constant (tmp, m->line (), m->column ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3318
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3319 std::ostringstream buf;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3320
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3321 tree_print_code tpc (buf);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3322
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3323 m->accept (tpc);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3324
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3325 tc_retval->stash_original_text (buf.str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3326
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3327 delete m;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3328
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3329 retval = tc_retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3330 }
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3331 }
3110
fe2d1ae8926b [project @ 1997-11-21 02:11:19 by jwe]
jwe
parents: 3099
diff changeset
3332
1623
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3333 return retval;
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3334 }
fa7a847f9b92 [project @ 1995-11-06 18:05:09 by jwe]
jwe
parents: 1607
diff changeset
3335
3351
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
3336 // Finish building a cell list.
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
3337
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
3338 static tree_expression *
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
3339 finish_cell (tree_cell *c)
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
3340 {
5875
f6ddc0ee2315 [project @ 2006-07-01 15:24:44 by jwe]
jwe
parents: 5864
diff changeset
3341 return finish_matrix (c);
3351
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
3342 }
8623649c967c [project @ 1999-11-15 16:17:01 by jwe]
jwe
parents: 3347
diff changeset
3343
1511
74f9e88a2c12 [project @ 1995-10-03 10:49:31 by jwe]
jwe
parents: 1491
diff changeset
3344 static void
74f9e88a2c12 [project @ 1995-10-03 10:49:31 by jwe]
jwe
parents: 1491
diff changeset
3345 maybe_warn_missing_semi (tree_statement_list *t)
74f9e88a2c12 [project @ 1995-10-03 10:49:31 by jwe]
jwe
parents: 1491
diff changeset
3346 {
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3347 if (current_function_depth > 0)
1511
74f9e88a2c12 [project @ 1995-10-03 10:49:31 by jwe]
jwe
parents: 1491
diff changeset
3348 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14584
diff changeset
3349 tree_statement *tmp = t->back ();
1607
795527e9db19 [project @ 1995-11-02 13:03:36 by jwe]
jwe
parents: 1588
diff changeset
3350
1511
74f9e88a2c12 [project @ 1995-10-03 10:49:31 by jwe]
jwe
parents: 1491
diff changeset
3351 if (tmp->is_expression ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3352 warning_with_id
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3353 ("Octave:missing-semicolon",
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
3354 "missing semicolon near line %d, column %d in file '%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3355 tmp->line (), tmp->column (), curr_fcn_file_full_name.c_str ());
1511
74f9e88a2c12 [project @ 1995-10-03 10:49:31 by jwe]
jwe
parents: 1491
diff changeset
3356 }
74f9e88a2c12 [project @ 1995-10-03 10:49:31 by jwe]
jwe
parents: 1491
diff changeset
3357 }
1994
c2d20f365b84 [project @ 1996-03-03 01:19:32 by jwe]
jwe
parents: 1884
diff changeset
3358
8471
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3359 static tree_statement_list *
2525
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3360 set_stmt_print_flag (tree_statement_list *list, char sep,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3361 bool warn_missing_semi)
2525
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3362 {
8471
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3363 tree_statement *tmp = list->back ();
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3364
2525
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3365 switch (sep)
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3366 {
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3367 case ';':
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
3368 tmp->set_print_flag (false);
2525
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3369 break;
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3370
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3371 case 0:
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3372 case ',':
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3373 case '\n':
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
3374 tmp->set_print_flag (true);
2525
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3375 if (warn_missing_semi)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3376 maybe_warn_missing_semi (list);
2525
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3377 break;
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3378
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3379 default:
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3380 warning ("unrecognized separator type!");
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3381 break;
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3382 }
8471
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3383
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3384 // Even if a statement is null, we add it to the list then remove it
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3385 // here so that the print flag is applied to the correct statement.
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3386
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3387 if (tmp->is_null_statement ())
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3388 {
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3389 list->pop_back ();
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3390 delete tmp;
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3391 }
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3392
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3393 return list;
2525
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3394 }
8561d88be5f2 [project @ 1996-11-17 21:23:31 by jwe]
jwe
parents: 2524
diff changeset
3395
8448
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
3396 static tree_statement_list *
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
3397 make_statement_list (tree_statement *stmt)
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
3398 {
8471
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3399 return new tree_statement_list (stmt);
8448
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
3400 }
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
3401
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
3402 static tree_statement_list *
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
3403 append_statement_list (tree_statement_list *list, char sep,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3404 tree_statement *stmt, bool warn_missing_semi)
8448
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
3405 {
8471
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3406 set_stmt_print_flag (list, sep, warn_missing_semi);
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3407
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3408 list->append (stmt);
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3409
02de6775f1fe parse.y: always append statements to list, but remove null statements after seeing separator
John W. Eaton <jwe@octave.org>
parents: 8448
diff changeset
3410 return list;
8448
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
3411 }
d6c0d5f208de parse.y: avoid storing null statements in statement lists
John W. Eaton <jwe@octave.org>
parents: 8447
diff changeset
3412
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3413 static tree_funcall *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3414 make_superclass_ref (const std::string& method_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3415 const std::string& package_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3416 const std::string& class_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3417 int l, int c)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3418 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3419 octave_value_list args;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3420
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3421 args(2) = class_nm;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3422 args(1) = package_nm;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3423 args(0) = method_nm;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3424
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3425 octave_value fcn
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3426 = symbol_table::find_built_in_function ("__superclass_reference__");
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3427
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3428 return new tree_funcall (fcn, args);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3429 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3430
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3431 static tree_funcall *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3432 make_meta_class_query (const std::string& package_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3433 const std::string& class_nm,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3434 int l, int c)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3435 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3436 octave_value_list args;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3437
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3438 args(1) = class_nm;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3439 args(0) = package_nm;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3440
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3441 octave_value fcn
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3442 = symbol_table::find_built_in_function ("__meta_class_query__");
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3443
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3444 return new tree_funcall (fcn, args);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3445 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3446
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3447 // A CLASSDEF block defines a class that has a constructor and other
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3448 // methods, but it is not an executable command. Parsing the block
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3449 // makes some changes in the symbol table (inserting the constructor
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3450 // and methods, and adding to the list of known objects) and creates
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3451 // a parse tree containing meta information about the class.
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3452
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3453 static tree_classdef *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3454 make_classdef (token *tok_val, tree_classdef_attribute_list *a,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3455 tree_identifier *id, tree_classdef_superclass_list *sc,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3456 tree_classdef_body *body, token *end_tok,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3457 octave_comment_list *lc)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3458 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3459 tree_classdef *retval = 0;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3460
15895
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3461 std::string cls_name = id->name ();
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3462
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3463 std::string nm = curr_fcn_file_name;
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3464
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3465 size_t pos = nm.find_last_of (file_ops::dir_sep_chars ());
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3466
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3467 if (pos != std::string::npos)
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3468 nm = curr_fcn_file_name.substr (pos+1);
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3469
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3470 if (nm != cls_name)
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3471 {
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3472 yyerror ("invalid classdef definition, the class name must match the file name");
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3473 return retval;
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3474 }
ce8ad12ce8a0 Force classdef name to match filename.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15869
diff changeset
3475
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3476 if (end_token_ok (end_tok, token::classdef_end))
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3477 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3478 octave_comment_list *tc = octave_comment_buffer::get_comment ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3479
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3480 int l = tok_val->line ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3481 int c = tok_val->column ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3482
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3483 retval = new tree_classdef (a, id, sc, body, lc, tc, l, c);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3484 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3485
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3486 return retval;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3487 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3488
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3489 static tree_classdef_properties_block *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3490 make_classdef_properties_block (token *tok_val,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3491 tree_classdef_attribute_list *a,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3492 tree_classdef_property_list *plist,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3493 token *end_tok, octave_comment_list *lc)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3494 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3495 tree_classdef_properties_block *retval = 0;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3496
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3497 if (end_token_ok (end_tok, token::properties_end))
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3498 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3499 octave_comment_list *tc = octave_comment_buffer::get_comment ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3500
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3501 int l = tok_val->line ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3502 int c = tok_val->column ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3503
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3504 retval = new tree_classdef_properties_block (a, plist, lc, tc, l, c);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3505 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3506
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3507 return retval;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3508 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3509
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3510 static tree_classdef_methods_block *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3511 make_classdef_methods_block (token *tok_val,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3512 tree_classdef_attribute_list *a,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3513 tree_classdef_methods_list *mlist,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3514 token *end_tok, octave_comment_list *lc)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3515 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3516 tree_classdef_methods_block *retval = 0;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3517
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3518 if (end_token_ok (end_tok, token::methods_end))
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3519 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3520 octave_comment_list *tc = octave_comment_buffer::get_comment ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3521
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3522 int l = tok_val->line ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3523 int c = tok_val->column ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3524
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3525 retval = new tree_classdef_methods_block (a, mlist, lc, tc, l, c);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3526 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3527
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3528 return retval;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3529 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3530
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3531 static tree_classdef_events_block *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3532 make_classdef_events_block (token *tok_val,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3533 tree_classdef_attribute_list *a,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3534 tree_classdef_events_list *elist,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3535 token *end_tok, octave_comment_list *lc)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3536 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3537 tree_classdef_events_block *retval = 0;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3538
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3539 if (end_token_ok (end_tok, token::events_end))
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3540 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3541 octave_comment_list *tc = octave_comment_buffer::get_comment ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3542
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3543 int l = tok_val->line ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3544 int c = tok_val->column ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3545
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3546 retval = new tree_classdef_events_block (a, elist, lc, tc, l, c);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3547 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3548
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3549 return retval;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3550 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3551
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3552 static tree_classdef_enum_block *
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3553 make_classdef_enum_block (token *tok_val,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3554 tree_classdef_attribute_list *a,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3555 tree_classdef_enum_list *elist,
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3556 token *end_tok, octave_comment_list *lc)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3557 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3558 tree_classdef_enum_block *retval = 0;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3559
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3560 if (end_token_ok (end_tok, token::enumeration_end))
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3561 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3562 octave_comment_list *tc = octave_comment_buffer::get_comment ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3563
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3564 int l = tok_val->line ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3565 int c = tok_val->column ();
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3566
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3567 retval = new tree_classdef_enum_block (a, elist, lc, tc, l, c);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3568 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3569
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3570 return retval;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3571 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3572
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3573 static void
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3574 safe_fclose (FILE *f)
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3575 {
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5774
diff changeset
3576 // FIXME -- comments at the end of an input file are
3765
e10451597802 [project @ 2001-01-17 18:41:29 by jwe]
jwe
parents: 3726
diff changeset
3577 // discarded (otherwise, they would be appended to the next
e10451597802 [project @ 2001-01-17 18:41:29 by jwe]
jwe
parents: 3726
diff changeset
3578 // statement, possibly from the command line or another file, which
e10451597802 [project @ 2001-01-17 18:41:29 by jwe]
jwe
parents: 3726
diff changeset
3579 // can be quite confusing).
e10451597802 [project @ 2001-01-17 18:41:29 by jwe]
jwe
parents: 3726
diff changeset
3580
5308
bc8d6ebb6ee1 [project @ 2005-04-27 05:08:19 by jwe]
jwe
parents: 5307
diff changeset
3581 octave_comment_list *tc = octave_comment_buffer::get_comment ();
bc8d6ebb6ee1 [project @ 2005-04-27 05:08:19 by jwe]
jwe
parents: 5307
diff changeset
3582
bc8d6ebb6ee1 [project @ 2005-04-27 05:08:19 by jwe]
jwe
parents: 5307
diff changeset
3583 delete tc;
3765
e10451597802 [project @ 2001-01-17 18:41:29 by jwe]
jwe
parents: 3726
diff changeset
3584
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3585 if (f)
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3586 fclose (static_cast<FILE *> (f));
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3587 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3588
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3589 static bool
5175
7a25bb94ef65 [project @ 2005-03-02 17:38:32 by jwe]
jwe
parents: 5161
diff changeset
3590 looks_like_copyright (const std::string& s)
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3591 {
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3592 bool retval = false;
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3593
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3594 if (! s.empty ())
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3595 {
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3596 size_t offset = s.find_first_not_of (" \t");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
3597
14180
4942b3011541 oct-parse.yy: also identify Author as start of license text
Carnë Draug <carandraug+dev@gmail.com>
parents: 14084
diff changeset
3598 retval = (s.substr (offset, 9) == "Copyright" || s.substr (offset, 6) == "Author");
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3599 }
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3600
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3601 return retval;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3602 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3603
4540
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3604 static int
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3605 text_getc (FILE *f)
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3606 {
12918
f3a8d1efe2c1 use gnulib:: qualifiers for more stdio functions
John W. Eaton <jwe@octave.org>
parents: 12719
diff changeset
3607 int c = gnulib::getc (f);
4540
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3608
7728
13820b9f5fd9 more consistent handling of CR/CRLF/LF line endings in lexer and parser
John W. Eaton <jwe@octave.org>
parents: 7723
diff changeset
3609 // Convert CRLF into just LF and single CR into LF.
4540
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3610
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3611 if (c == '\r')
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3612 {
12918
f3a8d1efe2c1 use gnulib:: qualifiers for more stdio functions
John W. Eaton <jwe@octave.org>
parents: 12719
diff changeset
3613 c = gnulib::getc (f);
4540
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3614
8447
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
3615 if (c != '\n')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3616 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3617 ungetc (c, f);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3618 c = '\n';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3619 }
4540
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3620 }
8447
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
3621
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
3622 if (c == '\n')
7723
74f5e0c7de9e first pass at handling block comments
John W. Eaton <jwe@octave.org>
parents: 7720
diff changeset
3623 input_line_number++;
4540
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3624
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3625 return c;
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3626 }
491ac5f9d120 [project @ 2003-10-16 17:34:07 by jwe]
jwe
parents: 4486
diff changeset
3627
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3628 class
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3629 stdio_stream_reader : public stream_reader
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3630 {
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3631 public:
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3632 stdio_stream_reader (FILE *f_arg) : stream_reader (), f (f_arg) { }
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3633
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3634 int getc (void) { return ::text_getc (f); }
8447
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
3635 int ungetc (int c)
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
3636 {
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
3637 if (c == '\n')
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
3638 input_line_number--;
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
3639
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
3640 return ::ungetc (c, f);
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
3641 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
3642
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3643 private:
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3644 FILE *f;
12222
91fa3871e9bf oct-parse.yy (class stdio_stream_reader): disallow copying
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
3645
91fa3871e9bf oct-parse.yy (class stdio_stream_reader): disallow copying
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
3646 // No copying!
91fa3871e9bf oct-parse.yy (class stdio_stream_reader): disallow copying
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
3647
91fa3871e9bf oct-parse.yy (class stdio_stream_reader): disallow copying
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
3648 stdio_stream_reader (const stdio_stream_reader&);
91fa3871e9bf oct-parse.yy (class stdio_stream_reader): disallow copying
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
3649
91fa3871e9bf oct-parse.yy (class stdio_stream_reader): disallow copying
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11586
diff changeset
3650 stdio_stream_reader & operator = (const stdio_stream_reader&);
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3651 };
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3652
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3653 static bool
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3654 skip_white_space (stream_reader& reader)
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3655 {
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3656 int c = 0;
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3657
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3658 while ((c = reader.getc ()) != EOF)
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3659 {
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3660 switch (c)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3661 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3662 case ' ':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3663 case '\t':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3664 current_input_column++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3665 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3666
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3667 case '\n':
12638
fd367312095a oct-parse.yy (skip_white_space): Fix column number calculation.
Daniel Kraft <d@domob.eu>
parents: 12627
diff changeset
3668 current_input_column = 1;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3669 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3670
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3671 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3672 reader.ungetc (c);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3673 goto done;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3674 }
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3675 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3676
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3677 done:
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3678
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3679 return (c == EOF);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3680 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3681
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3682 static bool
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3683 looking_at_classdef_keyword (FILE *ffile)
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3684 {
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3685 bool status = false;
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3686
12918
f3a8d1efe2c1 use gnulib:: qualifiers for more stdio functions
John W. Eaton <jwe@octave.org>
parents: 12719
diff changeset
3687 long pos = gnulib::ftell (ffile);
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3688
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3689 char buf [10];
12918
f3a8d1efe2c1 use gnulib:: qualifiers for more stdio functions
John W. Eaton <jwe@octave.org>
parents: 12719
diff changeset
3690 gnulib::fgets (buf, 10, ffile);
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3691 size_t len = strlen (buf);
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3692 if (len > 8 && strncmp (buf, "classdef", 8) == 0
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3693 && ! (isalnum (buf[8]) || buf[8] == '_'))
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3694 status = true;
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3695
12918
f3a8d1efe2c1 use gnulib:: qualifiers for more stdio functions
John W. Eaton <jwe@octave.org>
parents: 12719
diff changeset
3696 gnulib::fseek (ffile, pos, SEEK_SET);
9476
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3697
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3698 return status;
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3699 }
d9b25c5b8ee5 handle classdef syntax in lexer and parser
Ryan Rusaw
parents: 9474
diff changeset
3700
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3701 static std::string
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3702 gobble_leading_white_space (FILE *ffile, bool& eof)
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3703 {
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3704 std::string help_txt;
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3705
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3706 eof = false;
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3707
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3708 // TRUE means we have already cached the help text.
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3709 bool have_help_text = false;
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3710
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3711 std::string txt;
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3712
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3713 stdio_stream_reader stdio_reader (ffile);
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3714
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3715 while (true)
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3716 {
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3717 eof = skip_white_space (stdio_reader);
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3718
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3719 if (eof)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3720 break;
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3721
7723
74f5e0c7de9e first pass at handling block comments
John W. Eaton <jwe@octave.org>
parents: 7720
diff changeset
3722 txt = grab_comment_block (stdio_reader, true, eof);
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3723
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3724 if (txt.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3725 break;
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3726
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3727 if (! (have_help_text || looks_like_copyright (txt)))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3728 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3729 help_txt = txt;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3730 have_help_text = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3731 }
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3732
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3733 octave_comment_buffer::append (txt);
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3734
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3735 if (eof)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3736 break;
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3737 }
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3738
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3739 return help_txt;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3740 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3741
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3742 static bool
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3743 looking_at_function_keyword (FILE *ffile)
5931
25da9a7d5f6d [project @ 2006-08-16 06:52:19 by jwe]
jwe
parents: 5878
diff changeset
3744 {
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3745 bool status = false;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3746
12918
f3a8d1efe2c1 use gnulib:: qualifiers for more stdio functions
John W. Eaton <jwe@octave.org>
parents: 12719
diff changeset
3747 long pos = gnulib::ftell (ffile);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3748
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3749 char buf [10];
12918
f3a8d1efe2c1 use gnulib:: qualifiers for more stdio functions
John W. Eaton <jwe@octave.org>
parents: 12719
diff changeset
3750 gnulib::fgets (buf, 10, ffile);
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3751 size_t len = strlen (buf);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3752 if (len > 8 && strncmp (buf, "function", 8) == 0
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3753 && ! (isalnum (buf[8]) || buf[8] == '_'))
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3754 status = true;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3755
12918
f3a8d1efe2c1 use gnulib:: qualifiers for more stdio functions
John W. Eaton <jwe@octave.org>
parents: 12719
diff changeset
3756 gnulib::fseek (ffile, pos, SEEK_SET);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3757
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3758 return status;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3759 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3760
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3761 static octave_function *
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3762 parse_fcn_file (const std::string& ff, const std::string& dispatch_type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3763 bool force_script = false, bool require_file = true,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3764 const std::string& warn_for = std::string ())
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3765 {
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3766 unwind_protect frame;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3767
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3768 octave_function *fcn_ptr = 0;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3769
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3770 // Open function file and parse.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3771
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3772 FILE *in_stream = command_editor::get_input_stream ();
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3773
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3774 frame.add_fcn (command_editor::set_input_stream, in_stream);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3775
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3776 frame.protect_var (ff_instream);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3777
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3778 frame.protect_var (input_line_number);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3779 frame.protect_var (current_input_column);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3780 frame.protect_var (reading_fcn_file);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3781 frame.protect_var (line_editing);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3782 frame.protect_var (current_class_name);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3783 frame.protect_var (current_function_depth);
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3784 frame.protect_var (function_scopes);
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3785 frame.protect_var (max_function_depth);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3786 frame.protect_var (parsing_subfunctions);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3787 frame.protect_var (endfunction_found);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3788
8447
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
3789 input_line_number = 1;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3790 current_input_column = 1;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3791 reading_fcn_file = true;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3792 line_editing = false;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3793 current_class_name = dispatch_type;
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3794 current_function_depth = 0;
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
3795 function_scopes.clear ();
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3796 max_function_depth = 0;
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3797 parsing_subfunctions = false;
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
3798 endfunction_found = false;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3799
12989
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12973
diff changeset
3800 frame.add_fcn (command_history::ignore_entries,
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12973
diff changeset
3801 command_history::ignoring_entries ());
00235a6446da eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents: 12973
diff changeset
3802
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3803 command_history::ignore_entries ();
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3804
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3805 FILE *ffile = get_input_from_file (ff, 0);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3806
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
3807 frame.add_fcn (safe_fclose, ffile);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3808
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3809 if (ffile)
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3810 {
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3811 bool eof;
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3812
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3813 std::string help_txt = gobble_leading_white_space (ffile, eof);
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3814
10872
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3815 if (! help_txt.empty ())
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3816 help_buf.push (help_txt);
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3817
7720
4e2eafef689c unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents: 7719
diff changeset
3818 if (! eof)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3819 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3820 std::string file_type;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3821
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3822 frame.protect_var (get_input_from_eval_string);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3823 frame.protect_var (parser_end_of_input);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3824 frame.protect_var (reading_fcn_file);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3825 frame.protect_var (reading_script_file);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3826 frame.protect_var (reading_classdef_file);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3827 frame.protect_var (Vecho_executing_commands);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3828
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3829
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3830 get_input_from_eval_string = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3831 parser_end_of_input = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3832
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3833 if (! force_script && looking_at_function_keyword (ffile))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3834 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3835 file_type = "function";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3836
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3837 Vecho_executing_commands = ECHO_OFF;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3838
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3839 reading_classdef_file = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3840 reading_fcn_file = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3841 reading_script_file = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3842 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3843 else if (! force_script && looking_at_classdef_keyword (ffile))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3844 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3845 file_type = "classdef";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3846
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3847 Vecho_executing_commands = ECHO_OFF;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3848
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3849 reading_classdef_file = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3850 reading_fcn_file = false;
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3851 reading_script_file = false;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3852 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3853 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3854 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3855 file_type = "script";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3856
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3857 Vecho_executing_commands = ECHO_OFF;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3858
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3859 reading_classdef_file = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3860 reading_fcn_file = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3861 reading_script_file = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3862 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3863
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3864 YY_BUFFER_STATE old_buf = current_buffer ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3865 YY_BUFFER_STATE new_buf = create_buffer (ffile);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3866
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3867 frame.add_fcn (switch_to_buffer, old_buf);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3868 frame.add_fcn (delete_buffer, new_buf);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3869
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3870 switch_to_buffer (new_buf);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3871
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3872 frame.protect_var (primary_fcn_ptr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3873 primary_fcn_ptr = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3874
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3875 frame.protect_var (classdef_object);
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3876 classdef_object = 0;
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3877
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3878 reset_parser ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3879
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3880 // Do this with an unwind-protect cleanup function so that
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3881 // the forced variables will be unmarked in the event of an
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
3882 // interrupt.
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3883 symbol_table::scope_id scope = symbol_table::top_scope ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3884 frame.add_fcn (symbol_table::unmark_forced_variables, scope);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3885
10879
5af852c93af3 oct-parse.yy: Restore parsing of help text.
Rik <octave@nomad.inbox5.com>
parents: 10872
diff changeset
3886 if (! help_txt.empty ())
5af852c93af3 oct-parse.yy: Restore parsing of help text.
Rik <octave@nomad.inbox5.com>
parents: 10872
diff changeset
3887 help_buf.push (help_txt);
5af852c93af3 oct-parse.yy: Restore parsing of help text.
Rik <octave@nomad.inbox5.com>
parents: 10872
diff changeset
3888
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3889 if (reading_script_file)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3890 prep_lexer_for_script_file ();
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3891 else if (reading_classdef_file)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3892 prep_lexer_for_classdef_file ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3893 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3894 prep_lexer_for_function_file ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3895
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3896 lexer_flags.parsing_class_method = ! dispatch_type.empty ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3897
11258
795c97ace02c eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents: 11225
diff changeset
3898 frame.protect_var (global_command);
795c97ace02c eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents: 11225
diff changeset
3899
795c97ace02c eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents: 11225
diff changeset
3900 global_command = 0;
795c97ace02c eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents: 11225
diff changeset
3901
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3902 int status = yyparse ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3903
13970
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
3904 // Use an unwind-protect cleanup function so that the
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
3905 // global_command list will be deleted in the event of an
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
3906 // interrupt.
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
3907
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
3908 frame.add_fcn (cleanup_statement_list, &global_command);
11258
795c97ace02c eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents: 11225
diff changeset
3909
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3910 fcn_ptr = primary_fcn_ptr;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3911
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3912 if (status == 0)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3913 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3914 if (reading_classdef_file && classdef_object)
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3915 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3916 // Convert parse tree for classdef object to
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3917 // meta.class info (and stash it in the symbol
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3918 // table?). Return pointer to constructor?
15869
5e5705b3e505 Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15576
diff changeset
3919
5e5705b3e505 Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15576
diff changeset
3920 if (fcn_ptr)
5e5705b3e505 Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15576
diff changeset
3921 panic_impossible ();
5e5705b3e505 Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15576
diff changeset
3922
5e5705b3e505 Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15576
diff changeset
3923 fcn_ptr = classdef_object->make_meta_class ();
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3924 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3925 }
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3926 else
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3927 {
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3928 error ("parse error while reading %s file %s",
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3929 file_type.c_str(), ff.c_str ());
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 14846
diff changeset
3930 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3931 }
10872
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3932 else
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3933 {
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3934 tree_statement *end_of_script
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3935 = make_end ("endscript", input_line_number, current_input_column);
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3936
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3937 make_script (0, end_of_script);
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3938
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3939 fcn_ptr = primary_fcn_ptr;
988d16d5ae34 correctly .m files that are empty or contain only comments
John W. Eaton <jwe@octave.org>
parents: 10659
diff changeset
3940 }
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3941 }
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3942 else if (require_file)
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
3943 error ("no such file, '%s'", ff.c_str ());
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3944 else if (! warn_for.empty ())
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
3945 error ("%s: unable to open file '%s'", warn_for.c_str (), ff.c_str ());
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3946
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
3947 return fcn_ptr;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3948 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
3949
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
3950 std::string
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3951 get_help_from_file (const std::string& nm, bool& symbol_found,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3952 std::string& file)
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3953 {
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3954 std::string retval;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3955
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3956 file = fcn_file_in_path (nm);
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3957
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3958 if (! file.empty ())
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3959 {
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3960 symbol_found = true;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3961
14153
06aa17228706 use gnulib::fopen
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
3962 FILE *fptr = gnulib::fopen (file.c_str (), "r");
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3963
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3964 if (fptr)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3965 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3966 unwind_protect frame;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3967 frame.add_fcn (safe_fclose, fptr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3968
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3969 bool eof;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3970 retval = gobble_leading_white_space (fptr, eof);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3971
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3972 if (retval.empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3973 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3974 octave_function *fcn = parse_fcn_file (file, "");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3975
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3976 if (fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3977 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3978 retval = fcn->doc_string ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3979
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3980 delete fcn;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3981 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3982 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
3983 }
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3984 }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3985
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3986 return retval;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3987 }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3988
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3989 std::string
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3990 get_help_from_file (const std::string& nm, bool& symbol_found)
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3991 {
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3992 std::string file;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3993 return get_help_from_file (nm, symbol_found, file);
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3994 }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3995
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
3996 std::string
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
3997 lookup_autoload (const std::string& nm)
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
3998 {
5626
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
3999 std::string retval;
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4000
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4001 typedef std::map<std::string, std::string>::const_iterator am_iter;
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4002
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4003 am_iter p = autoload_map.find (nm);
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4004
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4005 if (p != autoload_map.end ())
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6238
diff changeset
4006 retval = load_path::find_file (p->second);
5626
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4007
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4008 return retval;
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4009 }
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4010
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
4011 string_vector
5592
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4012 autoloaded_functions (void)
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4013 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14584
diff changeset
4014 string_vector names (autoload_map.size ());
5592
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4015
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4016 octave_idx_type i = 0;
5626
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4017 typedef std::map<std::string, std::string>::const_iterator am_iter;
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4018 for (am_iter p = autoload_map.begin (); p != autoload_map.end (); p++)
5592
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4019 names[i++] = p->first;
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4020
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4021 return names;
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4022 }
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4023
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4024 string_vector
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4025 reverse_lookup_autoload (const std::string& nm)
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4026 {
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4027 string_vector names;
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4028
5626
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4029 typedef std::map<std::string, std::string>::const_iterator am_iter;
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4030 for (am_iter p = autoload_map.begin (); p != autoload_map.end (); p++)
5592
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4031 if (nm == p->second)
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4032 names.append (p->first);
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4033
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4034 return names;
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4035 }
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
4036
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4037 octave_function *
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4038 load_fcn_from_file (const std::string& file_name, const std::string& dir_name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4039 const std::string& dispatch_type,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4040 const std::string& fcn_name, bool autoload)
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4041 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4042 octave_function *retval = 0;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4043
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4044 unwind_protect frame;
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4045
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4046 std::string nm = file_name;
6238
3ecd8d2c5654 [project @ 2007-01-10 21:13:21 by jwe]
jwe
parents: 6235
diff changeset
4047
3ecd8d2c5654 [project @ 2007-01-10 21:13:21 by jwe]
jwe
parents: 6235
diff changeset
4048 size_t nm_len = nm.length ();
5472
e2f85b298a74 [project @ 2005-09-23 21:10:36 by jwe]
jwe
parents: 5400
diff changeset
4049
e2f85b298a74 [project @ 2005-09-23 21:10:36 by jwe]
jwe
parents: 5400
diff changeset
4050 std::string file;
e2f85b298a74 [project @ 2005-09-23 21:10:36 by jwe]
jwe
parents: 5400
diff changeset
4051
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4052 frame.protect_var (fcn_file_from_relative_lookup);
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6238
diff changeset
4053
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6238
diff changeset
4054 fcn_file_from_relative_lookup = false;
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6238
diff changeset
4055
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4056 file = nm;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4057
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4058 if ((nm_len > 4 && nm.substr (nm_len-4) == ".oct")
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4059 || (nm_len > 4 && nm.substr (nm_len-4) == ".mex")
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4060 || (nm_len > 2 && nm.substr (nm_len-2) == ".m"))
5472
e2f85b298a74 [project @ 2005-09-23 21:10:36 by jwe]
jwe
parents: 5400
diff changeset
4061 {
6238
3ecd8d2c5654 [project @ 2007-01-10 21:13:21 by jwe]
jwe
parents: 6235
diff changeset
4062 nm = octave_env::base_pathname (file);
3ecd8d2c5654 [project @ 2007-01-10 21:13:21 by jwe]
jwe
parents: 6235
diff changeset
4063 nm = nm.substr (0, nm.find_last_of ('.'));
11136
a51ac4198e1c oct-parse.yy (load_fcn_from_file): also strip directory when computing function name from filename
John W. Eaton <jwe@octave.org>
parents: 11091
diff changeset
4064
a51ac4198e1c oct-parse.yy (load_fcn_from_file): also strip directory when computing function name from filename
John W. Eaton <jwe@octave.org>
parents: 11091
diff changeset
4065 size_t pos = nm.find_last_of (file_ops::dir_sep_str ());
a51ac4198e1c oct-parse.yy (load_fcn_from_file): also strip directory when computing function name from filename
John W. Eaton <jwe@octave.org>
parents: 11091
diff changeset
4066 if (pos != std::string::npos)
11138
40206fe759db oct-parse.yy: fix typo in previous change
John W. Eaton <jwe@octave.org>
parents: 11136
diff changeset
4067 nm = nm.substr (pos+1);
5472
e2f85b298a74 [project @ 2005-09-23 21:10:36 by jwe]
jwe
parents: 5400
diff changeset
4068 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4069
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4070 if (autoload)
5472
e2f85b298a74 [project @ 2005-09-23 21:10:36 by jwe]
jwe
parents: 5400
diff changeset
4071 {
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4072 frame.protect_var (autoloading);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4073 autoloading = true;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4074 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4075
7749
14e05160b99f reference counting for functions loaded from shared libraries
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
4076 fcn_file_from_relative_lookup = ! octave_env::absolute_pathname (file);
14e05160b99f reference counting for functions loaded from shared libraries
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
4077
10250
2d47356a7a1a use gnulib getcwd module
John W. Eaton <jwe@octave.org>
parents: 10230
diff changeset
4078 file = octave_env::make_absolute (file);
4243
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4240
diff changeset
4079
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4240
diff changeset
4080 int len = file.length ();
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4240
diff changeset
4081
4244
189df16144fc [project @ 2002-12-28 02:00:05 by jwe]
jwe
parents: 4243
diff changeset
4082 if (len > 4 && file.substr (len-4, len-1) == ".oct")
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4083 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4084 if (autoload && ! fcn_name.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4085 nm = fcn_name;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4086
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4087 retval = octave_dynamic_loader::load_oct (nm, file, fcn_file_from_relative_lookup);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents: 5861
diff changeset
4088 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents: 5861
diff changeset
4089 else if (len > 4 && file.substr (len-4, len-1) == ".mex")
10570
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4090 {
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4091 // Temporarily load m-file version of mex-file, if it exists,
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4092 // to get the help-string to use.
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4093 frame.protect_var (curr_fcn_file_name);
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4094 frame.protect_var (curr_fcn_file_full_name);
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4095
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4096 curr_fcn_file_name = nm;
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4097 curr_fcn_file_full_name = file.substr (0, len - 2);
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4098
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
4099 octave_function *tmpfcn = parse_fcn_file (file.substr (0, len - 2),
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
4100 dispatch_type, autoloading,
10570
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4101 false);
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4102
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4103 retval = octave_dynamic_loader::load_mex (nm, file, fcn_file_from_relative_lookup);
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4104
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4105 if (tmpfcn)
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4106 retval->document (tmpfcn->doc_string ());
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4107 delete tmpfcn;
a61d7248627c When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
David Bateman <dbateman@free.fr>
parents: 10521
diff changeset
4108 }
4244
189df16144fc [project @ 2002-12-28 02:00:05 by jwe]
jwe
parents: 4243
diff changeset
4109 else if (len > 2)
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4110 {
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4111 // These are needed by yyparse.
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4112
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4113 frame.protect_var (curr_fcn_file_name);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4114 frame.protect_var (curr_fcn_file_full_name);
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4115
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4116 curr_fcn_file_name = nm;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4117 curr_fcn_file_full_name = file;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4118
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4119 retval = parse_fcn_file (file, dispatch_type, autoloading);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4120 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4121
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4122 if (retval)
8819
96d87674b818 also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
4123 {
96d87674b818 also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
4124 retval->stash_dir_name (dir_name);
96d87674b818 also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
4125
96d87674b818 also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
4126 if (retval->is_user_function ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4127 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4128 symbol_table::scope_id id = retval->scope ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4129
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4130 symbol_table::stash_dir_name_for_subfunctions (id, dir_name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4131 }
8819
96d87674b818 also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
4132 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4133
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4134 return retval;
5312
80c1aa832cb2 [project @ 2005-04-28 01:54:46 by jwe]
jwe
parents: 5309
diff changeset
4135 }
80c1aa832cb2 [project @ 2005-04-28 01:54:46 by jwe]
jwe
parents: 5309
diff changeset
4136
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8745
diff changeset
4137 DEFUN (autoload, args, ,
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4138 "-*- texinfo -*-\n\
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4139 @deftypefn {Built-in Function} {} autoload (@var{function}, @var{file})\n\
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4140 Define @var{function} to autoload from @var{file}.\n\
5626
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4141 \n\
6926
c05fbb1b7e1f [project @ 2007-09-26 19:56:54 by dbateman]
dbateman
parents: 6657
diff changeset
4142 The second argument, @var{file}, should be an absolute file name or\n\
c05fbb1b7e1f [project @ 2007-09-26 19:56:54 by dbateman]
dbateman
parents: 6657
diff changeset
4143 a file name in the same directory as the function or script from which\n\
9038
fca0dc2fb042 Cleanup documentation files stmt.texi and func.texi
Rik <rdrider0-list@yahoo.com>
parents: 8974
diff changeset
4144 the autoload command was run. @var{file} should not depend on the\n\
6926
c05fbb1b7e1f [project @ 2007-09-26 19:56:54 by dbateman]
dbateman
parents: 6657
diff changeset
4145 Octave load path.\n\
6380
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4146 \n\
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4147 Normally, calls to @code{autoload} appear in PKG_ADD script files that\n\
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4148 are evaluated when a directory is added to the Octave's load path. To\n\
6926
c05fbb1b7e1f [project @ 2007-09-26 19:56:54 by dbateman]
dbateman
parents: 6657
diff changeset
4149 avoid having to hardcode directory names in @var{file}, if @var{file}\n\
c05fbb1b7e1f [project @ 2007-09-26 19:56:54 by dbateman]
dbateman
parents: 6657
diff changeset
4150 is in the same directory as the PKG_ADD script then\n\
6380
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4151 \n\
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4152 @example\n\
6926
c05fbb1b7e1f [project @ 2007-09-26 19:56:54 by dbateman]
dbateman
parents: 6657
diff changeset
4153 autoload (\"foo\", \"bar.oct\");\n\
6380
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4154 @end example\n\
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4155 \n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
4156 @noindent\n\
9038
fca0dc2fb042 Cleanup documentation files stmt.texi and func.texi
Rik <rdrider0-list@yahoo.com>
parents: 8974
diff changeset
4157 will load the function @code{foo} from the file @code{bar.oct}. The above\n\
6926
c05fbb1b7e1f [project @ 2007-09-26 19:56:54 by dbateman]
dbateman
parents: 6657
diff changeset
4158 when @code{bar.oct} is not in the same directory or uses like\n\
6380
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4159 \n\
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4160 @example\n\
6637
c18ed0e7ee41 [project @ 2007-05-21 19:12:46 by jwe]
jwe
parents: 6431
diff changeset
4161 autoload (\"foo\", file_in_loadpath (\"bar.oct\"))\n\
6380
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4162 @end example\n\
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4163 \n\
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4164 @noindent\n\
6926
c05fbb1b7e1f [project @ 2007-09-26 19:56:54 by dbateman]
dbateman
parents: 6657
diff changeset
4165 are strongly discouraged, as their behavior might be unpredictable.\n\
6380
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4166 \n\
6637
c18ed0e7ee41 [project @ 2007-05-21 19:12:46 by jwe]
jwe
parents: 6431
diff changeset
4167 With no arguments, return a structure containing the current autoload map.\n\
6380
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4168 @seealso{PKG_ADD}\n\
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4169 @end deftypefn")
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4170 {
5626
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4171 octave_value retval;
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4172
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4173 int nargin = args.length ();
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4174
5626
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4175 if (nargin == 0)
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4176 {
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
4177 Cell func_names (dim_vector (autoload_map.size (), 1));
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
4178 Cell file_names (dim_vector (autoload_map.size (), 1));
5626
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4179
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4180 octave_idx_type i = 0;
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4181 typedef std::map<std::string, std::string>::const_iterator am_iter;
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4182 for (am_iter p = autoload_map.begin (); p != autoload_map.end (); p++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4183 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4184 func_names(i) = p->first;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4185 file_names(i) = p->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4186
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4187 i++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4188 }
5626
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4189
11060
54697b37d8bf replace Octave_map->octave_scalar_map in oct-parse.yy and ov-fcn-handle.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10879
diff changeset
4190 octave_map m;
5626
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4191
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4192 m.assign ("function", func_names);
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4193 m.assign ("file", file_names);
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4194
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4195 retval = m;
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4196 }
3236b4d98fde [project @ 2006-02-15 20:25:39 by jwe]
jwe
parents: 5615
diff changeset
4197 else if (nargin == 2)
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4198 {
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4199 string_vector argv = args.make_argv ("autoload");
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4200
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4201 if (! error_state)
6380
ac3d67504f85 [project @ 2007-03-02 22:08:06 by jwe]
jwe
parents: 6379
diff changeset
4202 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4203 std::string nm = argv[2];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4204
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4205 if (! octave_env::absolute_pathname (nm))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4206 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4207 octave_user_code *fcn = octave_call_stack::caller_user_code ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4208
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4209 bool found = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4210
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4211 if (fcn)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4212 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4213 std::string fname = fcn->fcn_file_name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4214
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4215 if (! fname.empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4216 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4217 fname = octave_env::make_absolute (fname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4218 fname = fname.substr (0, fname.find_last_of (file_ops::dir_sep_str ()) + 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4219
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4220 file_stat fs (fname + nm);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4221
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4222 if (fs.exists ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4223 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4224 nm = fname + nm;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4225 found = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4226 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4227 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4228 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4229 if (! found)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4230 warning_with_id ("Octave:autoload-relative-file-name",
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
4231 "autoload: '%s' is not an absolute file name",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4232 nm.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4233 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4234 autoload_map[argv[1]] = nm;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4235 }
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4236 }
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4237 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
4238 print_usage ();
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4239
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4240 return retval;
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4241 }
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5472
diff changeset
4242
4486
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4463
diff changeset
4243 void
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4244 source_file (const std::string& file_name, const std::string& context,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4245 bool verbose, bool require_file, const std::string& warn_for)
4486
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4463
diff changeset
4246 {
10578
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4247 // Map from absolute name of script file to recursion level. We
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4248 // use a map instead of simply placing a limit on recursion in the
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4249 // source_file function so that two mutually recursive scripts
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4250 // written as
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4251 //
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4252 // foo1.m:
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4253 // ------
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4254 // foo2
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4255 //
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4256 // foo2.m:
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4257 // ------
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4258 // foo1
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4259 //
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4260 // and called with
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4261 //
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4262 // foo1
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4263 //
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4264 // (for example) will behave the same if they are written as
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4265 //
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4266 // foo1.m:
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4267 // ------
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4268 // source ("foo2.m")
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4269 //
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4270 // foo2.m:
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4271 // ------
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4272 // source ("foo1.m")
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4273 //
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4274 // and called with
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4275 //
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4276 // source ("foo1.m")
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4277 //
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4278 // (for example).
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4279
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4280 static std::map<std::string, int> source_call_depth;
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4281
4486
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4463
diff changeset
4282 std::string file_full_name = file_ops::tilde_expand (file_name);
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4463
diff changeset
4283
10578
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4284 file_full_name = octave_env::make_absolute (file_full_name);
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4285
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4286 unwind_protect frame;
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4287
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4288 frame.protect_var (curr_fcn_file_name);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4289 frame.protect_var (curr_fcn_file_full_name);
4486
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4463
diff changeset
4290
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4463
diff changeset
4291 curr_fcn_file_name = file_name;
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4463
diff changeset
4292 curr_fcn_file_full_name = file_full_name;
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4463
diff changeset
4293
10578
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4294 if (source_call_depth.find (file_full_name) == source_call_depth.end ())
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4295 source_call_depth[file_full_name] = -1;
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4296
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4297 frame.protect_var (source_call_depth[file_full_name]);
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4298
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4299 source_call_depth[file_full_name]++;
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4300
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4301 if (source_call_depth[file_full_name] >= Vmax_recursion_depth)
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4302 {
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4303 error ("max_recursion_depth exceeded");
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4304 return;
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4305 }
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10570
diff changeset
4306
5975
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5932
diff changeset
4307 if (! context.empty ())
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5932
diff changeset
4308 {
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5932
diff changeset
4309 if (context == "caller")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4310 octave_call_stack::goto_caller_frame ();
5975
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5932
diff changeset
4311 else if (context == "base")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4312 octave_call_stack::goto_base_frame ();
5975
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5932
diff changeset
4313 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4314 error ("source: context must be \"caller\" or \"base\"");
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4315
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4316 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4317 frame.add_fcn (octave_call_stack::pop);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
4318 }
5975
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5932
diff changeset
4319
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5932
diff changeset
4320 if (! error_state)
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5932
diff changeset
4321 {
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4322 octave_function *fcn = parse_fcn_file (file_full_name, "", true,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4323 require_file, warn_for);
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4324
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4325 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4326 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4327 if (fcn && fcn->is_user_script ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4328 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4329 octave_value_list args;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4330
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4331 if (verbose)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4332 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4333 std::cout << "executing commands from " << file_full_name << " ... ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4334 reading_startup_message_printed = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4335 std::cout.flush ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4336 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4337
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4338 fcn->do_multi_index_op (0, args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4339
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4340 if (verbose)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4341 std::cout << "done." << std::endl;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4342
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4343 delete fcn;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4344 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4345 }
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7699
diff changeset
4346 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
4347 error ("source: error sourcing file '%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4348 file_full_name.c_str ());
5975
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5932
diff changeset
4349 }
4486
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4463
diff changeset
4350 }
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4463
diff changeset
4351
5739
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4352 DEFUN (mfilename, args, ,
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4353 "-*- texinfo -*-\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
4354 @deftypefn {Built-in Function} {} mfilename ()\n\
12719
7b5bfd6a8e28 doc: Don't use @code macro within @deftypefn macro
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
4355 @deftypefnx {Built-in Function} {} mfilename (\"fullpath\")\n\
7b5bfd6a8e28 doc: Don't use @code macro within @deftypefn macro
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
4356 @deftypefnx {Built-in Function} {} mfilename (\"fullpathext\")\n\
5739
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4357 Return the name of the currently executing file. At the top-level,\n\
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4358 return the empty string. Given the argument @code{\"fullpath\"},\n\
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4359 include the directory part of the file name, but not the extension.\n\
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4360 Given the argument @code{\"fullpathext\"}, include the directory part\n\
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4361 of the file name and the extension.\n\
5774
e7af222e98b0 [project @ 2006-04-24 17:45:31 by jwe]
jwe
parents: 5765
diff changeset
4362 @end deftypefn")
5739
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4363 {
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4364 octave_value retval;
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4365
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4366 int nargin = args.length ();
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4367
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4368 if (nargin > 1)
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4369 {
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
4370 print_usage ();
5739
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4371 return retval;
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4372 }
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4373
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4374 std::string arg;
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4375
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4376 if (nargin == 1)
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4377 {
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4378 arg = args(0).string_value ();
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4379
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4380 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4381 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4382 error ("mfilename: expecting argument to be a character string");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4383 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4384 }
5739
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4385 }
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4386
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4387 std::string fname;
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4388
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
4389 octave_user_code *fcn = octave_call_stack::caller_user_code ();
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5739
diff changeset
4390
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5739
diff changeset
4391 if (fcn)
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5739
diff changeset
4392 {
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5739
diff changeset
4393 fname = fcn->fcn_file_name ();
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5739
diff changeset
4394
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5739
diff changeset
4395 if (fname.empty ())
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5739
diff changeset
4396 fname = fcn->name ();
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5739
diff changeset
4397 }
5739
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4398
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4399 if (arg == "fullpathext")
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4400 retval = fname;
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4401 else
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4402 {
8007
a2ab20ba78f7 make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents: 8001
diff changeset
4403 size_t dpos = fname.rfind (file_ops::dir_sep_char ());
5747
b09d4d0f5b63 [project @ 2006-04-07 06:43:10 by jwe]
jwe
parents: 5744
diff changeset
4404 size_t epos = fname.rfind ('.');
b09d4d0f5b63 [project @ 2006-04-07 06:43:10 by jwe]
jwe
parents: 5744
diff changeset
4405
b09d4d0f5b63 [project @ 2006-04-07 06:43:10 by jwe]
jwe
parents: 5744
diff changeset
4406 if (epos <= dpos)
8021
85184151822e fix typo in NPOS change
John W. Eaton <jwe@octave.org>
parents: 8019
diff changeset
4407 epos = std::string::npos;
85184151822e fix typo in NPOS change
John W. Eaton <jwe@octave.org>
parents: 8019
diff changeset
4408
85184151822e fix typo in NPOS change
John W. Eaton <jwe@octave.org>
parents: 8019
diff changeset
4409 fname = (epos != std::string::npos) ? fname.substr (0, epos) : fname;
5739
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4410
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4411 if (arg == "fullpath")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4412 retval = fname;
5739
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4413 else
8021
85184151822e fix typo in NPOS change
John W. Eaton <jwe@octave.org>
parents: 8019
diff changeset
4414 retval = (dpos != std::string::npos) ? fname.substr (dpos+1) : fname;
5739
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4415 }
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4416
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4417 return retval;
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4418 }
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4419
d090d39bb82c [project @ 2006-04-05 06:56:24 by jwe]
jwe
parents: 5667
diff changeset
4420
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4421 DEFUN (source, args, ,
3371
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4422 "-*- texinfo -*-\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4423 @deftypefn {Built-in Function} {} source (@var{file})\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4424 Parse and execute the contents of @var{file}. This is equivalent to\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4425 executing commands from a script file, but without requiring the file to\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4426 be named @file{@var{file}.m}.\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4427 @end deftypefn")
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4428 {
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4429 octave_value_list retval;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4430
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4431 int nargin = args.length ();
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4432
5975
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5932
diff changeset
4433 if (nargin == 1 || nargin == 2)
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4434 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
4435 std::string file_name = args(0).string_value ();
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4436
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4437 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4438 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4439 std::string context;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4440
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4441 if (nargin == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4442 context = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4443
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4444 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4445 source_file (file_name, context);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4446 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4447 error ("source: expecting context to be character string");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4448 }
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4449 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4450 error ("source: expecting file name as argument");
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4451 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4452 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
4453 print_usage ();
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4454
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4455 return retval;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4456 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4457
3726
b7d997d593d9 [project @ 2000-10-27 17:51:21 by jwe]
jwe
parents: 3712
diff changeset
4458 // Evaluate an Octave function (built-in or interpreted) and return
3844
87f85453b6b7 [project @ 2001-07-23 20:07:45 by jwe]
jwe
parents: 3815
diff changeset
4459 // the list of result values. NAME is the name of the function to
87f85453b6b7 [project @ 2001-07-23 20:07:45 by jwe]
jwe
parents: 3815
diff changeset
4460 // call. ARGS are the arguments to the function. NARGOUT is the
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
4461 // number of output arguments expected.
3726
b7d997d593d9 [project @ 2000-10-27 17:51:21 by jwe]
jwe
parents: 3712
diff changeset
4462
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4463 octave_value_list
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
4464 feval (const std::string& name, const octave_value_list& args, int nargout)
3156
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3110
diff changeset
4465 {
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3110
diff changeset
4466 octave_value_list retval;
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3110
diff changeset
4467
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4468 octave_value fcn = symbol_table::find_function (name, args);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4469
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4470 if (fcn.is_defined ())
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4471 retval = fcn.do_multi_index_op (nargout, args);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
4472 else
10443
34e51d4e199b implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents: 10426
diff changeset
4473 {
34e51d4e199b implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents: 10426
diff changeset
4474 maybe_missing_function_hook (name);
34e51d4e199b implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents: 10426
diff changeset
4475 if (! error_state)
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
4476 error ("feval: function '%s' not found", name.c_str ());
10443
34e51d4e199b implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents: 10426
diff changeset
4477 }
3156
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3110
diff changeset
4478
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3110
diff changeset
4479 return retval;
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3110
diff changeset
4480 }
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3110
diff changeset
4481
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4482 octave_value_list
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4483 feval (octave_function *fcn, const octave_value_list& args, int nargout)
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4484 {
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4485 octave_value_list retval;
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4486
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4487 if (fcn)
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4488 retval = fcn->do_multi_index_op (nargout, args);
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4489
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4490 return retval;
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4491 }
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4492
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4493 static octave_value_list
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4494 get_feval_args (const octave_value_list& args)
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4495 {
10659
8baff2aceabc fix slicing value lists with name tags (bug #29960)
Jaroslav Hajek <highegg@gmail.com>
parents: 10578
diff changeset
4496 return args.slice (1, args.length () - 1, true);
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4497 }
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4498
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4499
3726
b7d997d593d9 [project @ 2000-10-27 17:51:21 by jwe]
jwe
parents: 3712
diff changeset
4500 // Evaluate an Octave function (built-in or interpreted) and return
b7d997d593d9 [project @ 2000-10-27 17:51:21 by jwe]
jwe
parents: 3712
diff changeset
4501 // the list of result values. The first element of ARGS should be a
b7d997d593d9 [project @ 2000-10-27 17:51:21 by jwe]
jwe
parents: 3712
diff changeset
4502 // string containing the name of the function to call, then the rest
b7d997d593d9 [project @ 2000-10-27 17:51:21 by jwe]
jwe
parents: 3712
diff changeset
4503 // are the actual arguments to the function. NARGOUT is the number of
b7d997d593d9 [project @ 2000-10-27 17:51:21 by jwe]
jwe
parents: 3712
diff changeset
4504 // output arguments expected.
b7d997d593d9 [project @ 2000-10-27 17:51:21 by jwe]
jwe
parents: 3712
diff changeset
4505
3156
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3110
diff changeset
4506 octave_value_list
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4507 feval (const octave_value_list& args, int nargout)
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4508 {
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4509 octave_value_list retval;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4510
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4511 int nargin = args.length ();
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4512
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4513 if (nargin > 0)
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4514 {
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4515 octave_value f_arg = args(0);
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4516
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4517 if (f_arg.is_string ())
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4318
diff changeset
4518 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4519 std::string name = f_arg.string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4520
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4521 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4522 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4523 octave_value_list tmp_args = get_feval_args (args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4524
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4525 retval = feval (name, tmp_args, nargout);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4526 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4527 }
13241
2a8dcb5b3a00 improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents: 13237
diff changeset
4528 else if (f_arg.is_function_handle ()
2a8dcb5b3a00 improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents: 13237
diff changeset
4529 || f_arg.is_anonymous_function ()
2a8dcb5b3a00 improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents: 13237
diff changeset
4530 || f_arg.is_inline_function ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4531 {
10492
a6b64a7a3769 make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents: 10463
diff changeset
4532 const octave_value_list tmp_args = get_feval_args (args);
a6b64a7a3769 make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents: 10463
diff changeset
4533
a6b64a7a3769 make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents: 10463
diff changeset
4534 retval = f_arg.do_multi_index_op (nargout, tmp_args);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4535 }
10492
a6b64a7a3769 make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents: 10463
diff changeset
4536 else
a6b64a7a3769 make feval work with overloaded handles
Jaroslav Hajek <highegg@gmail.com>
parents: 10463
diff changeset
4537 error ("feval: first argument must be a string, inline function or a function handle");
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4538 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4539
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4540 return retval;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4541 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4542
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4543 DEFUN (feval, args, nargout,
3371
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4544 "-*- texinfo -*-\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4545 @deftypefn {Built-in Function} {} feval (@var{name}, @dots{})\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4546 Evaluate the function named @var{name}. Any arguments after the first\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4547 are passed on to the named function. For example,\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4548 \n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4549 @example\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
4550 @group\n\
3371
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4551 feval (\"acos\", -1)\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4552 @result{} 3.1416\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
4553 @end group\n\
3371
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4554 @end example\n\
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4555 \n\
3371
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4556 @noindent\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4557 calls the function @code{acos} with the argument @samp{-1}.\n\
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4558 \n\
12946
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4559 The function @code{feval} can also be used with function handles of\n\
13019
1653d3a86fca doc: Fix warnings and errors in Texinfo required for building docs on stable branch.
Rik <octave@nomad.inbox5.com>
parents: 12946
diff changeset
4560 any sort (@pxref{Function Handles}). Historically, @code{feval} was\n\
12946
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4561 the only way to call user-supplied functions in strings, but\n\
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4562 function handles are now preferred due to the cleaner syntax they\n\
13019
1653d3a86fca doc: Fix warnings and errors in Texinfo required for building docs on stable branch.
Rik <octave@nomad.inbox5.com>
parents: 12946
diff changeset
4563 offer. For example,\n\
12946
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4564 \n\
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4565 @example\n\
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4566 @group\n\
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4567 @var{f} = @@exp;\n\
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4568 feval (@var{f}, 1)\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14329
diff changeset
4569 @result{} 2.7183\n\
12946
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4570 @var{f} (1)\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14329
diff changeset
4571 @result{} 2.7183\n\
12946
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4572 @end group\n\
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4573 @end example\n\
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4574 \n\
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4575 @noindent\n\
13019
1653d3a86fca doc: Fix warnings and errors in Texinfo required for building docs on stable branch.
Rik <octave@nomad.inbox5.com>
parents: 12946
diff changeset
4576 are equivalent ways to call the function referred to by @var{f}. If it\n\
12946
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4577 cannot be predicted beforehand that @var{f} is a function handle or the\n\
8b5b85e26246 octave-parse.yy (feval): Update docstring to refer to function handles.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12918
diff changeset
4578 function name in a string, @code{feval} can be used instead.\n\
3371
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4579 @end deftypefn")
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4580 {
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4581 octave_value_list retval;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4582
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4583 int nargin = args.length ();
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4584
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4585 if (nargin > 0)
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4586 retval = feval (args, nargout);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4587 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
4588 print_usage ();
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4589
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4590 return retval;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4591 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4592
11225
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4593 DEFUN (builtin, args, nargout,
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4594 "-*- texinfo -*-\n\
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4595 @deftypefn {Loadable Function} {[@dots{}]} builtin (@var{f}, @dots{})\n\
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4596 Call the base function @var{f} even if @var{f} is overloaded to\n\
11388
027fbc389898 Remove seealso reference to deprecated function dispatch.
Rik <octave@nomad.inbox5.com>
parents: 11367
diff changeset
4597 another function for the given type signature.\n\
11225
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4598 @end deftypefn")
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4599 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
4600 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
4601
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4602 int nargin = args.length ();
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4603
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4604 if (nargin > 0)
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4605 {
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4606 const std::string name (args(0).string_value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
4607
11225
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4608 if (! error_state)
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4609 {
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4610 octave_value fcn = symbol_table::builtin_find (name);
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4611
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4612 if (fcn.is_defined ())
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4613 retval = feval (fcn.function_value (), args.splice (0, 1),
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4614 nargout);
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4615 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14189
diff changeset
4616 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
4617 }
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4618 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12400
diff changeset
4619 error ("builtin: function name (F) must be a string");
11225
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4620 }
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4621 else
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4622 print_usage ();
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4623
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4624 return retval;
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4625 }
8d8e10058df6 move builtin function from dispatch.cc to oct-parse.yy
John W. Eaton <jwe@octave.org>
parents: 11138
diff changeset
4626
3099
8ce6fed79320 [project @ 1997-11-14 09:49:28 by jwe]
jwe
parents: 3095
diff changeset
4627 octave_value_list
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
4628 eval_string (const std::string& s, bool silent, int& parse_status, int nargout)
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4629 {
3877
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3844
diff changeset
4630 octave_value_list retval;
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3844
diff changeset
4631
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4632 unwind_protect frame;
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4633
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4634 frame.protect_var (input_line_number);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4635 frame.protect_var (current_input_column);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4636 frame.protect_var (get_input_from_eval_string);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4637 frame.protect_var (input_from_eval_string_pending);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4638 frame.protect_var (parser_end_of_input);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4639 frame.protect_var (line_editing);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4640 frame.protect_var (current_eval_string);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4641 frame.protect_var (current_function_depth);
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
4642 frame.protect_var (function_scopes);
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4643 frame.protect_var (max_function_depth);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4644 frame.protect_var (parsing_subfunctions);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4645 frame.protect_var (endfunction_found);
10130
0c3609dd34cf oct-parse.yy (eval_string): save and set reading_{script,fcn,classdef}_file vars
John W. Eaton <jwe@octave.org>
parents: 10067
diff changeset
4646 frame.protect_var (reading_fcn_file);
0c3609dd34cf oct-parse.yy (eval_string): save and set reading_{script,fcn,classdef}_file vars
John W. Eaton <jwe@octave.org>
parents: 10067
diff changeset
4647 frame.protect_var (reading_script_file);
0c3609dd34cf oct-parse.yy (eval_string): save and set reading_{script,fcn,classdef}_file vars
John W. Eaton <jwe@octave.org>
parents: 10067
diff changeset
4648 frame.protect_var (reading_classdef_file);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4649
8447
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
4650 input_line_number = 1;
adab48231a03 make input_line_number work again
John W. Eaton <jwe@octave.org>
parents: 8311
diff changeset
4651 current_input_column = 1;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4652 get_input_from_eval_string = true;
3877
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3844
diff changeset
4653 input_from_eval_string_pending = true;
3883
69b6bd271277 [project @ 2002-04-02 21:05:10 by jwe]
jwe
parents: 3881
diff changeset
4654 parser_end_of_input = false;
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5180
diff changeset
4655 line_editing = false;
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
4656 current_function_depth = 0;
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents: 14533
diff changeset
4657 function_scopes.clear ();
9474
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
4658 max_function_depth = 0;
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
4659 parsing_subfunctions = false;
25ed2d6aacf6 Parse nested functions more accurately.
David Grundberg <individ@acc.umu.se>
parents: 9471
diff changeset
4660 endfunction_found = false;
10130
0c3609dd34cf oct-parse.yy (eval_string): save and set reading_{script,fcn,classdef}_file vars
John W. Eaton <jwe@octave.org>
parents: 10067
diff changeset
4661 reading_fcn_file = false;
0c3609dd34cf oct-parse.yy (eval_string): save and set reading_{script,fcn,classdef}_file vars
John W. Eaton <jwe@octave.org>
parents: 10067
diff changeset
4662 reading_script_file = false;
0c3609dd34cf oct-parse.yy (eval_string): save and set reading_{script,fcn,classdef}_file vars
John W. Eaton <jwe@octave.org>
parents: 10067
diff changeset
4663 reading_classdef_file = false;
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5180
diff changeset
4664
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4665 current_eval_string = s;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4666
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4667 YY_BUFFER_STATE old_buf = current_buffer ();
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4668 YY_BUFFER_STATE new_buf = create_buffer (0);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4669
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4670 frame.add_fcn (switch_to_buffer, old_buf);
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4671 frame.add_fcn (delete_buffer, new_buf);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4672
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4673 switch_to_buffer (new_buf);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4674
3877
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3844
diff changeset
4675 do
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3844
diff changeset
4676 {
4318
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4297
diff changeset
4677 reset_parser ();
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4297
diff changeset
4678
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4679 frame.protect_var (global_command);
7903
8018e10d2b87 save and restore global_command as needed
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
4680
11258
795c97ace02c eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents: 11225
diff changeset
4681 global_command = 0;
795c97ace02c eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents: 11225
diff changeset
4682
9260
9c2349a51218 properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents: 9144
diff changeset
4683 // Do this with an unwind-protect cleanup function so that the
9c2349a51218 properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents: 9144
diff changeset
4684 // forced variables will be unmarked in the event of an
9c2349a51218 properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents: 9144
diff changeset
4685 // interrupt.
9c2349a51218 properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents: 9144
diff changeset
4686 symbol_table::scope_id scope = symbol_table::top_scope ();
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4687 frame.add_fcn (symbol_table::unmark_forced_variables, scope);
9260
9c2349a51218 properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents: 9144
diff changeset
4688
3877
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3844
diff changeset
4689 parse_status = yyparse ();
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3844
diff changeset
4690
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8471
diff changeset
4691 tree_statement_list *command_list = global_command;
3877
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3844
diff changeset
4692
9260
9c2349a51218 properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents: 9144
diff changeset
4693 // Unmark forced variables.
7903
8018e10d2b87 save and restore global_command as needed
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
4694 // Restore previous value of global_command.
15469
72868cae7624 eliminate some deprecated function warnings
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
4695 frame.run (2);
7903
8018e10d2b87 save and restore global_command as needed
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
4696
3883
69b6bd271277 [project @ 2002-04-02 21:05:10 by jwe]
jwe
parents: 3881
diff changeset
4697 if (parse_status == 0)
3877
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3844
diff changeset
4698 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4699 if (command_list)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4700 {
13970
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4701 unwind_protect inner_frame;
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4702
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4703 // Use an unwind-protect cleanup function so that the
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4704 // global_command list will be deleted in the event of an
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4705 // interrupt.
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4706
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4707 inner_frame.add_fcn (cleanup_statement_list, &command_list);
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4708
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4709 tree_statement *stmt = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4710
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4711 if (command_list->length () == 1
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4712 && (stmt = command_list->front ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4713 && stmt->is_expression ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4714 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4715 tree_expression *expr = stmt->expression ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4716
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4717 if (silent)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4718 expr->set_print_flag (false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4719
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4720 bool do_bind_ans = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4721
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4722 if (expr->is_identifier ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4723 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4724 tree_identifier *id
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4725 = dynamic_cast<tree_identifier *> (expr);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4726
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4727 do_bind_ans = (! id->is_variable ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4728 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4729 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4730 do_bind_ans = (! expr->is_assignment_expression ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4731
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4732 retval = expr->rvalue (nargout);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4733
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4734 if (do_bind_ans && ! (error_state || retval.empty ()))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4735 bind_ans (retval(0), expr->print_result ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4736
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4737 if (nargout == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4738 retval = octave_value_list ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4739 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4740 else if (nargout == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4741 command_list->accept (*current_evaluator);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4742 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4743 error ("eval: invalid use of statement list");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4744
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4745 if (error_state
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4746 || tree_return_command::returning
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4747 || tree_break_command::breaking
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4748 || tree_continue_command::continuing)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4749 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4750 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4751 else if (parser_end_of_input)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4752 break;
3883
69b6bd271277 [project @ 2002-04-02 21:05:10 by jwe]
jwe
parents: 3881
diff changeset
4753 }
3877
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3844
diff changeset
4754 }
55648fc616c8 [project @ 2002-03-07 23:00:09 by jwe]
jwe
parents: 3844
diff changeset
4755 while (parse_status == 0);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4756
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4757 return retval;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4758 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4759
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4760 octave_value
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
4761 eval_string (const std::string& s, bool silent, int& parse_status)
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4762 {
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4763 octave_value retval;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4764
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4765 octave_value_list tmp = eval_string (s, silent, parse_status, 1);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4766
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4767 if (! tmp.empty ())
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4768 retval = tmp(0);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4769
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4770 return retval;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4771 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4772
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4773 static octave_value_list
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4774 eval_string (const octave_value& arg, bool silent, int& parse_status,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4775 int nargout)
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4776 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
4777 std::string s = arg.string_value ();
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4778
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4779 if (error_state)
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4780 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
4781 error ("eval: expecting std::string argument");
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 4219
diff changeset
4782 return octave_value (-1);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4783 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4784
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4785 return eval_string (s, silent, parse_status, nargout);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4786 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4787
13970
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4788 void
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4789 cleanup_statement_list (tree_statement_list **lst)
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4790 {
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4791 if (*lst)
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4792 {
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4793 delete *lst;
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4794 *lst = 0;
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4795 }
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4796 }
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 13844
diff changeset
4797
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4798 DEFUN (eval, args, nargout,
3371
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4799 "-*- texinfo -*-\n\
14172
cba1c681f1b7 doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents: 14153
diff changeset
4800 @deftypefn {Built-in Function} {} eval (@var{try})\n\
cba1c681f1b7 doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents: 14153
diff changeset
4801 @deftypefnx {Built-in Function} {} eval (@var{try}, @var{catch})\n\
3371
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4802 Parse the string @var{try} and evaluate it as if it were an Octave\n\
6643
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4803 program. If that fails, evaluate the optional string @var{catch}.\n\
4463
322453495d75 [project @ 2003-07-12 05:03:33 by jwe]
jwe
parents: 4452
diff changeset
4804 The string @var{try} is evaluated in the current context,\n\
322453495d75 [project @ 2003-07-12 05:03:33 by jwe]
jwe
parents: 4452
diff changeset
4805 so any results remain available after @code{eval} returns.\n\
6643
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4806 \n\
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4807 The following example makes the variable @var{a} with the approximate\n\
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4808 value 3.1416 available.\n\
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4809 \n\
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4810 @example\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14329
diff changeset
4811 eval (\"a = acos(-1);\");\n\
6643
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4812 @end example\n\
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4813 \n\
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4814 If an error occurs during the evaluation of @var{try} the @var{catch}\n\
8828
8463d1a2e544 Doc fixes.
Brian Gough <bjg@network-theory.co.uk>
parents: 8819
diff changeset
4815 string is evaluated, as the following example shows:\n\
6643
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4816 \n\
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4817 @example\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
4818 @group\n\
6643
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4819 eval ('error (\"This is a bad example\");',\n\
8015
30629059b72d Update the manual to reflect the changes in error output
sh@sh-laptop
parents: 8007
diff changeset
4820 'printf (\"This error occurred:\\n%s\\n\", lasterr ());');\n\
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6926
diff changeset
4821 @print{} This error occurred:\n\
8015
30629059b72d Update the manual to reflect the changes in error output
sh@sh-laptop
parents: 8007
diff changeset
4822 This is a bad example\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
4823 @end group\n\
6643
6a7fc4105bcc [project @ 2007-05-21 20:37:43 by jwe]
jwe
parents: 6637
diff changeset
4824 @end example\n\
14172
cba1c681f1b7 doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents: 14153
diff changeset
4825 \n\
cba1c681f1b7 doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents: 14153
diff changeset
4826 Consider using try/catch blocks instead if you are only using @code{eval}\n\
cba1c681f1b7 doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents: 14153
diff changeset
4827 as an error-capturing mechanism rather than for the execution of arbitrary\n\
cba1c681f1b7 doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents: 14153
diff changeset
4828 code strings.\n\
cba1c681f1b7 doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents: 14153
diff changeset
4829 @seealso{evalin}\n\
3371
86873384cd10 [project @ 1999-11-21 17:31:07 by jwe]
jwe
parents: 3366
diff changeset
4830 @end deftypefn")
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4831 {
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4832 octave_value_list retval;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4833
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4834 int nargin = args.length ();
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4835
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4836 if (nargin > 0)
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4837 {
10067
6f79338c269b omission from last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9794
diff changeset
4838 unwind_protect frame;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4839
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4840 if (nargin > 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4841 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4842 frame.protect_var (buffer_error_messages);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4843 buffer_error_messages++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4844 }
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4845
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4846 int parse_status = 0;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4847
4463
322453495d75 [project @ 2003-07-12 05:03:33 by jwe]
jwe
parents: 4452
diff changeset
4848 octave_value_list tmp = eval_string (args(0), nargout > 0,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4849 parse_status, nargout);
4463
322453495d75 [project @ 2003-07-12 05:03:33 by jwe]
jwe
parents: 4452
diff changeset
4850
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4851 if (nargin > 1 && (parse_status != 0 || error_state))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4852 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4853 error_state = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4854
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4855 // Set up for letting the user print any messages from
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4856 // errors that occurred in the first part of this eval().
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4857
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4858 buffer_error_messages--;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4859
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4860 tmp = eval_string (args(1), nargout > 0, parse_status, nargout);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4861
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4862 if (nargout > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4863 retval = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4864 }
8033
2ad5ba320b93 parse.y (Feval): Return value produced by evaluating CATCH string
John W. Eaton <jwe@octave.org>
parents: 8021
diff changeset
4865 else if (nargout > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4866 retval = tmp;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4867 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4868 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
4869 print_usage ();
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4870
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4871 return retval;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4872 }
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 3016
diff changeset
4873
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7351
diff changeset
4874 /*
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7351
diff changeset
4875
14084
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4876 %!shared x
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7351
diff changeset
4877 %! x = 1;
14084
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4878
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4879 %!assert (eval ("x"), 1)
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4880 %!assert (eval ("x;"))
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4881 %!assert (eval ("x;"), 1);
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4882
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7351
diff changeset
4883 %!test
14084
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4884 %! y = eval ("x");
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4885 %! assert (y, 1);
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4886
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4887 %!test
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4888 %! y = eval ("x;");
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4889 %! assert (y, 1);
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4890
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4891 %!test
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4892 %! eval ("x = 1;")
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4893 %! assert (x,1);
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4894
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7351
diff changeset
4895 %!test
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7351
diff changeset
4896 %! eval ("flipud = 2;");
14084
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4897 %! assert (flipud, 2);
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4898
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4899 %!function y = __f ()
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7351
diff changeset
4900 %! eval ("flipud = 2;");
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7351
diff changeset
4901 %! y = flipud;
14084
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4902 %!endfunction
5aba9fa234cf Modernize %!tests for eval()
Rik <octave@nomad.inbox5.com>
parents: 13970
diff changeset
4903 %!assert (__f(), 2)
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7351
diff changeset
4904
14533
e6aa044253eb Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents: 14512
diff changeset
4905 % bug #35645
e6aa044253eb Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents: 14512
diff changeset
4906 %!test
e6aa044253eb Allow comma at the end of an assignment list (bug #35645)
Max Brister <max@2bass.com>
parents: 14512
diff changeset
4907 %! [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
4908 %! [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
4909
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7351
diff changeset
4910 */
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7351
diff changeset
4911
4661
12b6fbd57436 [project @ 2003-11-25 05:41:35 by jwe]
jwe
parents: 4615
diff changeset
4912 DEFUN (assignin, args, ,
4297
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4913 "-*- texinfo -*-\n\
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4914 @deftypefn {Built-in Function} {} assignin (@var{context}, @var{varname}, @var{value})\n\
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4915 Assign @var{value} to @var{varname} in context @var{context}, which\n\
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4916 may be either @code{\"base\"} or @code{\"caller\"}.\n\
14172
cba1c681f1b7 doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents: 14153
diff changeset
4917 @seealso{evalin}\n\
4297
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4918 @end deftypefn")
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4919 {
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4920 octave_value_list retval;
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4921
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4922 int nargin = args.length ();
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4923
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4924 if (nargin == 3)
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4925 {
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4926 std::string context = args(0).string_value ();
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4927
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4928 if (! error_state)
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4929 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4930 unwind_protect frame;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4931
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4932 if (context == "caller")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4933 octave_call_stack::goto_caller_frame ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4934 else if (context == "base")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4935 octave_call_stack::goto_base_frame ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4936 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12400
diff changeset
4937 error ("assignin: CONTEXT must be \"caller\" or \"base\"");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4938
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4939 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4940 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4941 frame.add_fcn (octave_call_stack::pop);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4942
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4943 std::string nm = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4944
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4945 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4946 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4947 if (valid_identifier (nm))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4948 symbol_table::varref (nm) = args(2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4949 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12400
diff changeset
4950 error ("assignin: invalid variable name in argument VARNAME");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4951 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4952 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12400
diff changeset
4953 error ("assignin: VARNAME must be a string");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4954 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4955 }
4297
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4956 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12400
diff changeset
4957 error ("assignin: CONTEXT must be a string");
4297
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4958 }
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4959 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
4960 print_usage ();
4297
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4961
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4962 return retval;
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4963 }
59a2ba0fb205 [project @ 2003-01-11 20:22:09 by jwe]
jwe
parents: 4246
diff changeset
4964
4245
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4965 DEFUN (evalin, args, nargout,
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4966 "-*- texinfo -*-\n\
14172
cba1c681f1b7 doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents: 14153
diff changeset
4967 @deftypefn {Built-in Function} {} evalin (@var{context}, @var{try})\n\
cba1c681f1b7 doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents: 14153
diff changeset
4968 @deftypefnx {Built-in Function} {} evalin (@var{context}, @var{try}, @var{catch})\n\
4245
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4969 Like @code{eval}, except that the expressions are evaluated in the\n\
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4970 context @var{context}, which may be either @code{\"caller\"} or\n\
4246
0253850a08d7 [project @ 2002-12-30 17:57:36 by jwe]
jwe
parents: 4245
diff changeset
4971 @code{\"base\"}.\n\
14172
cba1c681f1b7 doc: Update seealso references for eval family of functions.
Rik <octave@nomad.inbox5.com>
parents: 14153
diff changeset
4972 @seealso{eval, assignin}\n\
4245
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4973 @end deftypefn")
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4974 {
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4975 octave_value_list retval;
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4976
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4977 int nargin = args.length ();
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4978
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4979 if (nargin > 1)
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4980 {
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4981 std::string context = args(0).string_value ();
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4982
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4983 if (! error_state)
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
4984 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4985 unwind_protect frame;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4986
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4987 if (context == "caller")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4988 octave_call_stack::goto_caller_frame ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4989 else if (context == "base")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4990 octave_call_stack::goto_base_frame ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4991 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12400
diff changeset
4992 error ("evalin: CONTEXT must be \"caller\" or \"base\"");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4993
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4994 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4995 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4996 frame.add_fcn (octave_call_stack::pop);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4997
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4998 if (nargin > 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
4999 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5000 frame.protect_var (buffer_error_messages);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5001 buffer_error_messages++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5002 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5003
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5004 int parse_status = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5005
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5006 octave_value_list tmp = eval_string (args(1), nargout > 0,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5007 parse_status, nargout);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5008
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5009 if (nargout > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5010 retval = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5011
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5012 if (nargin > 2 && (parse_status != 0 || error_state))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5013 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5014 error_state = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5015
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5016 // Set up for letting the user print any messages from
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5017 // errors that occurred in the first part of this eval().
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5018
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5019 buffer_error_messages--;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5020
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5021 tmp = eval_string (args(2), nargout > 0,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5022 parse_status, nargout);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5023
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5024 retval = (nargout > 0) ? tmp : octave_value_list ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5025 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5026 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
5027 }
4245
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
5028 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12400
diff changeset
5029 error ("evalin: CONTEXT must be a string");
4245
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
5030 }
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
5031 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
5032 print_usage ();
4245
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
5033
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
5034 return retval;
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
5035 }
610671be8792 [project @ 2002-12-28 04:02:31 by jwe]
jwe
parents: 4244
diff changeset
5036
8311
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5037 DEFUN (__parser_debug_flag__, args, nargout,
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8746
diff changeset
5038 "-*- texinfo -*-\n\
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8746
diff changeset
5039 @deftypefn {Built-in Function} {@var{old_val} =} __parser_debug_flag__ (@var{new_val}))\n\
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8746
diff changeset
5040 Undocumented internal function.\n\
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8746
diff changeset
5041 @end deftypefn")
8311
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5042 {
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5043 octave_value retval;
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5044
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5045 bool debug_flag = octave_debug;
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5046
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5047 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
5048 "__parser_debug_flag__");
8311
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5049
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5050 octave_debug = debug_flag;
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5051
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5052 return retval;
7124bffc89c7 parse.y (F__parser_debug_flag__): New function.
John W. Eaton <jwe@octave.org>
parents: 8283
diff changeset
5053 }