annotate libinterp/parse-tree/parse.h @ 16237:70f465930546

rearrange class heirarchy for tree_cell and tree_matrix * pt-array-list.h, pt-array-list.cc: New files. (tree_array_list): New class. * pt-cell.h, pt-cell.cc (tree_cell): Derive from tree_array_list. * pt-mat.h, pt-mat.cc (tree_matrix): Derive from tree_array_list. * oct-parse.in.yy (octave_parser::finish_array_list): New function adapted from octave_parser::finish_matrix. (octave_parser::finish_matrix, octave_parser::finish_cell): Call finish_array_list to do the work. * pt-arg-list.h: Include symtab.h. * base-list.h: Include cstdlib.
author John W. Eaton <jwe@octave.org>
date Sat, 09 Mar 2013 18:04:51 -0500
parents 78365c56a762
children 90dfd98a915a c5e5f6ccac5d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
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: 13970
diff changeset
3 Copyright (C) 1993-2012 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
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 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
8 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: 6109
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6109
diff changeset
10 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 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
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 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
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 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: 6109
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6109
diff changeset
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22
383
0b52c68ec81f [project @ 1994-03-09 21:19:44 by jwe]
jwe
parents: 338
diff changeset
23 #if !defined (octave_parse_h)
0b52c68ec81f [project @ 1994-03-09 21:19:44 by jwe]
jwe
parents: 338
diff changeset
24 #define octave_parse_h 1
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
26 #include <cstdio>
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
27
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1315
diff changeset
28 #include <string>
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1315
diff changeset
29
4426
51a0dcde8778 [project @ 2003-06-13 19:16:37 by jwe]
jwe
parents: 4342
diff changeset
30 #include <stack>
16153
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
31 #include <vector>
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
32 #include <map>
4426
51a0dcde8778 [project @ 2003-06-13 19:16:37 by jwe]
jwe
parents: 4342
diff changeset
33
16139
2fd39ab12209 move a function and data member from lexical_feedback to octave_parser
John W. Eaton <jwe@octave.org>
parents: 16138
diff changeset
34 #include "lex.h"
16153
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
35 #include "symtab.h"
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
36 #include "token.h"
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
37
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
38 class octave_comment_list;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
39 class octave_function;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
40 class octave_user_function;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
41 class tree;
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
42 class tree_anon_fcn_handle;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
43 class tree_argument_list;
16237
70f465930546 rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents: 16210
diff changeset
44 class tree_array_list;
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
45 class tree_cell;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
46 class tree_colon_expression;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
47 class tree_command;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
48 class tree_constant;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
49 class tree_decl_command;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
50 class tree_decl_init_list;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
51 class tree_expression;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
52 class tree_fcn_handle;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
53 class tree_function_def;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
54 class tree_identifier;
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
55 class tree_if_clause;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
56 class tree_if_command;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
57 class tree_if_command_list;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
58 class tree_index_expression;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
59 class tree_matrix;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
60 class tree_matrix;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
61 class tree_parameter_list;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
62 class tree_statement;
13970
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
63 class tree_statement_list;
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
64 class tree_statement_listtree_statement;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
65 class tree_switch_case;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
66 class tree_switch_case_list;
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
67 class tree_switch_command;
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
68
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
69 #include "oct-obj.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
70
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
71 // Nonzero means print parser debugging info (-d).
4753
9f0ce1536368 [project @ 2004-02-13 17:55:24 by jwe]
jwe
parents: 4486
diff changeset
72 extern int octave_debug;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
73
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
74 // TRUE means we printed messages about reading startup files.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
75 extern bool reading_startup_message_printed;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
76
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
77 extern OCTINTERP_API std::string
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5312
diff changeset
78 get_help_from_file (const std::string& nm, bool& symbol_found,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
79 std::string& file);
5931
25da9a7d5f6d [project @ 2006-08-16 06:52:19 by jwe]
jwe
parents: 5781
diff changeset
80
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
81 extern OCTINTERP_API std::string
5931
25da9a7d5f6d [project @ 2006-08-16 06:52:19 by jwe]
jwe
parents: 5781
diff changeset
82 get_help_from_file (const std::string& nm, bool& symbol_found);
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5312
diff changeset
83
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
84 extern OCTINTERP_API std::string lookup_autoload (const std::string& nm);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
85
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
86 extern OCTINTERP_API string_vector autoloaded_functions (void);
5592
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
87
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
88 extern OCTINTERP_API string_vector reverse_lookup_autoload (const std::string& nm);
5592
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
89
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7102
diff changeset
90 extern OCTINTERP_API octave_function *
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7102
diff changeset
91 load_fcn_from_file (const std::string& file_name,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
92 const std::string& dir_name = std::string (),
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
93 const std::string& dispatch_type = std::string (),
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
94 const std::string& fcn_name = std::string (),
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
95 bool autoload = false);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
96
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
97 extern OCTINTERP_API void
5975
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5931
diff changeset
98 source_file (const std::string& file_name,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
99 const std::string& context = std::string (),
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
100 bool verbose = false, bool require_file = true,
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
101 const std::string& warn_for = std::string ());
4486
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4426
diff changeset
102
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
103 extern OCTINTERP_API octave_value_list
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
104 feval (const std::string& name,
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
105 const octave_value_list& args = octave_value_list (),
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
106 int nargout = 0);
3156
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3100
diff changeset
107
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
108 extern OCTINTERP_API octave_value_list
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
109 feval (octave_function *fcn,
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
110 const octave_value_list& args = octave_value_list (),
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
111 int nargout = 0);
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
112
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
113 extern OCTINTERP_API octave_value_list
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
114 feval (const octave_value_list& args, int nargout = 0);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
115
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
116 extern OCTINTERP_API octave_value_list
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
117 eval_string (const std::string&, bool silent, int& parse_status, int hargout);
3099
8ce6fed79320 [project @ 1997-11-14 09:49:28 by jwe]
jwe
parents: 3021
diff changeset
118
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
119 extern OCTINTERP_API octave_value
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
120 eval_string (const std::string&, bool silent, int& parse_status);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
121
13970
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
122 extern OCTINTERP_API void cleanup_statement_list (tree_statement_list **lst);
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
123
16149
49dfba4fd3c5 use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents: 16142
diff changeset
124 // Global access to currently active lexer.
49dfba4fd3c5 use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents: 16142
diff changeset
125 // FIXME -- to be removed after more parser+lexer refactoring.
16158
7eb614760ddb rename lexical_feedback to octave_lexer
John W. Eaton <jwe@octave.org>
parents: 16157
diff changeset
126 extern octave_lexer *CURR_LEXER;
16149
49dfba4fd3c5 use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents: 16142
diff changeset
127
16133
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
128 class
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
129 octave_parser
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
130 {
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
131 public:
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
132
16149
49dfba4fd3c5 use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents: 16142
diff changeset
133 octave_parser (void)
16164
c5bfdc4c0963 move end_of_input flag from octve_parser class to octave_lexer class
John W. Eaton <jwe@octave.org>
parents: 16158
diff changeset
134 : endfunction_found (false),
16153
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
135 autoloading (false), fcn_file_from_relative_lookup (false),
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
136 parsing_subfunctions (false), max_fcn_depth (0),
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
137 curr_fcn_depth (0), primary_fcn_scope (-1),
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
138 curr_class_name (), function_scopes (), primary_fcn_ptr (0),
16177
a7669b4d27f6 eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents: 16164
diff changeset
139 stmt_list (0),
16158
7eb614760ddb rename lexical_feedback to octave_lexer
John W. Eaton <jwe@octave.org>
parents: 16157
diff changeset
140 curr_lexer (new octave_lexer ()), parser_state (0)
16149
49dfba4fd3c5 use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents: 16142
diff changeset
141 {
16157
335041cc657a optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents: 16153
diff changeset
142 init ();
16149
49dfba4fd3c5 use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents: 16142
diff changeset
143 }
16133
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
144
16195
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
145 octave_parser (FILE *file)
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
146 : endfunction_found (false),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
147 autoloading (false), fcn_file_from_relative_lookup (false),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
148 parsing_subfunctions (false), max_fcn_depth (0),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
149 curr_fcn_depth (0), primary_fcn_scope (-1),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
150 curr_class_name (), function_scopes (), primary_fcn_ptr (0),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
151 stmt_list (0),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
152 curr_lexer (new octave_lexer (file)), parser_state (0)
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
153 {
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
154 init ();
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
155 }
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
156
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
157 octave_parser (const std::string& eval_string)
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
158 : endfunction_found (false),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
159 autoloading (false), fcn_file_from_relative_lookup (false),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
160 parsing_subfunctions (false), max_fcn_depth (0),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
161 curr_fcn_depth (0), primary_fcn_scope (-1),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
162 curr_class_name (), function_scopes (), primary_fcn_ptr (0),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
163 stmt_list (0),
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
164 curr_lexer (new octave_lexer (eval_string)), parser_state (0)
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
165 {
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
166 init ();
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
167 }
b52d2f9294b6 use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
168
16157
335041cc657a optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents: 16153
diff changeset
169 ~octave_parser (void);
335041cc657a optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents: 16153
diff changeset
170
335041cc657a optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents: 16153
diff changeset
171 void init (void);
16133
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
172
16177
a7669b4d27f6 eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents: 16164
diff changeset
173 void reset (void);
16139
2fd39ab12209 move a function and data member from lexical_feedback to octave_parser
John W. Eaton <jwe@octave.org>
parents: 16138
diff changeset
174
16138
284e2ca86ef7 execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16136
diff changeset
175 int run (void);
284e2ca86ef7 execute parser using member function of octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16136
diff changeset
176
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
177 // Error mesages for mismatched end tokens.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
178 void end_error (const char *type, token::end_tok_type ettype, int l, int c);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
179
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
180 // Check to see that end tokens are properly matched.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
181 bool end_token_ok (token *tok, token::end_tok_type expected);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
182
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
183 // Maybe print a warning if an assignment expression is used as the
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
184 // test in a logical expression.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
185 void maybe_warn_assign_as_truth_value (tree_expression *expr);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
186
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
187 // Maybe print a warning about switch labels that aren't constants.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
188 void maybe_warn_variable_switch_label (tree_expression *expr);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
189
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
190 // Finish building a range.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
191 tree_expression *finish_colon_expression (tree_colon_expression *e);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
192
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
193 // Build a constant.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
194 tree_constant *make_constant (int op, token *tok_val);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
195
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
196 // Build a function handle.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
197 tree_fcn_handle *make_fcn_handle (token *tok_val);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
198
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
199 // Build an anonymous function handle.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
200 tree_anon_fcn_handle *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
201 make_anon_fcn_handle (tree_parameter_list *param_list, tree_statement *stmt);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
202
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
203 // Build a binary expression.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
204 tree_expression *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
205 make_binary_op (int op, tree_expression *op1, token *tok_val,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
206 tree_expression *op2);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
207
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
208 // Build a boolean expression.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
209 tree_expression *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
210 make_boolean_op (int op, tree_expression *op1, token *tok_val,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
211 tree_expression *op2);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
212
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
213 // Build a prefix expression.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
214 tree_expression *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
215 make_prefix_op (int op, tree_expression *op1, token *tok_val);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
216
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
217 // Build a postfix expression.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
218 tree_expression *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
219 make_postfix_op (int op, tree_expression *op1, token *tok_val);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
220
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
221 // Build an unwind-protect command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
222 tree_command *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
223 make_unwind_command (token *unwind_tok, tree_statement_list *body,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
224 tree_statement_list *cleanup, token *end_tok,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
225 octave_comment_list *lc, octave_comment_list *mc);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
226
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
227 // Build a try-catch command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
228 tree_command *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
229 make_try_command (token *try_tok, tree_statement_list *body,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
230 tree_statement_list *cleanup, token *end_tok,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
231 octave_comment_list *lc, octave_comment_list *mc);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
232
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
233 // Build a while command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
234 tree_command *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
235 make_while_command (token *while_tok, tree_expression *expr,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
236 tree_statement_list *body, token *end_tok,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
237 octave_comment_list *lc);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
238
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
239 // Build a do-until command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
240 tree_command *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
241 make_do_until_command (token *until_tok, tree_statement_list *body,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
242 tree_expression *expr, octave_comment_list *lc);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
243
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
244 // Build a for command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
245 tree_command *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
246 make_for_command (int tok_id, token *for_tok, tree_argument_list *lhs,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
247 tree_expression *expr, tree_expression *maxproc,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
248 tree_statement_list *body, token *end_tok,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
249 octave_comment_list *lc);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
250
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
251 // Build a break command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
252 tree_command *make_break_command (token *break_tok);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
253
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
254 // Build a continue command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
255 tree_command *make_continue_command (token *continue_tok);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
256
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
257 // Build a return command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
258 tree_command *make_return_command (token *return_tok);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
259
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
260 // Start an if command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
261 tree_if_command_list *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
262 start_if_command (tree_expression *expr, tree_statement_list *list);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
263
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
264 // Finish an if command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
265 tree_if_command *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
266 finish_if_command (token *if_tok, tree_if_command_list *list,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
267 token *end_tok, octave_comment_list *lc);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
268
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
269 // Build an elseif clause.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
270 tree_if_clause *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
271 make_elseif_clause (token *elseif_tok, tree_expression *expr,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
272 tree_statement_list *list, octave_comment_list *lc);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
273
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
274 // Finish a switch command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
275 tree_switch_command *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
276 finish_switch_command (token *switch_tok, tree_expression *expr,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
277 tree_switch_case_list *list, token *end_tok,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
278 octave_comment_list *lc);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
279
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
280 // Build a switch case.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
281 tree_switch_case *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
282 make_switch_case (token *case_tok, tree_expression *expr,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
283 tree_statement_list *list, octave_comment_list *lc);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
284
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
285 // Build an assignment to a variable.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
286 tree_expression *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
287 make_assign_op (int op, tree_argument_list *lhs, token *eq_tok,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
288 tree_expression *rhs);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
289
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
290 // Define a script.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
291 void make_script (tree_statement_list *cmds, tree_statement *end_script);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
292
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
293 // Begin defining a function.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
294 octave_user_function *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
295 start_function (tree_parameter_list *param_list, tree_statement_list *body,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
296 tree_statement *end_function);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
297
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
298 // Create a no-op statement for end_function.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
299 tree_statement *make_end (const std::string& type, int l, int c);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
300
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
301 // Do most of the work for defining a function.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
302 octave_user_function *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
303 frob_function (const std::string& fname, octave_user_function *fcn);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
304
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
305 // Finish defining a function.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
306 tree_function_def *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
307 finish_function (tree_parameter_list *ret_list,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
308 octave_user_function *fcn, octave_comment_list *lc);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
309
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
310 // Reset state after parsing function.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
311 void
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
312 recover_from_parsing_function (void);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
313
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
314 // Make an index expression.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
315 tree_index_expression *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
316 make_index_expression (tree_expression *expr,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
317 tree_argument_list *args, char type);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
318
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
319 // Make an indirect reference expression.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
320 tree_index_expression *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
321 make_indirect_ref (tree_expression *expr, const std::string&);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
322
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
323 // Make an indirect reference expression with dynamic field name.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
324 tree_index_expression *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
325 make_indirect_ref (tree_expression *expr, tree_expression *field);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
326
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
327 // Make a declaration command.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
328 tree_decl_command *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
329 make_decl_command (int tok, token *tok_val, tree_decl_init_list *lst);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
330
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
331 // Validate argument list forming a matrix or cell row.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
332 tree_argument_list *validate_matrix_row (tree_argument_list *row);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
333
16237
70f465930546 rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents: 16210
diff changeset
334 // Finish building an array_list (common action for finish_matrix
70f465930546 rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents: 16210
diff changeset
335 // and finish_cell).
70f465930546 rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents: 16210
diff changeset
336 tree_expression *finish_array_list (tree_array_list *a);
70f465930546 rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents: 16210
diff changeset
337
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
338 // Finish building a matrix list.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
339 tree_expression *finish_matrix (tree_matrix *m);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
340
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
341 // Finish building a cell list.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
342 tree_expression *finish_cell (tree_cell *c);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
343
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
344 // Maybe print a warning. Duh.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
345 void maybe_warn_missing_semi (tree_statement_list *);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
346
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
347 // Set the print flag for a statement based on the separator type.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
348 tree_statement_list *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
349 set_stmt_print_flag (tree_statement_list *, char, bool);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
350
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
351 // Create a statement list.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
352 tree_statement_list *make_statement_list (tree_statement *stmt);
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
353
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
354 // Append a statement to an existing statement list.
16136
ed36d5543b27 don't declare octave_parser member functions static
John W. Eaton <jwe@octave.org>
parents: 16134
diff changeset
355 tree_statement_list *
16134
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
356 append_statement_list (tree_statement_list *list, char sep,
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
357 tree_statement *stmt, bool warn_missing_semi);
ec9c6222ef5a move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16133
diff changeset
358
16142
26d65d677557 rename yyerror to bison_error and make it a member of octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16139
diff changeset
359 // Generic error messages.
26d65d677557 rename yyerror to bison_error and make it a member of octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16139
diff changeset
360 void bison_error (const char *s);
26d65d677557 rename yyerror to bison_error and make it a member of octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16139
diff changeset
361
16153
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
362 // Have we found an explicit end to a function?
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
363 bool endfunction_found;
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
364
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
365 // TRUE means we are in the process of autoloading a function.
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
366 bool autoloading;
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
367
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
368 // TRUE means the current function file was found in a relative path
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
369 // element.
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
370 bool fcn_file_from_relative_lookup;
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
371
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
372 // FALSE if we are still at the primary function. Subfunctions can
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
373 // only be declared inside function files.
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
374 bool parsing_subfunctions;
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
375
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
376 // Maximum function depth detected. Used to determine whether
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
377 // we have nested functions or just implicitly ended subfunctions.
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
378 int max_fcn_depth;
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
379
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
380 // = 0 currently outside any function.
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
381 // = 1 inside the primary function or a subfunction.
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
382 // > 1 means we are looking at a function definition that seems to be
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
383 // inside a function. Note that the function still might not be a
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
384 // nested function.
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
385 int curr_fcn_depth;
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
386
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
387 // Scope where we install all subfunctions and nested functions. Only
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
388 // used while reading function files.
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
389 symbol_table::scope_id primary_fcn_scope;
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
390
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
391 // Name of the current class when we are parsing class methods or
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
392 // constructors.
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
393 std::string curr_class_name;
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
394
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
395 // A stack holding the nested function scopes being parsed.
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
396 // We don't use std::stack, because we want the clear method. Also, we
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
397 // must access one from the top
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
398 std::vector<symbol_table::scope_id> function_scopes;
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
399
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
400 // Pointer to the primary user function or user script function.
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
401 octave_function *primary_fcn_ptr;
a57c2c8c8163 move some variables into the octave_parser class
John W. Eaton <jwe@octave.org>
parents: 16149
diff changeset
402
16177
a7669b4d27f6 eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents: 16164
diff changeset
403 // Result of parsing input.
a7669b4d27f6 eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents: 16164
diff changeset
404 tree_statement_list *stmt_list;
a7669b4d27f6 eliminate global global_command variable
John W. Eaton <jwe@octave.org>
parents: 16164
diff changeset
405
16149
49dfba4fd3c5 use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents: 16142
diff changeset
406 // State of the lexer.
16158
7eb614760ddb rename lexical_feedback to octave_lexer
John W. Eaton <jwe@octave.org>
parents: 16157
diff changeset
407 octave_lexer *curr_lexer;
16149
49dfba4fd3c5 use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents: 16142
diff changeset
408
16157
335041cc657a optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents: 16153
diff changeset
409 // Internal state of the parser. Only used if USE_PUSH_PARSER is
335041cc657a optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents: 16153
diff changeset
410 // defined.
335041cc657a optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents: 16153
diff changeset
411 void *parser_state;
335041cc657a optionally use push parser interface
John W. Eaton <jwe@octave.org>
parents: 16153
diff changeset
412
16133
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
413 // For unwind protect.
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
414 static void cleanup (octave_parser *parser) { delete parser; }
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
415
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
416 private:
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
417
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
418 // No copying!
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
419
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
420 octave_parser (const octave_parser&);
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
421
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
422 octave_parser& operator = (const octave_parser&);
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
423 };
249d62b3fac8 new class for parser state
John W. Eaton <jwe@octave.org>
parents: 16122
diff changeset
424
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
425 #endif