annotate src/parse.h @ 5307:4c8a2e4e0717

[project @ 2005-04-26 19:24:27 by jwe]
author jwe
date Tue, 26 Apr 2005 19:24:47 +0000
parents 85b315ad5f7d
children 80c1aa832cb2
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
5307
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5189
diff changeset
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5189
diff changeset
20 02110-1301, USA.
1
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 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
23
383
0b52c68ec81f [project @ 1994-03-09 21:19:44 by jwe]
jwe
parents: 338
diff changeset
24 #if !defined (octave_parse_h)
0b52c68ec81f [project @ 1994-03-09 21:19:44 by jwe]
jwe
parents: 338
diff changeset
25 #define octave_parse_h 1
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
27 #include <cstdio>
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
28
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1315
diff changeset
29 #include <string>
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1315
diff changeset
30
4426
51a0dcde8778 [project @ 2003-06-13 19:16:37 by jwe]
jwe
parents: 4342
diff changeset
31 #include <stack>
51a0dcde8778 [project @ 2003-06-13 19:16:37 by jwe]
jwe
parents: 4342
diff changeset
32
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
33 extern void reset_parser (void);
4753
9f0ce1536368 [project @ 2004-02-13 17:55:24 by jwe]
jwe
parents: 4486
diff changeset
34 extern int octave_lex (void);
9f0ce1536368 [project @ 2004-02-13 17:55:24 by jwe]
jwe
parents: 4486
diff changeset
35 extern int octave_parse (void);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
36
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
37 class tree;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
38 class tree_matrix;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
39 class tree_identifier;
4342
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
40 class octaev_function;
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
41 class symbol_record;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
42 class symbol_table;
3772
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
43
e44ffad3d06c [project @ 2001-02-03 06:23:38 by jwe]
jwe
parents: 3523
diff changeset
44 #include "oct-obj.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
45
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
46 // 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
47 extern symbol_table *tmp_local_sym_tab;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
48
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
49 // Nonzero means print parser debugging info (-d).
4753
9f0ce1536368 [project @ 2004-02-13 17:55:24 by jwe]
jwe
parents: 4486
diff changeset
50 extern int octave_debug;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
51
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
52 // The current input line number.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
53 extern int input_line_number;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
54
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
55 // The column of the current token.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
56 extern int current_input_column;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
57
338
82d30a23c979 [project @ 1994-02-07 07:09:33 by jwe]
jwe
parents: 195
diff changeset
58 // Buffer for help text snagged from function files.
4426
51a0dcde8778 [project @ 2003-06-13 19:16:37 by jwe]
jwe
parents: 4342
diff changeset
59 extern std::stack<std::string> help_buf;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
60
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
61 // TRUE means we are using readline.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
62 extern bool line_editing;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
63
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
64 // TRUE means we printed messages about reading startup files.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
65 extern bool reading_startup_message_printed;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
66
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
67 // TRUE means input is coming from startup file.
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
68 extern bool input_from_startup_file;
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
69
3489
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3162
diff changeset
70 // 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
71 // 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
72 // an eval() statement.
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3162
diff changeset
73 extern bool evaluating_function_body;
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3162
diff changeset
74
4186
bf9c5ca4c3f3 [project @ 2002-11-19 00:33:40 by jwe]
jwe
parents: 3772
diff changeset
75 // 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
76 extern std::stack<symbol_table*> symtab_context;
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
77
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
78 // 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
79 // contain nested functions.
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
80 extern std::string parent_function_name;
4186
bf9c5ca4c3f3 [project @ 2002-11-19 00:33:40 by jwe]
jwe
parents: 3772
diff changeset
81
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3156
diff changeset
82 // 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
83 extern bool Vwarn_future_time_stamp;
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3156
diff changeset
84
4238
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
85 // 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
86 extern int end_tokens_expected;
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4214
diff changeset
87
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
88 extern void
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
89 parse_and_execute (FILE *f);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
90
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
91 extern void
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
92 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
93 const char *warn_for = 0);
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
94
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3489
diff changeset
95 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
96
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
97 extern bool
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
98 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
99
4486
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4426
diff changeset
100 extern void
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4426
diff changeset
101 source_file (const std::string file_name);
6ceba1f351fb [project @ 2003-08-22 16:49:46 by jwe]
jwe
parents: 4426
diff changeset
102
3021
18d64612e67a [project @ 1997-06-03 22:18:56 by jwe]
jwe
parents: 2907
diff changeset
103 extern 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
a494f93e60ff [project @ 1998-02-20 07:47:48 by jwe]
jwe
parents: 3100
diff changeset
108 extern 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
813effe14ee1 [project @ 2003-02-20 08:35:55 by jwe]
jwe
parents: 4238
diff changeset
113 extern 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
3100
bea2f5be3eab [project @ 1997-11-14 10:07:50 by jwe]
jwe
parents: 3099
diff changeset
116 extern 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
8ce6fed79320 [project @ 1997-11-14 09:49:28 by jwe]
jwe
parents: 3021
diff changeset
119 extern 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
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
122 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
123
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
124 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
125 ;;; Local Variables: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
126 ;;; mode: C++ ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
127 ;;; End: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
128 */