Mercurial > octave
annotate libinterp/parse-tree/lex.h @ 27777:3b6920ee4383
eliminate COMMAND_ARG_FINISH macro in lexer
* lex.h, lex.ll (base_lexer::finish_command_arg): New function to do
part of the work of the COMMAND_ARG_FINISH macro.
(COMMAND_ARG_FINISH): Delete macro. Replace all uses with some inline
code and a call to curr_lexer->finish_command_arg.
(base_lexer::handle_token (const std::string&, int)): Delete function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 05 Dec 2019 22:01:02 -0600 |
parents | cd566153edd6 |
children | 2f8559459314 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26345
diff
changeset
|
3 Copyright (C) 1993-2019 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24380
diff
changeset
|
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 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24380
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
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 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24380
diff
changeset
|
19 <https://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> |
8745
6dc61981d18b
better handling of object indexing in lexer
John W. Eaton <jwe@octave.org>
parents:
8701
diff
changeset
|
29 #include <list> |
16101
8d19626b38ae
provide copy contructor and operator = for lexical_feedback class.
John W. Eaton <jwe@octave.org>
parents:
16100
diff
changeset
|
30 #include <set> |
11464
21b5284fa78d
avoid error when parsing nested functions
John W. Eaton <jwe@octave.org>
parents:
11367
diff
changeset
|
31 #include <stack> |
8745
6dc61981d18b
better handling of object indexing in lexer
John W. Eaton <jwe@octave.org>
parents:
8701
diff
changeset
|
32 |
16228
e19b1632d7c1
revamp most comment handling
John W. Eaton <jwe@octave.org>
parents:
16224
diff
changeset
|
33 #include "comment-list.h" |
27766
0ca7f17de041
use file position object to track line and column info in lexer and parser
John W. Eaton <jwe@octave.org>
parents:
27736
diff
changeset
|
34 #include "filepos.h" |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
35 #include "input.h" |
24380
51a1d6c84d0c
* lex.h: Include symscope.h for clang on OS X.
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
36 #include "symscope.h" |
16230
4bf907906134
use a queue to hold tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
16229
diff
changeset
|
37 #include "token.h" |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
38 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
39 namespace octave |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
40 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
41 class interpreter; |
1826 | 42 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
43 // Is the given string a keyword? |
26059
da2bbcf1fbcd
Deprecate C++ function is_keyword in favor of iskeyword for readability.
Rik <rik@octave.org>
parents:
25994
diff
changeset
|
44 extern bool iskeyword (const std::string& s); |
1826 | 45 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
46 // 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
|
47 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
48 class |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
49 lexical_feedback |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
50 { |
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
51 public: |
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
52 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
53 // 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
|
54 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
55 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
|
56 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
57 public: |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
58 |
27443
075602880383
store ref to interpreter in lexical_feedback and symbol_table_context classes
John W. Eaton <jwe@octave.org>
parents:
27162
diff
changeset
|
59 symbol_table_context (interpreter& interp) |
075602880383
store ref to interpreter in lexical_feedback and symbol_table_context classes
John W. Eaton <jwe@octave.org>
parents:
27162
diff
changeset
|
60 : m_interpreter (interp), m_frame_stack () { } |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
61 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
62 ~symbol_table_context (void) { clear (); } |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
63 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
64 void clear (void); |
17796
6b51f5f44aea
find symbols in proper scope when debugging (bug #40397)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
65 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
66 bool empty (void) const { return m_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 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
68 size_t size (void) const { return m_frame_stack.size (); } |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
69 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
70 void pop (void); |
16320
09f0cb9cac7d
don't modify symbol table scope in the parser
John W. Eaton <jwe@octave.org>
parents:
16294
diff
changeset
|
71 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
72 void push (const symbol_scope& scope) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
73 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
74 m_frame_stack.push_front (scope); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
75 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
76 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
77 symbol_scope curr_scope (void) const; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
78 symbol_scope parent_scope (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
|
79 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
80 private: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
81 |
27443
075602880383
store ref to interpreter in lexical_feedback and symbol_table_context classes
John W. Eaton <jwe@octave.org>
parents:
27162
diff
changeset
|
82 interpreter& m_interpreter; |
075602880383
store ref to interpreter in lexical_feedback and symbol_table_context classes
John W. Eaton <jwe@octave.org>
parents:
27162
diff
changeset
|
83 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
84 std::deque<symbol_scope> m_frame_stack; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
85 }; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
86 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
87 // 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
|
88 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
89 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
|
90 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
91 private: |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
92 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
93 enum bracket_type |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
94 { |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
95 BRACKET = 1, |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
96 BRACE = 2, |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
97 PAREN = 3, |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
98 ANON_FCN_BODY = 4 |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
99 }; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
100 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
101 public: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
102 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
103 bbp_nesting_level (void) : m_context () { } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
104 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
105 bbp_nesting_level (const bbp_nesting_level& nl) |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
106 : m_context (nl.m_context) |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
107 { } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
108 |
22196
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& 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
|
110 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
111 if (&nl != this) |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
112 m_context = nl.m_context; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
113 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
114 return *this; |
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 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
117 ~bbp_nesting_level (void) = default; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
118 |
26345
7c6ff9b36302
lex.h: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26059
diff
changeset
|
119 // Alias for clear function. |
7c6ff9b36302
lex.h: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26059
diff
changeset
|
120 void reset (void) { clear (); } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
121 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
122 void bracket (void) { m_context.push (BRACKET); } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
123 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
124 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
|
125 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
126 return ! m_context.empty () && m_context.top () == BRACKET; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
127 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
128 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
129 void brace (void) { m_context.push (BRACE); } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
130 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
131 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
|
132 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
133 return ! m_context.empty () && m_context.top () == BRACE; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
134 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
135 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
136 void paren (void) { m_context.push (PAREN); } |
22196
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 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
|
139 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
140 return ! m_context.empty () && m_context.top () == PAREN; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
141 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
142 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
143 void anon_fcn_body (void) { m_context.push (ANON_FCN_BODY); } |
22196
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 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
|
146 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
147 return ! m_context.empty () && m_context.top () == ANON_FCN_BODY; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
148 } |
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_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
|
151 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
152 return (! m_context.empty () |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
153 && (m_context.top () == BRACKET || m_context.top () == BRACE)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
154 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
155 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
156 bool none (void) { return m_context.empty (); } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
157 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
158 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
|
159 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
160 if (! m_context.empty ()) |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
161 m_context.pop (); |
22196
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
164 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
|
165 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
166 while (! m_context.empty ()) |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
167 m_context.pop (); |
22196
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
170 private: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
171 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
172 std::stack<int> m_context; |
22196
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 class token_cache |
16194
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
176 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
177 public: |
16194
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
178 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
179 // 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
|
180 |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
181 // 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
|
182 // 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
|
183 // |
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
184 // 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
|
185 // 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
|
186 // 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
|
187 // 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
|
188 // 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
|
189 // 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
|
190 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
191 token_cache (void) : m_buffer () { } |
22858
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
192 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
193 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
194 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
195 token_cache (const token_cache&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
196 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
197 token_cache& operator = (const token_cache&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
198 |
22858
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
199 ~token_cache (void) { clear (); } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
200 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
201 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
|
202 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
203 m_buffer.push_front (tok); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
204 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
205 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
206 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
|
207 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
208 if (! empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
209 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
210 delete m_buffer.back (); |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
211 m_buffer.pop_back (); |
22196
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 } |
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 // Direct access. |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
216 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
|
217 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
218 return empty () ? nullptr : m_buffer.at (n); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
219 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
220 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
221 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
|
222 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
223 return empty () ? nullptr : m_buffer.at (n); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
224 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
225 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
226 // Most recently pushed. |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
227 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
|
228 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
229 return empty () ? nullptr : m_buffer.front (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
230 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
231 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
232 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
|
233 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
234 return empty () ? nullptr : m_buffer.front (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
235 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
236 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
237 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
|
238 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
239 return empty () ? nullptr : m_buffer.back (); |
22196
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 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
|
243 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
244 return empty () ? nullptr : m_buffer.back (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
245 } |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
246 |
22858
a183a0929653
eliminate size limit for token cache; provide destructor for class
John W. Eaton <jwe@octave.org>
parents:
22857
diff
changeset
|
247 // Number of elements currently in the buffer. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
248 size_t size (void) const { return m_buffer.size (); } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
249 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
250 bool empty (void) const { return m_buffer.empty (); } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
251 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
252 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
|
253 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
254 while (! empty ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
255 pop (); |
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
258 private: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
259 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
260 std::deque<token *> m_buffer; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
261 }; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
262 |
27443
075602880383
store ref to interpreter in lexical_feedback and symbol_table_context classes
John W. Eaton <jwe@octave.org>
parents:
27162
diff
changeset
|
263 lexical_feedback (interpreter& interp) |
075602880383
store ref to interpreter in lexical_feedback and symbol_table_context classes
John W. Eaton <jwe@octave.org>
parents:
27162
diff
changeset
|
264 : m_interpreter (interp), |
075602880383
store ref to interpreter in lexical_feedback and symbol_table_context classes
John W. Eaton <jwe@octave.org>
parents:
27162
diff
changeset
|
265 m_end_of_input (false), |
26662
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
266 m_allow_command_syntax (true), |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
267 m_at_beginning_of_statement (true), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
268 m_looking_at_anon_fcn_args (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
269 m_looking_at_return_list (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
270 m_looking_at_parameter_list (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
271 m_looking_at_decl_list (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
272 m_looking_at_initializer_expression (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
273 m_looking_at_matrix_or_assign_lhs (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
274 m_looking_for_object_index (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
275 m_looking_at_indirect_ref (false), |
27736
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27528
diff
changeset
|
276 m_parsing_anon_fcn_body (false), |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
277 m_parsing_class_method (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
278 m_parsing_classdef (false), |
26709
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26699
diff
changeset
|
279 m_parsing_classdef_decl (false), |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26699
diff
changeset
|
280 m_parsing_classdef_superclass (false), |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
281 m_maybe_classdef_get_set_method (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
282 m_parsing_classdef_get_method (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
283 m_parsing_classdef_set_method (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
284 m_quote_is_transpose (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
285 m_force_script (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
286 m_reading_fcn_file (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
287 m_reading_script_file (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
288 m_reading_classdef_file (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
289 m_buffer_function_text (false), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
290 m_bracketflag (0), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
291 m_braceflag (0), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
292 m_looping (0), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
293 m_defining_func (0), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
294 m_looking_at_function_handle (0), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
295 m_block_comment_nesting_level (0), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
296 m_command_arg_paren_count (0), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
297 m_token_count (0), |
27766
0ca7f17de041
use file position object to track line and column info in lexer and parser
John W. Eaton <jwe@octave.org>
parents:
27736
diff
changeset
|
298 m_filepos (), |
27768
d6701f835496
use filepos object to store beginning position of character strings
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
299 m_beg_string (), |
d6701f835496
use filepos object to store beginning position of character strings
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
300 m_string_text (), |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
301 m_current_input_line (), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
302 m_comment_text (), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
303 m_help_text (), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
304 m_function_text (), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
305 m_fcn_file_name (), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
306 m_fcn_file_full_name (), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
307 m_dir_name (), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
308 m_package_name (), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
309 m_looking_at_object_index (), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
310 m_parsed_function_name (), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
311 m_pending_local_variables (), |
27443
075602880383
store ref to interpreter in lexical_feedback and symbol_table_context classes
John W. Eaton <jwe@octave.org>
parents:
27162
diff
changeset
|
312 m_symtab_context (interp), |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
313 m_nesting_level (), |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
314 m_tokens () |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
315 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
316 init (); |
16265
71ee3afedb69
5/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16263
diff
changeset
|
317 } |
71ee3afedb69
5/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16263
diff
changeset
|
318 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
319 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
320 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
321 lexical_feedback (const lexical_feedback&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
322 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
323 lexical_feedback& operator = (const lexical_feedback&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
324 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
325 ~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
|
326 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
327 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
|
328 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
329 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
|
330 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
331 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
|
332 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
333 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
|
334 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
335 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
|
336 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
337 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
|
338 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
339 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
|
340 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
341 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
|
342 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
343 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
|
344 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
345 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
|
346 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
347 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
|
348 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
|
349 |
27443
075602880383
store ref to interpreter in lexical_feedback and symbol_table_context classes
John W. Eaton <jwe@octave.org>
parents:
27162
diff
changeset
|
350 interpreter& m_interpreter; |
075602880383
store ref to interpreter in lexical_feedback and symbol_table_context classes
John W. Eaton <jwe@octave.org>
parents:
27162
diff
changeset
|
351 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
352 // true means that we have encountered eof on the input stream. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
353 bool m_end_of_input; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
354 |
26662
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
355 // true means command syntax is allowed. |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
356 bool m_allow_command_syntax; |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
357 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
358 // 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
|
359 // command name is possible. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
360 bool m_at_beginning_of_statement; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
361 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
362 // true means we are parsing an anonymous function argument list. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
363 bool m_looking_at_anon_fcn_args; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
364 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
365 // true means we're parsing the return list for a function. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
366 bool m_looking_at_return_list; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
367 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
368 // true means we're parsing the parameter list for a function. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
369 bool m_looking_at_parameter_list; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
370 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
371 // 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
|
372 // persistent). |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
373 bool m_looking_at_decl_list; |
22196
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 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
|
376 // parameter list element. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
377 bool m_looking_at_initializer_expression; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
378 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
379 // 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
|
380 // multi-value assignment statement. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
381 bool m_looking_at_matrix_or_assign_lhs; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
382 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
383 // object index not possible until we've seen something. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
384 bool m_looking_for_object_index; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
385 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
386 // 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
|
387 // structure element. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
388 bool m_looking_at_indirect_ref; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
389 |
27736
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27528
diff
changeset
|
390 // true means we are parsing the body of an anonymous function. |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27528
diff
changeset
|
391 bool m_parsing_anon_fcn_body; |
bd80e14f268a
improve parse error message for @()x+=expr (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
27528
diff
changeset
|
392 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
393 // true means we are parsing a class method in function or classdef file. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
394 bool m_parsing_class_method; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
395 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
396 // true means we are parsing a classdef file |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
397 bool m_parsing_classdef; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
398 |
26709
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26699
diff
changeset
|
399 // true means we are parsing the initial classdef declaration |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26699
diff
changeset
|
400 // portion of classdef file, from the "classdef" token through the |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26699
diff
changeset
|
401 // optional list of superclasses. |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26699
diff
changeset
|
402 bool m_parsing_classdef_decl; |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26699
diff
changeset
|
403 |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26699
diff
changeset
|
404 // true means we are parsing the superclass part of a classdef |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26699
diff
changeset
|
405 // declaration. |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26699
diff
changeset
|
406 bool m_parsing_classdef_superclass; |
17e7d310def8
revamp parsing of superclass identifiers in classdef decls
John W. Eaton <jwe@octave.org>
parents:
26699
diff
changeset
|
407 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
408 // 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
|
409 // 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
|
410 // for example, "get.propertyname" is recognized as a function name. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
411 bool m_maybe_classdef_get_set_method; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
412 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
413 // TRUE means we are parsing a classdef get.method. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
414 bool m_parsing_classdef_get_method; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
415 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
416 // TRUE means we are parsing a classdef set.method. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
417 bool m_parsing_classdef_set_method; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
418 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
419 // return transpose or start a string? |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
420 bool m_quote_is_transpose; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
421 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
422 // 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
|
423 // token is "function" or "classdef". |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
424 bool m_force_script; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
425 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
426 // TRUE means we're parsing a function file. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
427 bool m_reading_fcn_file; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
428 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
429 // TRUE means we're parsing a script file. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
430 bool m_reading_script_file; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
431 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
432 // TRUE means we're parsing a classdef file. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
433 bool m_reading_classdef_file; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
434 |
23730
85f1d31956c0
make echo work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
435 // TRUE means we should store the text of the function we are |
85f1d31956c0
make echo work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
436 // parsing. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
437 bool m_buffer_function_text; |
23730
85f1d31956c0
make echo work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
438 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
439 // square bracket level count. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
440 int m_bracketflag; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
441 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
442 // curly brace level count. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
443 int m_braceflag; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
444 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
445 // true means we're in the middle of defining a loop. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
446 int m_looping; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
447 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
448 // nonzero means we're in the middle of defining a function. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
449 int m_defining_func; |
22196
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 // nonzero means we are parsing a function handle. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
452 int m_looking_at_function_handle; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
453 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
454 // nestng level for block comments. |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
455 int m_block_comment_nesting_level; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
456 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
457 // Parenthesis count for command argument parsing. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
458 int m_command_arg_paren_count; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
459 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
460 // 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
|
461 // since the last reset. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
462 size_t m_token_count; |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
463 |
27766
0ca7f17de041
use file position object to track line and column info in lexer and parser
John W. Eaton <jwe@octave.org>
parents:
27736
diff
changeset
|
464 // The current position in the file (line and column). |
0ca7f17de041
use file position object to track line and column info in lexer and parser
John W. Eaton <jwe@octave.org>
parents:
27736
diff
changeset
|
465 filepos m_filepos; |
0ca7f17de041
use file position object to track line and column info in lexer and parser
John W. Eaton <jwe@octave.org>
parents:
27736
diff
changeset
|
466 |
27768
d6701f835496
use filepos object to store beginning position of character strings
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
467 // The position of the beginning of the current character string. |
d6701f835496
use filepos object to store beginning position of character strings
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
468 filepos m_beg_string; |
d6701f835496
use filepos object to store beginning position of character strings
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
469 |
d6701f835496
use filepos object to store beginning position of character strings
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
470 // The current character string text. |
d6701f835496
use filepos object to store beginning position of character strings
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
471 std::string m_string_text; |
d6701f835496
use filepos object to store beginning position of character strings
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
472 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
473 // The current line of input. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
474 std::string m_current_input_line; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
475 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
476 // The current comment text. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
477 std::string m_comment_text; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
478 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
479 // The current help text. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
480 std::string m_help_text; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
481 |
23730
85f1d31956c0
make echo work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
482 // The text of functions entered on the command line. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
483 std::string m_function_text; |
23730
85f1d31956c0
make echo work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
484 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
485 // Simple name of function file we are reading. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
486 std::string m_fcn_file_name; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
487 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
488 // Full name of file we are reading. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
489 std::string m_fcn_file_full_name; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
490 |
23667
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
491 // Directory name where this file was found. May be relative. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
492 std::string m_dir_name; |
23667
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
493 |
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
494 // Name of +package containing this file, if any. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
495 std::string m_package_name; |
23667
2d4a7ae1f6cd
store directory and package names in function when function is parsed
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
496 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
497 // 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
|
498 // bracket nesting is an index for an object. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
499 std::list<bool> m_looking_at_object_index; |
22196
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 // 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
|
502 // 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
|
503 // current_function_level > 0 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
504 std::stack<bool> m_parsed_function_name; |
22196
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 // set of identifiers that might be local variable names. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
507 std::set<std::string> m_pending_local_variables; |
22196
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 // Track current symbol table scope and context. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
510 symbol_table_context m_symtab_context; |
22196
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 // 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
|
513 // a paren, or an anonymous function body? |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
514 bbp_nesting_level m_nesting_level; |
22196
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 // Tokens generated by the lexer. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
517 token_cache m_tokens; |
16230
4bf907906134
use a queue to hold tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
16229
diff
changeset
|
518 }; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
519 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
520 // 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
|
521 // eventually have several different constructors and it is easier to |
26699
775643b5eae4
maint: Fix typos in comments where "intial" instead of "initial" used.
Rik <rik@octave.org>
parents:
26662
diff
changeset
|
522 // initialize if everything is grouped in a parent class rather than |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
523 // 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
|
524 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
525 class |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
526 base_lexer : public lexical_feedback |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
527 { |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
528 public: |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
529 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
530 // 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
|
531 |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
532 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
|
533 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
534 public: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
535 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
536 input_buffer (void) |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
537 : m_buffer (), m_pos (nullptr), m_chars_left (0), m_eof (false) |
22196
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 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
540 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
|
541 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
542 // 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
|
543 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
|
544 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
545 bool empty (void) const { return m_chars_left == 0; } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
546 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
547 bool at_eof (void) const { return m_eof; } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
548 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
549 private: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
550 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
551 std::string m_buffer; |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
552 const char *m_pos; |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
553 size_t m_chars_left; |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
554 bool m_eof; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
555 }; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
556 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
557 // 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
|
558 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
559 class |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
560 comment_buffer |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
561 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
562 public: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
563 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
564 comment_buffer (void) : m_comment_list (nullptr) { } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
565 |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
566 ~comment_buffer (void) { delete m_comment_list; } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
567 |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
568 void append (const std::string& s, comment_elt::comment_type t) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
569 { |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
570 if (! m_comment_list) |
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
571 m_comment_list = new comment_list (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
572 |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
573 m_comment_list->append (s, t); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
574 } |
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 // 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
|
577 |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
578 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
|
579 { |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
580 comment_list *retval = m_comment_list; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
581 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
582 m_comment_list = nullptr; |
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 return retval; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
585 } |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
586 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
587 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
|
588 { |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
589 delete m_comment_list; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
590 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23750
diff
changeset
|
591 m_comment_list = nullptr; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
592 } |
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 private: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
595 |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
596 comment_list *m_comment_list; |
22196
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 |
27526
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
599 base_lexer (interpreter& interp) |
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
600 : lexical_feedback (interp), m_scanner (nullptr), m_input_buf (), |
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
601 m_comment_buf () |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
602 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
603 init (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
604 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
605 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
606 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
607 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
608 base_lexer (const base_lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
609 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
610 base_lexer& operator = (const base_lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
611 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
612 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
|
613 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
614 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
|
615 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
616 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
|
617 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
618 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
|
619 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
620 void prep_for_file (void); |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
621 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
622 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
|
623 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
624 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
|
625 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
626 bool at_end_of_buffer (void) const { return m_input_buf.empty (); } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
627 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
628 bool at_end_of_file (void) const { return m_input_buf.at_eof (); } |
22196
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 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
|
631 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
632 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
|
633 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
634 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
|
635 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
636 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
|
637 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
638 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
|
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 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
|
641 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
642 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
|
643 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
644 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
|
645 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
646 bool is_variable (const std::string& name, const symbol_scope& scope); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
647 |
27771
cd566153edd6
split base_lexer::is_keyword_token into two functions
John W. Eaton <jwe@octave.org>
parents:
27768
diff
changeset
|
648 bool is_keyword_token (const std::string& s); |
cd566153edd6
split base_lexer::is_keyword_token into two functions
John W. Eaton <jwe@octave.org>
parents:
27768
diff
changeset
|
649 |
cd566153edd6
split base_lexer::is_keyword_token into two functions
John W. Eaton <jwe@octave.org>
parents:
27768
diff
changeset
|
650 int make_keyword_token (const std::string& s); |
22196
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 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
|
653 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
654 bool whitespace_is_significant (void); |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
655 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
656 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
|
657 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
658 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
|
659 |
23750
ea879bc55272
move comment_list and comment_elt classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23730
diff
changeset
|
660 void finish_comment (comment_elt::comment_type typ); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
661 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
662 comment_list * get_comment (void) { return m_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
|
663 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
664 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
|
665 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
666 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
|
667 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
668 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
|
669 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
670 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
|
671 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
672 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
|
673 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
674 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
|
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 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
|
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 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
|
679 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
680 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
|
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 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
|
683 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
684 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
|
685 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
686 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
|
687 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
688 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
|
689 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
690 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
|
691 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
692 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
|
693 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
694 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
|
695 |
25443
2fa7cd178c4a
new class for miscellaneous interpreter settings
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
696 bool debug_flag (void) const; |
2fa7cd178c4a
new class for miscellaneous interpreter settings
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
697 |
2fa7cd178c4a
new class for miscellaneous interpreter settings
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
698 bool display_tokens (void) const; |
2fa7cd178c4a
new class for miscellaneous interpreter settings
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
699 |
2fa7cd178c4a
new class for miscellaneous interpreter settings
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
700 void increment_token_count (void); |
2fa7cd178c4a
new class for miscellaneous interpreter settings
John W. Eaton <jwe@octave.org>
parents:
25441
diff
changeset
|
701 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
702 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
|
703 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
704 // Internal state of the flex-generated lexer. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
705 void *m_scanner; |
22196
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 // Object that reads and buffers input. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
708 input_buffer m_input_buf; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
709 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
710 // Object that collects comment text. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
711 comment_buffer m_comment_buf; |
22196
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 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
|
714 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
715 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
|
716 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
717 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
|
718 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
719 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
|
720 |
25994
f881d3e271d2
eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents:
25443
diff
changeset
|
721 bool input_from_tmp_history_file (void); |
f881d3e271d2
eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents:
25443
diff
changeset
|
722 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
723 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
|
724 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
725 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
|
726 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
727 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
|
728 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
729 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
|
730 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
731 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
|
732 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
733 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
|
734 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
735 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
|
736 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
|
737 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
738 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
|
739 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
740 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
|
741 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
742 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
|
743 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
744 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
|
745 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
746 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
|
747 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
748 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
|
749 |
27777
3b6920ee4383
eliminate COMMAND_ARG_FINISH macro in lexer
John W. Eaton <jwe@octave.org>
parents:
27771
diff
changeset
|
750 int finish_command_arg (void); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
751 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
752 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
|
753 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
754 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
|
755 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
756 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
|
757 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
758 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
|
759 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
760 protected: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
761 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
762 std::stack<int> start_state_stack; |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
763 }; |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
764 |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
765 class |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
766 lexer : public base_lexer |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
767 { |
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
768 public: |
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
769 |
25441
143007dad864
store reference instead of pointer to interpreter in lexer
John W. Eaton <jwe@octave.org>
parents:
25438
diff
changeset
|
770 lexer (interpreter& interp) |
27528
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
771 : base_lexer (interp), m_reader (interp), m_initial_input (true) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
772 { } |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
773 |
25441
143007dad864
store reference instead of pointer to interpreter in lexer
John W. Eaton <jwe@octave.org>
parents:
25438
diff
changeset
|
774 lexer (FILE *file, interpreter& interp) |
27528
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
775 : base_lexer (interp), m_reader (interp, file), m_initial_input (true) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
776 { } |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
777 |
25441
143007dad864
store reference instead of pointer to interpreter in lexer
John W. Eaton <jwe@octave.org>
parents:
25438
diff
changeset
|
778 lexer (const std::string& eval_string, interpreter& interp) |
27528
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
779 : base_lexer (interp), m_reader (interp, eval_string), |
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
780 m_initial_input (true) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
781 { } |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
782 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
783 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
784 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
785 lexer (const lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
786 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
787 lexer& operator = (const lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
788 |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
789 void reset (void) |
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
790 { |
27528
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
791 m_initial_input = true; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
792 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
793 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
|
794 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
795 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
796 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
|
797 { |
27526
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
798 return m_reader.input_source (); |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
799 } |
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
800 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
801 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
|
802 { |
27526
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
803 return m_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
|
804 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
805 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
806 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
|
807 { |
27526
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
808 return m_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
|
809 } |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
810 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
811 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
|
812 { |
27526
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
813 return m_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
|
814 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
815 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
816 int fill_flex_buffer (char *buf, unsigned int max_size); |
27526
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
817 |
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
818 input_reader m_reader; |
27528
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
819 |
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
820 // TRUE means we are filling the input buffer for the first time. |
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
821 // Otherwise, we are requesting more input to complete the parse |
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
822 // and, if printing a prompt, should use the secondary prompt |
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
823 // string. |
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
824 |
e51284fc0a51
eliminate promptflag from the lexer and input reader classes
John W. Eaton <jwe@octave.org>
parents:
27527
diff
changeset
|
825 bool m_initial_input; |
17693
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
diff
changeset
|
826 }; |
efbe746f8fa8
eliminate octave_comment_buffer singleton
John W. Eaton <jwe@octave.org>
parents:
16898
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 class |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
829 push_lexer : public base_lexer |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
830 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
831 public: |
16113
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
832 |
27526
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
833 push_lexer (interpreter& interp) |
27527
73be3c628eac
refactor input_reader class and its use in lexer
John W. Eaton <jwe@octave.org>
parents:
27526
diff
changeset
|
834 : base_lexer (interp) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
835 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
836 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
|
837 } |
16253
a89cf57ba3a5
partial cleanup of continuation handling in lexer
John W. Eaton <jwe@octave.org>
parents:
16231
diff
changeset
|
838 |
27526
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
839 push_lexer (const std::string& input, interpreter& interp) |
27527
73be3c628eac
refactor input_reader class and its use in lexer
John W. Eaton <jwe@octave.org>
parents:
27526
diff
changeset
|
840 : base_lexer (interp) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
841 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
842 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
|
843 } |
16113
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
844 |
27526
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
845 push_lexer (bool eof, interpreter& interp) |
27527
73be3c628eac
refactor input_reader class and its use in lexer
John W. Eaton <jwe@octave.org>
parents:
27526
diff
changeset
|
846 : base_lexer (interp) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
847 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
848 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
|
849 } |
16209
e7ff32e7cf82
move global promptflag variable to octave_reader class
John W. Eaton <jwe@octave.org>
parents:
16207
diff
changeset
|
850 |
27526
cb964b74d8a0
Backed out changeset 28ed77ca1e4a
John W. Eaton <jwe@octave.org>
parents:
27513
diff
changeset
|
851 push_lexer (const std::string& input, bool eof, interpreter& interp) |
27527
73be3c628eac
refactor input_reader class and its use in lexer
John W. Eaton <jwe@octave.org>
parents:
27526
diff
changeset
|
852 : base_lexer (interp) |
22196
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 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
|
855 } |
16224
4a848eb52de2
use stack for tracking lexer start states
John W. Eaton <jwe@octave.org>
parents:
16209
diff
changeset
|
856 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
857 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
858 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
859 push_lexer (const push_lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
860 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
861 push_lexer& operator = (const push_lexer&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
862 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
863 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
|
864 |
23730
85f1d31956c0
make echo work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
865 void append_input (const std::string& input, bool eof); |
16293
57e87ddfee14
create base class for lexer
John W. Eaton <jwe@octave.org>
parents:
16292
diff
changeset
|
866 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
867 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
|
868 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
869 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
|
870 }; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
21814
diff
changeset
|
871 } |
16294
0925d1f6875e
push parser/lexer interface
John W. Eaton <jwe@octave.org>
parents:
16293
diff
changeset
|
872 |
1 | 873 #endif |