annotate src/parse.h @ 4960:ce01dbd7e026 ss-2-1-58

[project @ 2004-09-02 03:47:49 by jwe]
author jwe
date Thu, 02 Sep 2004 03:47:49 +0000
parents 9f0ce1536368
children 85b315ad5f7d
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
10 later version.
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
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
1315
611d403c7f3d [project @ 1995-06-25 19:56:32 by jwe]
jwe
parents: 1009
diff changeset
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
69 // TRUE means that input is coming from a file that was named on
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
70 // the command line.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
71 extern bool input_from_command_line_file;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
72
3489
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3162
diff changeset
73 // 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
74 // 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
75 // an eval() statement.
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3162
diff changeset
76 extern bool evaluating_function_body;
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3162
diff changeset
77
4186
bf9c5ca4c3f3 [project @ 2002-11-19 00:33:40 by jwe]
jwe
parents: 3772
diff changeset
78 // 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
79 extern std::stack<symbol_table*> symtab_context;
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
80
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
81 // 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
82 // contain nested functions.
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
83 extern std::string parent_function_name;
4186
bf9c5ca4c3f3 [project @ 2002-11-19 00:33:40 by jwe]
jwe
parents: 3772
diff changeset
84
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3156
diff changeset
85 // TRUE means warn about function files that have time stamps in the future.
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3156
diff changeset
86 extern bool Vwarn_future_time_stamp;
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3156
diff changeset
87
4238
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
88 // 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
89 extern int end_tokens_expected;
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
90
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
91 extern void
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
92 parse_and_execute (FILE *f);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
93
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
94 extern void
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
95 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
96 const char *warn_for = 0);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
97
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
98 extern std::string get_help_from_file (const std::string& f);
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
99
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
100 extern bool
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
101 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
102
4486
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4426
diff changeset
103 extern void
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4426
diff changeset
104 source_file (const std::string file_name);
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4426
diff changeset
105
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
106 extern octave_value_list
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
107 feval (const std::string& name,
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
108 const octave_value_list& args = octave_value_list (),
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
109 int nargout = 0);
3156
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3100
diff changeset
110
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3100
diff changeset
111 extern octave_value_list
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
112 feval (octave_function *fcn,
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
113 const octave_value_list& args = octave_value_list (),
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
114 int nargout = 0);
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
115
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
116 extern octave_value_list
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
117 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
118
3100
bea2f5be3eab [project @ 1997-11-14 10:07:50 by jwe]
jwe
parents: 3099
diff changeset
119 extern octave_value_list
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, int hargout);
3099
8ce6fed79320 [project @ 1997-11-14 09:49:28 by jwe]
jwe
parents: 3021
diff changeset
121
8ce6fed79320 [project @ 1997-11-14 09:49:28 by jwe]
jwe
parents: 3021
diff changeset
122 extern octave_value
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
123 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
124
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
125 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
126
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
127 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
128 ;;; Local Variables: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
129 ;;; mode: C++ ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
130 ;;; End: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
131 */