GNU Octave  4.4.1
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-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_cmd_h)
24 #define octave_pt_cmd_h 1
25 
26 #include "octave-config.h"
27 
28 #include <string>
29 
30 #include "ov-fcn.h"
31 #include "pt.h"
32 #include "pt-bp.h"
33 #include "pt-walk.h"
34 
35 namespace octave
36 {
37  // A base class for commands.
38 
39  class tree_command : public tree
40  {
41  public:
42 
43  tree_command (int l = -1, int c = -1)
44  : tree (l, c) { }
45 
46  // No copying!
47 
48  tree_command (const tree_command&) = delete;
49 
50  tree_command& operator = (const tree_command&) = delete;
51 
52  virtual ~tree_command (void) = default;
53  };
54 
55  // No-op.
56 
58  {
59  public:
60 
61  tree_no_op_command (const std::string& cmd = "no_op", bool e = false,
62  int l = -1, int c = -1)
63  : tree_command (l, c), m_eof (e), m_orig_cmd (cmd) { }
64 
65  // No copying!
66 
67  tree_no_op_command (const tree_no_op_command&) = delete;
68 
70 
71  ~tree_no_op_command (void) = default;
72 
73  void accept (tree_walker& tw)
74  {
75  tw.visit_no_op_command (*this);
76  }
77 
78  bool is_end_of_fcn_or_script (void) const
79  {
80  return (m_orig_cmd == "endfunction" || m_orig_cmd == "endscript");
81  }
82 
83  bool is_end_of_file (void) const { return m_eof; }
84 
86 
87  private:
88 
89  bool m_eof;
90 
92  };
93 
94  // Function definition.
95 
97  {
98  public:
99 
100  tree_function_def (octave_function *f, int l = -1, int c = -1)
101  : tree_command (l, c), m_fcn (f) { }
102 
103  // No copying!
104 
105  tree_function_def (const tree_function_def&) = delete;
106 
108 
109  ~tree_function_def (void) = default;
110 
111  void accept (tree_walker& tw)
112  {
113  tw.visit_function_def (*this);
114  }
115 
116  octave_value function (void) { return m_fcn; }
117 
118  private:
119 
121 
122  tree_function_def (const octave_value& v, int l = -1, int c = -1)
123  : tree_command (l, c), m_fcn (v) { }
124  };
125 }
126 
127 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
128 
129 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_command' instead")
130 typedef octave::tree_command tree_command;
131 
132 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_no_op_command' instead")
133 typedef octave::tree_no_op_command tree_no_op_command;
134 
135 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_function_def' instead")
136 typedef octave::tree_function_def tree_function_def;
137 
138 #endif
139 
140 #endif
virtual void visit_function_def(tree_function_def &)=0
tree_function_def(const octave_value &v, int l=-1, int c=-1)
Definition: pt-cmd.h:122
tree_no_op_command(const std::string &cmd="no_op", bool e=false, int l=-1, int c=-1)
Definition: pt-cmd.h:61
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
void accept(tree_walker &tw)
Definition: pt-cmd.h:111
~tree_function_def(void)=default
tree_no_op_command & operator=(const tree_no_op_command &)=delete
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_no_op_command(void)=default
i e
Definition: data.cc:2591
std::string m_orig_cmd
Definition: pt-cmd.h:91
tree_function_def & operator=(const tree_function_def &)=delete
std::string original_command(void)
Definition: pt-cmd.h:85
tree_command & operator=(const tree_command &)=delete
virtual void visit_no_op_command(tree_no_op_command &)=0
bool is_end_of_file(void) const
Definition: pt-cmd.h:83
virtual ~tree_command(void)=default
tree_function_def(octave_function *f, int l=-1, int c=-1)
Definition: pt-cmd.h:100
void accept(tree_walker &tw)
Definition: pt-cmd.h:73
octave_value m_fcn
Definition: pt-cmd.h:120
tree_command(int l=-1, int c=-1)
Definition: pt-cmd.h:43
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
bool is_end_of_fcn_or_script(void) const
Definition: pt-cmd.h:78