Mercurial > octave
annotate libinterp/parse-tree/lex.h @ 23457:21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
* FigureWindow.h, Logger.cc, Menu.cc, MouseModeActionGroup.h, Object.h,
ObjectFactory.cc, ObjectProxy.h, color-picker.h, documentation-dock-widget.h,
files-dock-widget.h, find-files-dialog.h, history-dock-widget.h,
file-editor-tab.cc, file-editor.cc, file-editor.h, find-dialog.h,
main-window.cc, main-window.h, octave-dock-widget.h, parser.cc, parser.h,
webinfo.h, resource-manager.cc, shortcut-manager.cc, shortcut-manager.h,
terminal-dock-widget.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.h,
workspace-view.h, __magick_read__.cc, call-stack.cc, call-stack.h, cdisplay.c,
display.cc, dlmread.cc, dynamic-ld.cc, ft-text-renderer.cc, gl2ps-print.cc,
graphics.cc, graphics.in.h, input.h, interpreter.cc, interpreter.h, ls-hdf5.cc,
mex.cc, mxarray.in.h, oct-errno.in.cc, oct-fstrm.cc, oct-iostrm.h,
oct-procbuf.cc, oct-stdstrm.h, oct-stream.cc, oct-stream.h, octave-link.cc,
pager.cc, pr-output.cc, profiler.h, qz.cc, sighandlers.cc, strfns.cc,
symtab.cc, symtab.h, typecast.cc, urlwrite.cc, variables.cc, __eigs__.cc,
__init_fltk__.cc, __ode15__.cc, colamd.cc, ov-base-int.cc, ov-base.cc,
ov-bool-mat.cc, ov-bool-sparse.cc, ov-builtin.cc, ov-class.cc, ov-classdef.cc,
ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc,
ov-fcn-inline.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc,
ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-java.cc, ov-java.h, ov-lazy-idx.cc,
ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc,
ov-str-mat.cc, ov-struct.cc, ov-usr-fcn.h, octave.cc, octave.h, bp-table.cc,
jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, lex.h, pt-arg-list.cc,
pt-arg-list.h, pt-array-list.h, pt-cell.h, pt-classdef.h, pt-colon.cc,
pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.h, pt-idx.h, pt-jit.cc, pt-jit.h,
pt-loop.h, pt-mat.h, pt-select.h, pt.h, CSparse.cc, dSparse.cc, DASPK.cc,
DASRT.cc, DASSL.cc, oct-fftw.cc, oct-rand.cc, oct-spparms.cc, child-list.cc,
file-ops.cc, mach-info.cc, oct-env.cc, oct-time.cc, cmd-edit.cc, cmd-hist.cc,
oct-locbuf.cc, oct-shlib.cc, pathsearch.cc, singleton-cleanup.cc,
unwind-prot.h, url-transfer.cc:
Use C++11 nullptr rather than 0 or NULL when possible.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 28 Apr 2017 13:19:12 -0700 |
parents | cd4e1ee28716 |
children | 084245f9bd03 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1993-2017 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
1 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
1 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19852
diff
changeset
|
23 #if ! defined (octave_lex_h) |
383 | 24 #define octave_lex_h 1 |
1 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21102
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21102
diff
changeset
|
27 |
16230
4bf907906134
use a queue to hold tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
16229
diff
changeset
|
28 #include <deque> |
4bf907906134
use a queue to hold tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
16229
diff
changeset
|
29 #include <limits> |
8745
6dc61981d18b
better handling of object indexing in lexer
John W. Eaton <jwe@octave.org>
parents:
8701
diff
changeset
|
30 #include <list> |
16101
8d19626b38ae
provide copy contructor and operator = for lexical_feedback class.
John W. Eaton <jwe@octave.org>
parents:
16100
diff
changeset
|
31 #include <set> |
11464
21b5284fa78d
avoid error when parsing nested functions
John W. Eaton <jwe@octave.org>
parents:
11367
diff
changeset
|
32 #include <stack> |
8745
6dc61981d18b
better handling of object indexing in lexer
John W. Eaton <jwe@octave.org>
parents:
8701
diff
changeset
|
33 |
16228
e19b1632d7c1
revamp most comment handling
John W. Eaton <jwe@octave.org>
parents:
16224
diff
changeset
|
34 #include "comment-list.h" |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
35 #include "input.h" |
16230
4bf907906134
use a queue to hold tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
16229
diff
changeset
|
36 #include "token.h" |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
37 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
38 namespace octave |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
39 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
40 class interpreter; |
1826 | 41 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
42 // Is the given string a keyword? |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
43 extern bool is_keyword (const std::string& s); |
1826 | 44 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
45 // For communication between the lexer and parser. |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
46 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
47 class |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
48 lexical_feedback |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
49 { |
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
50 public: |
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
51 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
52 // Track symbol table information when parsing functions. |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
53 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
54 class symbol_table_context |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
55 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
56 public: |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
57 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
58 symbol_table_context (void) : frame_stack () { } |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
59 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
60 void clear (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
61 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
62 while (! frame_stack.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
63 frame_stack.pop (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
64 } |
17796
6b51f5f44aea
find symbols in proper scope when debugging (bug #40397)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
65 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
66 bool empty (void) const { return frame_stack.empty (); } |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
67 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
68 void pop (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
69 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
70 if (empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
71 panic_impossible (); |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
72 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
73 frame_stack.pop (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
74 } |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
75 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
76 void push (symbol_table::scope_id scope = symbol_table::current_scope ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
77 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
78 frame_stack.push (scope); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
79 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
80 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
81 symbol_table::scope_id curr_scope (void) const |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
82 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
83 return empty () ? symbol_table::current_scope () : frame_stack.top (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
84 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
85 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
86 private: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
87 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
88 std::stack<symbol_table::scope_id> frame_stack; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
89 }; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
90 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
91 // Track nesting of square brackets, curly braces, and parentheses. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
92 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
93 class bbp_nesting_level |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
94 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
95 private: |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
96 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
97 enum bracket_type |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
98 { |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
99 BRACKET = 1, |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
100 BRACE = 2, |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
101 PAREN = 3, |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
102 ANON_FCN_BODY = 4 |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
103 }; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
104 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
105 public: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
106 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
107 bbp_nesting_level (void) : context () { } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
108 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
109 bbp_nesting_level (const bbp_nesting_level& nl) : context (nl.context) { } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
110 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
111 bbp_nesting_level& operator = (const bbp_nesting_level& nl) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
112 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
113 if (&nl != this) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
114 context = nl.context; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
115 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
116 return *this; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
117 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
118 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
119 ~bbp_nesting_level (void) = default; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
120 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
121 void reset (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
122 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
123 while (! context.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
124 context.pop (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
125 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
126 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
127 void bracket (void) { context.push (BRACKET); } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
128 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
129 bool is_bracket (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
130 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
131 return ! context.empty () && context.top () == BRACKET; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
132 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
133 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
134 void brace (void) { context.push (BRACE); } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
135 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
136 bool is_brace (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
137 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
138 return ! context.empty () && context.top () == BRACE; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
139 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
140 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
141 void paren (void) { context.push (PAREN); } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
142 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
143 bool is_paren (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
144 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
145 return ! context.empty () && context.top () == PAREN; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
146 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
147 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
148 void anon_fcn_body (void) { context.push (ANON_FCN_BODY); } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
149 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
150 bool is_anon_fcn_body (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
151 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
152 return ! context.empty () && context.top () == ANON_FCN_BODY; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
153 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
154 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
155 bool is_bracket_or_brace (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
156 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
157 return (! context.empty () |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
158 && (context.top () == BRACKET || context.top () == BRACE)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
159 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
160 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
161 bool none (void) { return context.empty (); } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
162 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
163 void remove (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
164 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
165 if (! context.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
166 context.pop (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
167 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
168 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
169 void clear (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
170 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
171 while (! context.empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
172 context.pop (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
173 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
174 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
175 private: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
176 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
177 std::stack<int> context; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
178 }; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
179 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
180 class token_cache |
16194
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
181 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
182 public: |
16194
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
183 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
184 // Store an "unlimited" number of tokens. |
22858
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
185 |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
186 // Tokens are allocated with new. Delete them when they are |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
187 // removed from the cache. |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
188 // |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
189 // One of the reasons for using this class instead of std::deque |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
190 // directly is that we can ensure that memory is cleaned up |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
191 // properly. It's more tedious to do that with deque since the |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
192 // deque destructor and clear method don't call delete on the |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
193 // elements that it stores. Another reason is that it makes it |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
194 // easier to change the implementation later if needed. |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
195 |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
196 token_cache (void) : buffer () { } |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
197 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
198 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
199 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
200 token_cache (const token_cache&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
201 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
202 token_cache& operator = (const token_cache&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
203 |
22858
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
204 ~token_cache (void) { clear (); } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
205 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
206 void push (token *tok) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
207 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
208 buffer.push_front (tok); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
209 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
210 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
211 void pop (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
212 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
213 if (! empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
214 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
215 delete buffer.back (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
216 buffer.pop_back (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
217 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
218 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
219 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
220 // Direct access. |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
221 token * at (size_t n) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
222 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
223 return empty () ? 0 : buffer.at (n); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
224 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
225 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
226 const token * at (size_t n) const |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
227 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
228 return empty () ? 0 : buffer.at (n); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
229 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
230 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
231 // Most recently pushed. |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
232 token * front (void) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
233 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
234 return empty () ? 0 : buffer.front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
235 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
236 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
237 const token * front (void) const |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
238 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
239 return empty () ? 0 : buffer.front (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
240 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
241 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
242 token * back (void) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
243 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
244 return empty () ? 0 : buffer.back (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
245 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
246 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
247 const token * back (void) const |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
248 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
249 return empty () ? 0 : buffer.back (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
250 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
251 |
22858
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
252 // Number of elements currently in the buffer. |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
253 size_t size (void) const { return buffer.size (); } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
254 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
255 bool empty (void) const { return buffer.empty (); } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
256 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
257 void clear (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
258 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
259 while (! empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
260 pop (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
261 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
262 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
263 private: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
264 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
265 std::deque<token *> buffer; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
266 }; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
267 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
268 lexical_feedback (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
269 : end_of_input (false), at_beginning_of_statement (true), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
270 looking_at_anon_fcn_args (false), looking_at_return_list (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
271 looking_at_parameter_list (false), looking_at_decl_list (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
272 looking_at_initializer_expression (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
273 looking_at_matrix_or_assign_lhs (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
274 looking_for_object_index (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
275 looking_at_indirect_ref (false), parsing_class_method (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
276 parsing_classdef (false), maybe_classdef_get_set_method (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
277 parsing_classdef_get_method (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
278 parsing_classdef_set_method (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
279 quote_is_transpose (false), force_script (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
280 reading_fcn_file (false), reading_script_file (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
281 reading_classdef_file (false), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
282 input_line_number (1), current_input_column (1), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
283 bracketflag (0), braceflag (0), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
284 looping (0), defining_func (0), looking_at_function_handle (0), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
285 block_comment_nesting_level (0), command_arg_paren_count (0), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
286 token_count (0), current_input_line (), comment_text (), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
287 help_text (), string_text (), string_line (0), string_column (0), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
288 fcn_file_name (), fcn_file_full_name (), looking_at_object_index (), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
289 parsed_function_name (), pending_local_variables (), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
290 symtab_context (), nesting_level (), tokens () |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
291 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
292 init (); |
16265
71ee3afedb69
5/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16263
diff
changeset
|
293 } |
71ee3afedb69
5/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16263
diff
changeset
|
294 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
295 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
296 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
297 lexical_feedback (const lexical_feedback&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
298 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
299 lexical_feedback& operator = (const lexical_feedback&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
300 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
301 ~lexical_feedback (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
302 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
303 void init (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
304 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
305 void reset (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
306 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
307 int previous_token_value (void) const; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
308 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
309 bool previous_token_value_is (int tok_val) const; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
310 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
311 void mark_previous_token_trailing_space (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
312 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
313 bool space_follows_previous_token (void) const; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
314 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
315 bool previous_token_is_binop (void) const; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
316 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
317 bool previous_token_is_keyword (void) const; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
318 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
319 bool previous_token_may_be_command (void) const; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
320 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
321 void maybe_mark_previous_token_as_variable (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
322 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
323 void mark_as_variable (const std::string& nm); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
324 void mark_as_variables (const std::list<std::string>& lst); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
325 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
326 // true means that we have encountered eof on the input stream. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
327 bool end_of_input; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
328 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
329 // true means we are at the beginning of a statement, where a |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
330 // command name is possible. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
331 bool at_beginning_of_statement; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
332 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
333 // true means we are parsing an anonymous function argument list. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
334 bool looking_at_anon_fcn_args; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
335 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
336 // true means we're parsing the return list for a function. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
337 bool looking_at_return_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
338 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
339 // true means we're parsing the parameter list for a function. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
340 bool looking_at_parameter_list; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
341 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
342 // true means we're parsing a declaration list (global or |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
343 // persistent). |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
344 bool looking_at_decl_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
345 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
346 // true means we are looking at the initializer expression for a |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
347 // parameter list element. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
348 bool looking_at_initializer_expression; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
349 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
350 // true means we're parsing a matrix or the left hand side of |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
351 // multi-value assignment statement. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
352 bool looking_at_matrix_or_assign_lhs; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
353 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
354 // object index not possible until we've seen something. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
355 bool looking_for_object_index; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
356 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
357 // true means we're looking at an indirect reference to a |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
358 // structure element. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
359 bool looking_at_indirect_ref; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
360 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
361 // true means we are parsing a class method in function or classdef file. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
362 bool parsing_class_method; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
363 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
364 // true means we are parsing a classdef file |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
365 bool parsing_classdef; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
366 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
367 // true means we are parsing a class method declaration line in a |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
368 // classdef file and can accept a property get or set method name. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
369 // for example, "get.propertyname" is recognized as a function name. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
370 bool maybe_classdef_get_set_method; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
371 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
372 // TRUE means we are parsing a classdef get.method. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
373 bool parsing_classdef_get_method; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
374 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
375 // TRUE means we are parsing a classdef set.method. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
376 bool parsing_classdef_set_method; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
377 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
378 // return transpose or start a string? |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
379 bool quote_is_transpose; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
380 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
381 // TRUE means treat the current file as a script even if the first |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
382 // token is "function" or "classdef". |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
383 bool force_script; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
384 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
385 // TRUE means we're parsing a function file. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
386 bool reading_fcn_file; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
387 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
388 // TRUE means we're parsing a script file. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
389 bool reading_script_file; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
390 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
391 // TRUE means we're parsing a classdef file. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
392 bool reading_classdef_file; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
393 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
394 // the current input line number. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
395 int input_line_number; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
396 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
397 // the column of the current token. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
398 int current_input_column; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
399 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
400 // square bracket level count. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
401 int bracketflag; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
402 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
403 // curly brace level count. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
404 int braceflag; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
405 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
406 // true means we're in the middle of defining a loop. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
407 int looping; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
408 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
409 // nonzero means we're in the middle of defining a function. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
410 int defining_func; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
411 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
412 // nonzero means we are parsing a function handle. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
413 int looking_at_function_handle; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
414 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
415 // nestng level for blcok comments. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
416 int block_comment_nesting_level; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
417 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
418 // Parenthesis count for command argument parsing. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
419 int command_arg_paren_count; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
420 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
421 // Count of tokens recognized by this lexer since initialized or |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
422 // since the last reset. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
423 size_t token_count; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
424 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
425 // The current line of input. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
426 std::string current_input_line; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
427 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
428 // The current comment text. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
429 std::string comment_text; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
430 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
431 // The current help text. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
432 std::string help_text; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
433 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
434 // The current character string text. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
435 std::string string_text; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
436 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
437 // The position of the beginning of the current character string. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
438 int string_line; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
439 int string_column; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
440 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
441 // Simple name of function file we are reading. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
442 std::string fcn_file_name; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
443 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
444 // Full name of file we are reading. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
445 std::string fcn_file_full_name; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
446 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
447 // if the front of the list is true, the closest paren, brace, or |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
448 // bracket nesting is an index for an object. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
449 std::list<bool> looking_at_object_index; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
450 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
451 // if the top of the stack is true, then we've already seen the name |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
452 // of the current function. should only matter if |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
453 // current_function_level > 0 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
454 std::stack<bool> parsed_function_name; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
455 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
456 // set of identifiers that might be local variable names. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
457 std::set<std::string> pending_local_variables; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
458 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
459 // Track current symbol table scope and context. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
460 symbol_table_context symtab_context; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
461 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
462 // is the closest nesting level a square bracket, squiggly brace, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
463 // a paren, or an anonymous function body? |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
464 bbp_nesting_level nesting_level; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
465 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
466 // Tokens generated by the lexer. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
467 token_cache tokens; |
16230
4bf907906134
use a queue to hold tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
16229
diff
changeset
|
468 }; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
469 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
470 // base_lexer inherits from lexical_feedback because we will |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
471 // eventually have several different constructors and it is easier to |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
472 // intialize if everything is grouped in a parent class rather than |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
473 // listing all the members in the base_lexer class. |
16193
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
474 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
475 class |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
476 base_lexer : public lexical_feedback |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
477 { |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
478 public: |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
479 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
480 // Handle buffering of input for lexer. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
481 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
482 class input_buffer |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
483 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
484 public: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
485 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
486 input_buffer (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
487 : buffer (), pos (0), chars_left (0), eof (false) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
488 { } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
489 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
490 void fill (const std::string& input, bool eof_arg); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
491 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
492 // Copy at most max_size characters to buf. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
493 int copy_chunk (char *buf, size_t max_size); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
494 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
495 bool empty (void) const { return chars_left == 0; } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
496 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
497 bool at_eof (void) const { return eof; } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
498 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
499 private: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
500 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
501 std::string buffer; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
502 const char *pos; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
503 size_t chars_left; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
504 bool eof; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
505 }; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
506 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
507 // Collect comment text. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
508 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
509 class |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
510 comment_buffer |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
511 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
512 public: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
513 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
514 comment_buffer (void) : comment_list (0) { } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
515 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
516 ~comment_buffer (void) { delete comment_list; } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
517 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
518 void append (const std::string& s, octave_comment_elt::comment_type t) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
519 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
520 if (! comment_list) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
521 comment_list = new octave_comment_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
522 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
523 comment_list->append (s, t); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
524 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
525 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
526 // Caller is expected to delete the returned value. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
527 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
528 octave_comment_list * get_comment (void) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
529 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
530 octave_comment_list *retval = comment_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
531 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
532 comment_list = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
533 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
534 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
535 } |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
536 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
537 void reset (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
538 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
539 delete comment_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
540 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
541 comment_list = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
542 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
543 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
544 private: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
545 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
546 octave_comment_list *comment_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
547 }; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
548 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
549 base_lexer (interpreter *interp_context = nullptr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
550 : lexical_feedback (), scanner (0), input_buf (), comment_buf (), |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
551 m_interp_context (interp_context) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
552 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
553 init (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
554 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
555 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
556 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
557 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
558 base_lexer (const base_lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
559 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
560 base_lexer& operator = (const base_lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
561 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
562 virtual ~base_lexer (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
563 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
564 void init (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
565 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
566 virtual bool is_push_lexer (void) const { return false; } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
567 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
568 virtual void reset (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
569 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
570 void prep_for_file (void); |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
571 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
572 void begin_string (int state); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
573 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
574 virtual int fill_flex_buffer (char *buf, unsigned int max_size) = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
575 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
576 bool at_end_of_buffer (void) const { return input_buf.empty (); } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
577 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
578 bool at_end_of_file (void) const { return input_buf.at_eof (); } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
579 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
580 int handle_end_of_input (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
581 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
582 char * flex_yytext (void); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
583 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
584 int flex_yyleng (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
585 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
586 int text_yyinput (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
587 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
588 void xunput (char c, char *buf); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
589 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
590 void xunput (char c); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
591 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
592 bool looking_at_space (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
593 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
594 bool inside_any_object_index (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
595 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
596 bool is_variable (const std::string& name, symbol_table::scope_id scope); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
597 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
598 int is_keyword_token (const std::string& s); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
599 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
600 bool fq_identifier_contains_keyword (const std::string& s); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
601 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
602 bool whitespace_is_significant (void); |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
603 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
604 void handle_number (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
605 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
606 void handle_continuation (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
607 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
608 void finish_comment (octave_comment_elt::comment_type typ); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
609 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
610 octave_comment_list * get_comment (void) { return comment_buf.get_comment (); } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
611 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
612 int handle_close_bracket (int bracket_type); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
613 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
614 bool looks_like_command_arg (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
615 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
616 int handle_superclass_identifier (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
617 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
618 int handle_meta_identifier (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
619 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
620 int handle_fq_identifier (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
621 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
622 int handle_identifier (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
623 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
624 void maybe_warn_separator_insert (char sep); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
625 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
626 void warn_single_quote_string (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
627 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
628 void warn_language_extension (const std::string& msg); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
629 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
630 void maybe_warn_language_extension_comment (char c); |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
631 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
632 void warn_language_extension_continuation (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
633 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
634 void warn_language_extension_operator (const std::string& op); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
635 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
636 void push_token (token *); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
637 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
638 token * current_token (void); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
639 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
640 void display_token (int tok); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
641 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
642 void fatal_error (const char *msg); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
643 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
644 void lexer_debug (const char *pattern); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
645 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
646 // Internal state of the flex-generated lexer. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
647 void *scanner; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
648 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
649 // Object that reads and buffers input. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
650 input_buffer input_buf; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
651 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
652 // Object that collects comment text. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
653 comment_buffer comment_buf; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
654 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
655 // Interpreter that contains us, if any. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
656 interpreter *m_interp_context; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
657 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
658 virtual void increment_promptflag (void) = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
659 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
660 virtual void decrement_promptflag (void) = 0; |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
661 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
662 virtual int promptflag (void) const = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
663 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
664 virtual int promptflag (int) = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
665 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
666 virtual std::string input_source (void) const { return "unknown"; } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
667 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
668 virtual bool input_from_terminal (void) const { return false; } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
669 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
670 virtual bool input_from_file (void) const { return false; } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
671 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
672 virtual bool input_from_eval_string (void) const { return false; } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
673 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
674 void push_start_state (int state); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
675 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
676 void pop_start_state (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
677 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
678 void clear_start_state (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
679 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
680 int start_state (void) const { return start_state_stack.top (); } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
681 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
682 void display_start_state (void) const; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
683 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
684 int handle_op (const char *pattern, int tok, bool bos = false); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
685 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
686 int handle_language_extension_op (const char *pattern, int tok, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
687 bool bos = false); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
688 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
689 bool maybe_unput_comma_before_unary_op (int tok); |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
690 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
691 int handle_unary_op (int tok, bool bos = false); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
692 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
693 int handle_language_extension_unary_op (int tok, bool bos = false); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
694 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
695 int handle_assign_op (const char *pattern, int tok); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
696 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
697 int handle_language_extension_assign_op (const char *pattern, int tok); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
698 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
699 int handle_op_internal (int tok, bool bos, bool compat); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
700 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
701 int handle_token (const std::string& name, int tok); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
702 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
703 int handle_token (int tok, token *tok_val = nullptr); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
704 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
705 int count_token (int tok); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
706 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
707 int count_token_internal (int tok); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
708 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
709 int show_token (int tok); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
710 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
711 void enable_fq_identifier (void); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
712 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
713 protected: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
714 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
715 std::stack<int> start_state_stack; |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
716 }; |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
717 |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
718 class |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
719 lexer : public base_lexer |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
720 { |
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
721 public: |
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
722 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
723 lexer (interpreter *interp_context = nullptr) |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
724 : base_lexer (interp_context), reader (this) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
725 { } |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
726 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
727 lexer (FILE *file, interpreter *interp_context = nullptr) |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
728 : base_lexer (interp_context), reader (file, this) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
729 { } |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
730 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
731 lexer (const std::string& eval_string, |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
732 interpreter *interp_context = nullptr) |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
733 : base_lexer (interp_context), reader (eval_string, this) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
734 { } |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
735 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
736 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
737 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
738 lexer (const lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
739 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
740 lexer& operator = (const lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
741 |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
742 void reset (void) |
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
743 { |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
744 reader.reset (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
745 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
746 base_lexer::reset (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
747 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
748 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
749 void increment_promptflag (void) { reader.increment_promptflag (); } |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
750 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
751 void decrement_promptflag (void) { reader.decrement_promptflag (); } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
752 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
753 int promptflag (void) const { return reader.promptflag (); } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
754 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
755 int promptflag (int n) { return reader.promptflag (n); } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
756 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
757 std::string input_source (void) const |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
758 { |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
759 return reader.input_source (); |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
760 } |
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
761 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
762 bool input_from_terminal (void) const |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
763 { |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
764 return reader.input_from_terminal (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
765 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
766 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
767 bool input_from_file (void) const |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
768 { |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
769 return reader.input_from_file (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
770 } |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
771 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
772 bool input_from_eval_string (void) const |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
773 { |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
774 return reader.input_from_eval_string (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
775 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
776 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
777 int fill_flex_buffer (char *buf, unsigned int max_size); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
778 |
23061
aedc662896a3
move input reader classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
779 input_reader reader; |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
780 }; |
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
781 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
782 class |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
783 push_lexer : public base_lexer |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
784 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
785 public: |
16113
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
786 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
787 push_lexer (interpreter *interp_context = nullptr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
788 : base_lexer (interp_context), pflag (1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
789 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
790 append_input ("", false); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
791 } |
16253
a89cf57ba3a5
partial cleanup of continuation handling in lexer
John W. Eaton <jwe@octave.org>
parents:
16231
diff
changeset
|
792 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
793 push_lexer (const std::string& input, |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
794 interpreter *interp_context = nullptr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
795 : base_lexer (interp_context), pflag (1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
796 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
797 append_input (input, false); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
798 } |
16113
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
799 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
800 push_lexer (bool eof, interpreter *interp_context = nullptr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
801 : base_lexer (interp_context), pflag (1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
802 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
803 append_input ("", eof); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
804 } |
16209
e7ff32e7cf82
move global promptflag variable to octave_reader class
John W. Eaton <jwe@octave.org>
parents:
16207
diff
changeset
|
805 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
806 push_lexer (const std::string& input, bool eof, |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
807 interpreter *interp_context = nullptr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
808 : base_lexer (interp_context), pflag (1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
809 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
810 append_input (input, eof); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
811 } |
16224
4a848eb52de2
use stack for tracking lexer start states
John W. Eaton <jwe@octave.org>
parents:
16209
diff
changeset
|
812 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
813 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
814 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
815 push_lexer (const push_lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
816 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
817 push_lexer& operator = (const push_lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
818 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
819 bool is_push_lexer (void) const { return true; } |
16263
9acb86e6ac90
4/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16259
diff
changeset
|
820 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
821 void reset (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
822 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
823 promptflag (1); |
16229
7b7b1e4968e8
use functions instead of token return macros in lexer
John W. Eaton <jwe@octave.org>
parents:
16228
diff
changeset
|
824 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
825 base_lexer::reset (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
826 } |
16293
57e87ddfee14
create base class for lexer
John W. Eaton <jwe@octave.org>
parents:
16292
diff
changeset
|
827 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
828 void append_input (const std::string& input, bool eof) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
829 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
830 input_buf.fill (input, eof); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
831 } |
16293
57e87ddfee14
create base class for lexer
John W. Eaton <jwe@octave.org>
parents:
16292
diff
changeset
|
832 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
833 void increment_promptflag (void) { pflag++; } |
16293
57e87ddfee14
create base class for lexer
John W. Eaton <jwe@octave.org>
parents:
16292
diff
changeset
|
834 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
835 void decrement_promptflag (void) { pflag--; } |
16293
57e87ddfee14
create base class for lexer
John W. Eaton <jwe@octave.org>
parents:
16292
diff
changeset
|
836 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
837 int promptflag (void) const { return pflag; } |
16293
57e87ddfee14
create base class for lexer
John W. Eaton <jwe@octave.org>
parents:
16292
diff
changeset
|
838 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
839 int promptflag (int n) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
840 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
841 int retval = pflag; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
842 pflag = n; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
843 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
844 } |
1826 | 845 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
846 std::string input_source (void) const { return "push buffer"; } |
16294
0925d1f6875e
push parser/lexer interface
John W. Eaton <jwe@octave.org>
parents:
16293
diff
changeset
|
847 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
848 int fill_flex_buffer (char *buf, unsigned int max_size); |
16294
0925d1f6875e
push parser/lexer interface
John W. Eaton <jwe@octave.org>
parents:
16293
diff
changeset
|
849 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
850 protected: |
16294
0925d1f6875e
push parser/lexer interface
John W. Eaton <jwe@octave.org>
parents:
16293
diff
changeset
|
851 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
852 int pflag; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
853 }; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
854 } |
16294
0925d1f6875e
push parser/lexer interface
John W. Eaton <jwe@octave.org>
parents:
16293
diff
changeset
|
855 |
1 | 856 #endif |