GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-idx.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 John W. Eaton
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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_pt_idx_h)
24 #define octave_pt_idx_h 1
25 
26 #include "octave-config.h"
27 
28 #include <list>
29 
30 class octave_map;
31 class octave_value;
32 class octave_value_list;
33 
34 #include "str-vec.h"
35 
36 #include "pt-exp.h"
37 #include "pt-walk.h"
38 
39 namespace octave
40 {
41  class octave_lvalue;
42  class symbol_scope;
43  class tree_argument_list;
44  class tree_evaluator;
45 
46  // Index expressions.
47 
49  {
50  public:
51 
53  tree_argument_list *lst = nullptr,
54  int l = -1, int c = -1, char t = '(');
55 
57  int l = -1, int c = -1);
58 
60  int l = -1, int c = -1);
61 
62  // No copying!
63 
65 
67 
69 
70  bool has_magic_end (void) const;
71 
72  void append (tree_argument_list *lst = nullptr, char t = '(');
73 
74  void append (const std::string& n);
75 
76  void append (tree_expression *df);
77 
78  bool is_index_expression (void) const { return true; }
79 
80  std::string name (void) const;
81 
82  tree_expression * expression (void) { return m_expr; }
83 
84  std::list<tree_argument_list *> arg_lists (void) { return m_args; }
85 
86  std::string type_tags (void) { return m_type; }
87 
88  std::list<string_vector> arg_names (void) { return m_arg_nm; }
89 
90  std::list<tree_expression *> dyn_fields (void) { return m_dyn_field; }
91 
92  bool lvalue_ok (void) const { return m_expr->lvalue_ok (); }
93 
94  bool rvalue_ok (void) const { return true; }
95 
97 
98  tree_index_expression * dup (symbol_scope& scope) const;
99 
100  void accept (tree_walker& tw)
101  {
102  tw.visit_index_expression (*this);
103  }
104 
107  (tree_evaluator *tw, std::list<string_vector>::const_iterator p_arg_nm,
108  std::list<tree_expression *>::const_iterator p_dyn_field) const;
109 
110  private:
111 
112  // The LHS of this index expression.
114 
115  // The indices (only valid if type == paren || type == brace).
116  std::list<tree_argument_list *> m_args;
117 
118  // The type of this index expression.
120 
121  // The names of the arguments. Used for constant struct element
122  // references.
123  std::list<string_vector> m_arg_nm;
124 
125  // The list of dynamic field names, if any.
126  std::list<tree_expression *> m_dyn_field;
127 
128  tree_index_expression (int l, int c);
129 
130  octave_map make_arg_struct (void) const;
131  };
132 }
133 
134 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
135 
136 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_index_expression' instead")
137 typedef octave::tree_index_expression tree_index_expression;
138 
139 #endif
140 
141 #endif
bool has_magic_end(void) const
Definition: pt-idx.cc:127
bool is_index_expression(void) const
Definition: pt-idx.h:78
tree_index_expression * dup(symbol_scope &scope) const
Definition: pt-idx.cc:388
tree_index_expression & operator=(const tree_index_expression &)=delete
bool rvalue_ok(void) const
Definition: pt-idx.h:94
bool lvalue_ok(void) const
Definition: pt-idx.h:92
octave_lvalue lvalue(tree_evaluator *tw)
Definition: pt-idx.cc:236
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:997
std::list< string_vector > arg_names(void)
Definition: pt-idx.h:88
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
tree_index_expression(tree_expression *e=nullptr, tree_argument_list *lst=nullptr, int l=-1, int c=-1, char t='(')
Definition: pt-idx.cc:50
i e
Definition: data.cc:2591
std::string name(void) const
Definition: pt-idx.cc:142
tree_expression * expression(void)
Definition: pt-idx.h:82
std::list< tree_argument_list * > m_args
Definition: pt-idx.h:116
virtual bool lvalue_ok(void) const
Definition: pt-exp.h:83
std::list< tree_argument_list * > arg_lists(void)
Definition: pt-idx.h:84
std::string type_tags(void)
Definition: pt-idx.h:86
octave_map make_arg_struct(void) const
std::list< string_vector > m_arg_nm
Definition: pt-idx.h:123
virtual void visit_index_expression(tree_index_expression &)=0
tree_expression * m_expr
Definition: pt-idx.h:113
std::list< tree_expression * > m_dyn_field
Definition: pt-idx.h:126
void accept(tree_walker &tw)
Definition: pt-idx.h:100
void append(tree_argument_list *lst=nullptr, char t='(')
Definition: pt-idx.cc:78
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
std::list< tree_expression * > dyn_fields(void)
Definition: pt-idx.h:90
std::string get_struct_index(tree_evaluator *tw, std::list< string_vector >::const_iterator p_arg_nm, std::list< tree_expression *>::const_iterator p_dyn_field) const
Definition: pt-idx.cc:174