GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
settings.cc
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 (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 
38 
40  : m_display_tokens (false), m_token_count (0),
41  m_lexer_debug_flag (false)
42 { }
43 
46  int nargout)
47 {
48  return set_internal_variable (m_display_tokens, args, nargout,
49  "__display_tokens__");
50 }
51 
54  int nargout)
55 {
56  return set_internal_variable (m_lexer_debug_flag, args, nargout,
57  "__lexer_debug_flag__");
58 }
59 
60 DEFMETHOD (__display_tokens__, interp, args, nargout,
61  doc: /* -*- texinfo -*-
62 @deftypefn {} {@var{val} =} __display_tokens__ ()
63 @deftypefnx {} {@var{old_val} =} __display_tokens__ (@var{new_val})
64 @deftypefnx {} {@var{old_val} =} __display_tokens__ (@var{new_val}, "local")
65 Query or set the internal variable that determines whether Octave's
66 lexer displays tokens as they are read.
67 @seealso{__lexer_debug_flag__, __token_count__}
68 @end deftypefn */)
69 {
70  settings& stgs = interp.get_settings ();
71 
72  return stgs.display_tokens (args, nargout);
73 }
74 
75 DEFMETHOD (__token_count__, interp, , ,
76  doc: /* -*- texinfo -*-
77 @deftypefn {} {@var{n} =} __token_count__ ()
78 Return the number of language tokens processed since Octave startup.
79 @seealso{__lexer_debug_flag__, __display_tokens__}
80 @end deftypefn */)
81 {
82  settings& stgs = interp.get_settings ();
83 
84  return octave_value (stgs.token_count ());
85 }
86 
87 DEFMETHOD (__lexer_debug_flag__, interp, args, nargout,
88  doc: /* -*- texinfo -*-
89 @deftypefn {} {@var{val} =} __lexer_debug_flag__ ()
90 @deftypefnx {} {@var{old_val} =} __lexer_debug_flag__ (@var{new_val})
91 Query or set the internal flag that determines whether Octave's lexer prints
92 debug information as it processes an expression.
93 @seealso{__display_tokens__, __token_count__, __parse_debug_flag__}
94 @end deftypefn */)
95 {
96  settings& stgs = interp.get_settings ();
97 
98  return stgs.lexer_debug_flag (args, nargout);
99 }
100 
101 OCTAVE_END_NAMESPACE(octave)
std::size_t token_count() const
Definition: settings.h:66
octave_value lexer_debug_flag(const octave_value_list &args, int nargout)
Definition: settings.cc:53
bool display_tokens() const
Definition: settings.h:56
bool lexer_debug_flag() const
Definition: settings.h:72
octave_value display_tokens(const octave_value_list &args, int nargout)
Definition: settings.cc:45
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition: defun.h:111
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
Definition: variables.cc:583
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))