GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-colon.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_colon_h)
24 #define octave_pt_colon_h 1
25 
26 #include "octave-config.h"
27 
28 #include <string>
29 
30 class octave_value;
31 class octave_value_list;
32 
33 #include "pt-exp.h"
34 #include "pt-walk.h"
35 
36 namespace octave
37 {
38  class symbol_scope;
39 
40  // Colon expressions.
41 
43  {
44  public:
45 
46  tree_colon_expression (int l = -1, int c = -1)
47  : tree_expression (l, c), m_base (nullptr), m_limit (nullptr),
48  m_increment (nullptr), m_save_base (false) { }
49 
51  int l = -1, int c = -1)
52  : tree_expression (l, c), m_base (bas), m_limit (lim),
53  m_increment (nullptr), m_save_base (false) { }
54 
56  tree_expression *inc, int l = -1, int c = -1)
57  : tree_expression (l, c), m_base (bas), m_limit (lim),
58  m_increment (inc), m_save_base (false) { }
59 
60  // No copying!
61 
63 
65 
67  {
68  if (! m_save_base)
69  delete m_base;
70 
71  delete m_limit;
72  delete m_increment;
73  }
74 
75  bool has_magic_end (void) const
76  {
77  return ((m_base && m_base->has_magic_end ())
78  || (m_limit && m_limit->has_magic_end ())
80  }
81 
82  void preserve_base (void) { m_save_base = true; }
83 
84  bool rvalue_ok (void) const { return true; }
85 
86  void eval_error (const std::string& s) const;
87 
88  tree_expression * base (void) { return m_base; }
89 
90  tree_expression * limit (void) { return m_limit; }
91 
92  tree_expression * increment (void) { return m_increment; }
93 
94  tree_expression * dup (symbol_scope& scope) const;
95 
96  void accept (tree_walker& tw)
97  {
98  tw.visit_colon_expression (*this);
99  }
100 
101  private:
102 
103  // The components of the expression.
107 
109  };
110 }
111 
112 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
113 
114 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_colon_expression' instead")
115 typedef octave::tree_colon_expression tree_colon_expression;
116 
117 #endif
118 
119 #endif
tree_expression * m_increment
Definition: pt-colon.h:106
tree_expression * dup(symbol_scope &scope) const
Definition: pt-colon.cc:34
tree_colon_expression & operator=(const tree_colon_expression &)=delete
tree_expression * base(void)
Definition: pt-colon.h:88
virtual bool has_magic_end(void) const =0
virtual void visit_colon_expression(tree_colon_expression &)=0
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
s
Definition: file-io.cc:2729
tree_colon_expression(tree_expression *bas, tree_expression *lim, tree_expression *inc, int l=-1, int c=-1)
Definition: pt-colon.h:55
tree_colon_expression(int l=-1, int c=-1)
Definition: pt-colon.h:46
is false
Definition: cellfun.cc:400
bool rvalue_ok(void) const
Definition: pt-colon.h:84
tree_expression * increment(void)
Definition: pt-colon.h:92
tree_colon_expression(tree_expression *bas, tree_expression *lim, int l=-1, int c=-1)
Definition: pt-colon.h:50
bool has_magic_end(void) const
Definition: pt-colon.h:75
void accept(tree_walker &tw)
Definition: pt-colon.h:96
void eval_error(const std::string &s) const
tree_expression * m_limit
Definition: pt-colon.h:105
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
tree_expression * m_base
Definition: pt-colon.h:104
tree_expression * limit(void)
Definition: pt-colon.h:90