Mercurial > hg > octave-nkf
annotate libinterp/parse-tree/pt-colon.h @ 16325:fc565603ccbb
also accept "." as possibly beginning a command
* lex.ll ("."): If it looks like a command, parse it like one.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 16 Mar 2013 04:43:30 -0400 |
parents | 2fc554ffbc28 |
children | d63878346099 |
rev | line source |
---|---|
2980 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
2980 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2980 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2980 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_tree_colon_h) | |
24 #define octave_tree_colon 1 | |
25 | |
26 #include <string> | |
27 | |
28 class tree_walker; | |
29 | |
30 class octave_value; | |
31 class octave_value_list; | |
32 class octave_lvalue; | |
33 | |
34 #include "pt-exp.h" | |
7336 | 35 #include "symtab.h" |
2980 | 36 |
37 // Colon expressions. | |
38 | |
39 class | |
40 tree_colon_expression : public tree_expression | |
41 { | |
42 public: | |
43 | |
44 tree_colon_expression (int l = -1, int c = -1) | |
2990 | 45 : tree_expression (l, c), op_base (0), op_limit (0), |
46 op_increment (0), save_base (false) { } | |
2980 | 47 |
48 tree_colon_expression (tree_expression *e, int l = -1, int c = -1) | |
2990 | 49 : tree_expression (l, c), op_base (e), op_limit (0), |
50 op_increment (0), save_base (false) { } | |
2980 | 51 |
5861 | 52 tree_colon_expression (tree_expression *bas, tree_expression *lim, |
10313 | 53 tree_expression *inc, int l = -1, int c = -1) |
5861 | 54 : tree_expression (l, c), op_base (bas), op_limit (lim), |
55 op_increment (inc), save_base (false) { } | |
56 | |
2980 | 57 ~tree_colon_expression (void) |
58 { | |
2990 | 59 if (! save_base) |
10313 | 60 delete op_base; |
2990 | 61 |
2980 | 62 delete op_limit; |
63 delete op_increment; | |
64 } | |
65 | |
4267 | 66 bool has_magic_end (void) const |
67 { | |
68 return ((op_base && op_base->has_magic_end ()) | |
10313 | 69 || (op_limit && op_limit->has_magic_end ()) |
70 || (op_increment && op_increment->has_magic_end ())); | |
4267 | 71 } |
72 | |
2990 | 73 void preserve_base (void) { save_base = true; } |
74 | |
2980 | 75 tree_colon_expression *append (tree_expression *t); |
76 | |
3933 | 77 bool rvalue_ok (void) const { return true; } |
2980 | 78 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
79 octave_value rvalue1 (int nargout = 1); |
2980 | 80 |
81 octave_value_list rvalue (int nargout); | |
82 | |
8011
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
83 void eval_error (const std::string& s) const; |
2980 | 84 |
85 tree_expression *base (void) { return op_base; } | |
86 | |
87 tree_expression *limit (void) { return op_limit; } | |
88 | |
89 tree_expression *increment (void) { return op_increment; } | |
90 | |
5066 | 91 int line (void) const; |
92 int column (void) const; | |
93 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
94 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 95 symbol_table::context_id context) const; |
5861 | 96 |
2980 | 97 void accept (tree_walker& tw); |
98 | |
99 private: | |
100 | |
101 // The components of the expression. | |
102 tree_expression *op_base; | |
103 tree_expression *op_limit; | |
104 tree_expression *op_increment; | |
2988 | 105 |
2990 | 106 bool save_base; |
107 | |
5347 | 108 octave_value |
109 make_range (const Matrix& m_base, const Matrix& m_limit, | |
10313 | 110 const Matrix& m_increment, bool result_is_str, |
111 bool dq_str) const; | |
5347 | 112 |
113 octave_value | |
114 make_range (const octave_value& ov_base, const octave_value& ov_limit, | |
10313 | 115 const octave_value& ov_increment) const; |
5347 | 116 |
2988 | 117 // No copying! |
118 | |
119 tree_colon_expression (const tree_colon_expression&); | |
120 | |
121 tree_colon_expression& operator = (const tree_colon_expression&); | |
2980 | 122 }; |
123 | |
124 #endif |