GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt.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_h)
24 #define octave_pt_h 1
25 
26 #include "octave-config.h"
27 
28 #include <string>
29 
30 #include <iosfwd>
31 
32 class octave_function;
33 
34 namespace octave
35 {
36  class tree_walker;
37 
38  // Base class for the parse tree.
39 
40  class tree
41  {
42  public:
43 
44  tree (int l = -1, int c = -1)
45  : m_line_num (l), m_column_num (c), m_bp_cond (nullptr)
46  { }
47 
48  // No copying!
49 
50  tree (const tree&) = delete;
51 
52  tree& operator = (const tree&) = delete;
53 
54  virtual ~tree (void) = default;
55 
56  virtual int line (void) const { return m_line_num; }
57 
58  virtual int column (void) const { return m_column_num; }
59 
60  void line (int l) { m_line_num = l; }
61 
62  void column (int c) { m_column_num = c; }
63 
64  void set_location (int l, int c)
65  {
66  m_line_num = l;
67  m_column_num = c;
68  }
69 
70  virtual void set_breakpoint (const std::string& condition)
71  {
72  if (m_bp_cond)
73  *m_bp_cond = condition;
74  else
75  m_bp_cond = new std::string (condition);
76  }
77 
78  virtual void delete_breakpoint (void)
79  {
80  if (m_bp_cond)
81  {
82  delete m_bp_cond;
83 
84  m_bp_cond = nullptr;
85  }
86  }
87 
88  bool meets_bp_condition (void) const;
89 
90  bool is_breakpoint (bool check_active = false) const
91  {
92  return m_bp_cond && (! check_active || meets_bp_condition ());
93  }
94 
95  // breakpoint condition, or "0" (i.e., "false") if no breakpoint.
96  // To distinguish "0" from a disabled breakpoint, test "is_breakpoint" too.
97  const std::string bp_cond (void) const
98  {
99  return m_bp_cond ? *m_bp_cond : "0";
100  }
101 
103 
104  virtual void accept (tree_walker& tw) = 0;
105 
106  private:
107 
108  // The input line and column where we found the text that was
109  // eventually converted to this tree node.
112 
113  // NULL if no breakpoint, or a breakpoint condition if there is one.
115  };
116 }
117 
118 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
119 
120 OCTAVE_DEPRECATED (4.4, "use 'octave::tree' instead")
121 typedef octave::tree tree;
122 
123 #endif
124 
125 #endif
virtual int line(void) const
Definition: pt.h:56
std::string * m_bp_cond
Definition: pt.h:114
int m_column_num
Definition: pt.h:111
virtual int column(void) const
Definition: pt.h:58
bool meets_bp_condition(void) const
Definition: pt.cc:59
virtual void accept(tree_walker &tw)=0
tree & operator=(const tree &)=delete
bool is_breakpoint(bool check_active=false) const
Definition: pt.h:90
std::string str_print_code(void)
Definition: pt.cc:42
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
void line(int l)
Definition: pt.h:60
int m_line_num
Definition: pt.h:110
void set_location(int l, int c)
Definition: pt.h:64
virtual ~tree(void)=default
const std::string bp_cond(void) const
Definition: pt.h:97
virtual void delete_breakpoint(void)
Definition: pt.h: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
void column(int c)
Definition: pt.h:62
tree(int l=-1, int c=-1)
Definition: pt.h:44
virtual void set_breakpoint(const std::string &condition)
Definition: pt.h:70