GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
settings.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2018-2021 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 (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include "defun.h"
31 #include "interpreter.h"
32 #include "ov.h"
33 #include "ovl.h"
34 #include "settings.h"
35 #include "variables.h"
36 
37 namespace octave
38 {
40  : m_display_tokens (false), m_token_count (0),
41  m_lexer_debug_flag (false)
42  { }
43 
45  int nargout)
46  {
47  return set_internal_variable (m_display_tokens, args, nargout,
48  "__display_tokens__");
49  }
50 
52  int nargout)
53  {
54  return set_internal_variable (m_lexer_debug_flag, args, nargout,
55  "__lexer_debug_flag__");
56  }
57 }
58 
59 DEFMETHOD (__display_tokens__, interp, args, nargout,
60  doc: /* -*- texinfo -*-
61 @deftypefn {} {} __display_tokens__ ()
62 Query or set the internal variable that determines whether Octave's
63 lexer displays tokens as they are read.
64 @seealso{__lexer_debug_flag__, __token_count__}
65 @end deftypefn */)
66 {
67  octave::settings& stgs = interp.get_settings ();
68 
69  return stgs.display_tokens (args, nargout);
70 }
71 
72 DEFMETHOD (__token_count__, interp, , ,
73  doc: /* -*- texinfo -*-
74 @deftypefn {} {} __token_count__ ()
75 Return the number of language tokens processed since Octave startup.
76 @seealso{__lexer_debug_flag__, __display_tokens__}
77 @end deftypefn */)
78 {
79  octave::settings& stgs = interp.get_settings ();
80 
81  return octave_value (stgs.token_count ());
82 }
83 
84 DEFMETHOD (__lexer_debug_flag__, interp, args, nargout,
85  doc: /* -*- texinfo -*-
86 @deftypefn {} {@var{val} =} __lexer_debug_flag__ ()
87 @deftypefnx {} {@var{old_val} =} __lexer_debug_flag__ (@var{new_val})
88 Query or set the internal flag that determines whether Octave's lexer prints
89 debug information as it processes an expression.
90 @seealso{__display_tokens__, __token_count__, __parse_debug_flag__}
91 @end deftypefn */)
92 {
93  octave::settings& stgs = interp.get_settings ();
94 
95  return stgs.lexer_debug_flag (args, nargout);
96 }
bool m_display_tokens
Definition: settings.h:86
size_t token_count(void) const
Definition: settings.h:68
octave_value display_tokens(const octave_value_list &args, int nargout)
Definition: settings.cc:44
bool lexer_debug_flag(void) const
Definition: settings.h:74
octave_value lexer_debug_flag(const octave_value_list &args, int nargout)
Definition: settings.cc:51
bool display_tokens(void) const
Definition: settings.h:58
bool m_lexer_debug_flag
Definition: settings.h:92
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition: defun.h:138
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
Definition: variables.cc:608