GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
pt.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_pt_h)
27#define octave_pt_h 1
28
29#include "octave-config.h"
30
31#include <string>
32
33#include <iosfwd>
34
35class octave_function;
36
38
39class comment_list;
40class filepos;
41class tree_evaluator;
42class tree_walker;
43
44// Base class for the parse tree.
45
46class tree
47{
48public:
49
50 tree () : m_bp_cond (nullptr) { }
51
52 OCTAVE_DISABLE_COPY_MOVE (tree)
53
54 virtual ~tree () = default;
55
56 virtual int line () const;
57 virtual int column () const;
58
59 virtual filepos beg_pos () const = 0;
60 virtual filepos end_pos () const = 0;
61
62 // FIXME: maybe make this a pure virtual function?
63 virtual comment_list leading_comments () const;
64
65 virtual void set_breakpoint (const std::string& condition)
66 {
67 if (m_bp_cond)
68 *m_bp_cond = condition;
69 else
70 m_bp_cond = new std::string (condition);
71 }
72
73 virtual void delete_breakpoint ()
74 {
75 delete m_bp_cond;
76
77 m_bp_cond = nullptr;
78 }
79
80 bool meets_bp_condition (tree_evaluator& tw) const;
81
82 bool is_breakpoint () const
83 {
84 return m_bp_cond;
85 }
86
88 {
89 return m_bp_cond && meets_bp_condition (tw);
90 }
91
92 // breakpoint condition, or "0" (i.e., "false") if no breakpoint.
93 // To distinguish "0" from a disabled breakpoint, test "is_breakpoint" too.
94 const std::string bp_cond () const
95 {
96 return m_bp_cond ? *m_bp_cond : "0";
97 }
98
99 std::string str_print_code ();
100
101 virtual void accept (tree_walker& tw) = 0;
102
103private:
104
105 // NULL if no breakpoint, or a breakpoint condition if there is one.
106 std::string *m_bp_cond;
107};
108
109OCTAVE_END_NAMESPACE(octave)
110
111#endif
Definition pt.h:47
virtual int line() const
Definition pt.cc:45
virtual filepos end_pos() const =0
virtual filepos beg_pos() const =0
bool is_breakpoint() const
Definition pt.h:82
bool meets_bp_condition(tree_evaluator &tw) const
Definition pt.cc:82
virtual void delete_breakpoint()
Definition pt.h:73
virtual comment_list leading_comments() const
Definition pt.cc:57
std::string str_print_code()
Definition pt.cc:66
const std::string bp_cond() const
Definition pt.h:94
bool is_active_breakpoint(tree_evaluator &tw) const
Definition pt.h:87
tree()
Definition pt.h:50
virtual int column() const
Definition pt.cc:51
virtual void accept(tree_walker &tw)=0
virtual void set_breakpoint(const std::string &condition)
Definition pt.h:65
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn