annotate src/parse.h @ 7016:93c65f2a5668

[project @ 2007-10-12 06:40:56 by jwe]
author jwe
date Fri, 12 Oct 2007 06:41:26 +0000
parents c68896f193e3
children a1dbe9d80eee
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
2847
8b262e771614 [project @ 1997-03-27 16:18:26 by jwe]
jwe
parents: 2165
diff changeset
3 Copyright (C) 1996, 1997 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>
51a0dcde8778 [project @ 2003-06-13 19:16:37 by jwe]
jwe
parents: 4342
diff changeset
31
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
32 extern void reset_parser (void);
4753
9f0ce1536368 [project @ 2004-02-13 17:55:24 by jwe]
jwe
parents: 4486
diff changeset
33 extern int octave_lex (void);
9f0ce1536368 [project @ 2004-02-13 17:55:24 by jwe]
jwe
parents: 4486
diff changeset
34 extern int octave_parse (void);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
35
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
36 class tree;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
37 class tree_matrix;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
38 class tree_identifier;
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
39 class octaev_function;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
40 class symbol_record;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
41 class symbol_table;
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
42
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
43 #include "oct-obj.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
44
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
45 // Temporary symbol table pointer used to cope with bogus function syntax.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
46 extern symbol_table *tmp_local_sym_tab;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
47
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
48 // Nonzero means print parser debugging info (-d).
4753
9f0ce1536368 [project @ 2004-02-13 17:55:24 by jwe]
jwe
parents: 4486
diff changeset
49 extern int octave_debug;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
50
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
51 // The current input line number.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
52 extern int input_line_number;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
53
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
54 // The column of the current token.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
55 extern int current_input_column;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
56
338
82d30a23c979 [project @ 1994-02-07 07:09:33 by jwe]
jwe
parents: 195
diff changeset
57 // Buffer for help text snagged from function files.
4426
51a0dcde8778 [project @ 2003-06-13 19:16:37 by jwe]
jwe
parents: 4342
diff changeset
58 extern std::stack<std::string> help_buf;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
59
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
60 // TRUE means we are using readline.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
61 extern bool line_editing;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
62
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
63 // TRUE means we printed messages about reading startup files.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
64 extern bool reading_startup_message_printed;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
65
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
66 // TRUE means input is coming from startup file.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
67 extern bool input_from_startup_file;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
68
3489
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3162
diff changeset
69 // TRUE means that we are in the process of evaluating a function
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3162
diff changeset
70 // body. The parser might be called in that case if we are looking at
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3162
diff changeset
71 // an eval() statement.
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3162
diff changeset
72 extern bool evaluating_function_body;
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3162
diff changeset
73
4186
bf9c5ca4c3f3 [project @ 2002-11-19 00:33:40 by jwe]
jwe
parents: 3772
diff changeset
74 // Keep track of symbol table information when parsing functions.
4238
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
75 extern std::stack<symbol_table*> symtab_context;
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
76
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
77 // Name of parent function when parsing function files that might
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
78 // contain nested functions.
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
79 extern std::string parent_function_name;
4186
bf9c5ca4c3f3 [project @ 2002-11-19 00:33:40 by jwe]
jwe
parents: 3772
diff changeset
80
4238
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
81 // Keep a count of how many END tokens we expect.
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
82 extern int end_tokens_expected;
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
83
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
84 extern OCTINTERP_API void
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
85 parse_and_execute (FILE *f);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
86
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
87 extern OCTINTERP_API void
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
88 parse_and_execute (const std::string& s, bool verbose = false,
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
89 const char *warn_for = 0);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
90
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
91 extern OCTINTERP_API std::string
5484
2ff5363a16bd [project @ 2005-10-06 17:12:12 by jwe]
jwe
parents: 5312
diff changeset
92 get_help_from_file (const std::string& nm, bool& symbol_found,
5931
25da9a7d5f6d [project @ 2006-08-16 06:52:19 by jwe]
jwe
parents: 5781
diff changeset
93 std::string& file);
25da9a7d5f6d [project @ 2006-08-16 06:52:19 by jwe]
jwe
parents: 5781
diff changeset
94
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
95 extern OCTINTERP_API std::string
5931
25da9a7d5f6d [project @ 2006-08-16 06:52:19 by jwe]
jwe
parents: 5781
diff changeset
96 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
97
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
98 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
99
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
100 extern OCTINTERP_API string_vector autoloaded_functions (void);
5592
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5484
diff changeset
101
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
102 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
103
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
104 extern OCTINTERP_API bool
5312
80c1aa832cb2 [project @ 2005-04-28 01:54:46 by jwe]
jwe
parents: 5307
diff changeset
105 load_fcn_from_file (const std::string& nm, bool exec_script);
80c1aa832cb2 [project @ 2005-04-28 01:54:46 by jwe]
jwe
parents: 5307
diff changeset
106
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
107 extern OCTINTERP_API bool
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
108 load_fcn_from_file (symbol_record *sym_rec, bool exec_script);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
109
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
110 extern OCTINTERP_API void
5975
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5931
diff changeset
111 source_file (const std::string& file_name,
e64059303a6f [project @ 2006-08-29 16:37:39 by jwe]
jwe
parents: 5931
diff changeset
112 const std::string& context = std::string ());
4486
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4426
diff changeset
113
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
114 extern OCTINTERP_API octave_value_list
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
115 feval (const std::string& name,
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
116 const octave_value_list& args = octave_value_list (),
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
117 int nargout = 0);
3156
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3100
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_list
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
120 feval (octave_function *fcn,
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
121 const octave_value_list& args = octave_value_list (),
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
122 int nargout = 0);
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
123
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
124 extern OCTINTERP_API octave_value_list
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
125 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
126
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
127 extern OCTINTERP_API octave_value_list
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
128 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
129
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 5975
diff changeset
130 extern OCTINTERP_API octave_value
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
131 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
132
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
133 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
134
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
135 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
136 ;;; Local Variables: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
137 ;;; mode: C++ ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
138 ;;; End: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
139 */