GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
settings.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2018-2024 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_settings_h)
27 #define octave_settings_h 1
28 
29 #include "octave-config.h"
30 
31 #include <cstddef>
32 
33 class octave_value;
34 class octave_value_list;
35 
37 
38 // Most settings for the interpreter are stored in the classes which
39 // they affect (intput_system, output_system, load_path, etc. Some
40 // don't really fit anywhere else. For example, there is no single
41 // lexer or parser object, so we store settings for those things
42 // here.
43 
44 class settings
45 {
46 public:
47 
48  settings ();
49 
50  OCTAVE_DISABLE_COPY_MOVE (settings)
51 
52  ~settings () = default;
53 
54  octave_value display_tokens (const octave_value_list& args, int nargout);
55 
56  bool display_tokens () const { return m_display_tokens; }
57 
58  bool display_tokens (bool flag)
59  {
60  bool val = m_display_tokens;
61  m_display_tokens = flag;
62  return val;
63  }
64 
65  // Read only.
66  std::size_t token_count () const { return m_token_count; }
67 
68  void increment_token_count () { ++m_token_count; }
69 
70  octave_value lexer_debug_flag (const octave_value_list& args, int nargout);
71 
72  bool lexer_debug_flag () const { return m_lexer_debug_flag; }
73 
74  bool lexer_debug_flag (bool flag)
75  {
76  bool val = m_lexer_debug_flag;
77  m_lexer_debug_flag = flag;
78  return val;
79  }
80 
81 private:
82 
83  // Display tokens as they are processed, for debugging.
84  bool m_display_tokens = false;
85 
86  // Number of tokens processed since interpreter startup.
87  std::size_t m_token_count = 0;
88 
89  // Internal variable for lexer debugging state.
90  bool m_lexer_debug_flag = false;
91 };
92 
93 OCTAVE_END_NAMESPACE(octave)
94 
95 #endif
std::size_t token_count() const
Definition: settings.h:66
bool display_tokens(bool flag)
Definition: settings.h:58
bool lexer_debug_flag(bool flag)
Definition: settings.h:74
bool display_tokens() const
Definition: settings.h:56
bool lexer_debug_flag() const
Definition: settings.h:72
void increment_token_count()
Definition: settings.h:68
~settings()=default
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn