GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-cmd.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1994-2022 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_cmd_h)
27#define octave_pt_cmd_h 1
28
29#include "octave-config.h"
30
31#include <string>
32
33#include "ov-fcn.h"
34#include "pt.h"
35#include "pt-bp.h"
36#include "pt-walk.h"
37
38namespace octave
39{
40 // A base class for commands.
41
42 class tree_command : public tree
43 {
44 public:
45
46 tree_command (int l = -1, int c = -1)
47 : tree (l, c) { }
48
49 // No copying!
50
51 tree_command (const tree_command&) = delete;
52
54
55 virtual ~tree_command (void) = default;
56 };
57
58 // No-op.
59
61 {
62 public:
63
64 tree_no_op_command (const std::string& cmd = "no_op", bool e = false,
65 int l = -1, int c = -1)
66 : tree_command (l, c), m_eof (e), m_orig_cmd (cmd) { }
67
68 // No copying!
69
71
73
74 ~tree_no_op_command (void) = default;
75
77 {
78 tw.visit_no_op_command (*this);
79 }
80
81 bool is_end_of_fcn_or_script (void) const
82 {
83 return (m_orig_cmd == "endfunction" || m_orig_cmd == "endscript");
84 }
85
86 bool is_end_of_file (void) const { return m_eof; }
87
88 std::string original_command (void) { return m_orig_cmd; }
89
90 private:
91
92 bool m_eof;
93
94 std::string m_orig_cmd;
95 };
96
97 // Function definition.
98
100 {
101 public:
102
103 tree_function_def (octave_function *f, int l = -1, int c = -1)
104 : tree_command (l, c), m_fcn (f) { }
105
106 // No copying!
107
109
111
112 ~tree_function_def (void) = default;
113
115 {
116 tw.visit_function_def (*this);
117 }
118
119 octave_value function (void) { return m_fcn; }
120
121 private:
122
124
125 tree_function_def (const octave_value& v, int l = -1, int c = -1)
126 : tree_command (l, c), m_fcn (v) { }
127 };
128}
129
130#endif
virtual ~tree_command(void)=default
tree_command(int l=-1, int c=-1)
Definition: pt-cmd.h:46
tree_command & operator=(const tree_command &)=delete
tree_command(const tree_command &)=delete
tree_function_def(octave_function *f, int l=-1, int c=-1)
Definition: pt-cmd.h:103
~tree_function_def(void)=default
tree_function_def & operator=(const tree_function_def &)=delete
octave_value function(void)
Definition: pt-cmd.h:119
octave_value m_fcn
Definition: pt-cmd.h:123
tree_function_def(const octave_value &v, int l=-1, int c=-1)
Definition: pt-cmd.h:125
tree_function_def(const tree_function_def &)=delete
void accept(tree_walker &tw)
Definition: pt-cmd.h:114
tree_no_op_command(const tree_no_op_command &)=delete
tree_no_op_command(const std::string &cmd="no_op", bool e=false, int l=-1, int c=-1)
Definition: pt-cmd.h:64
bool is_end_of_fcn_or_script(void) const
Definition: pt-cmd.h:81
tree_no_op_command & operator=(const tree_no_op_command &)=delete
std::string m_orig_cmd
Definition: pt-cmd.h:94
~tree_no_op_command(void)=default
void accept(tree_walker &tw)
Definition: pt-cmd.h:76
std::string original_command(void)
Definition: pt-cmd.h:88
bool is_end_of_file(void) const
Definition: pt-cmd.h:86
virtual void visit_no_op_command(tree_no_op_command &)
Definition: pt-walk.cc:463
virtual void visit_function_def(tree_function_def &)
Definition: pt-walk.cc:283
static double f(double k, double l_nu, double c_pm)
Definition: randpoisson.cc:118