Mercurial > octave
annotate libinterp/parse-tree/token.h @ 29724:c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
This change allows parsing of arguments validation blocks. Octave
should now accept the arguments block syntax in a mostly Matlab
compatible way. Multiple argument blocks are allowed. All arguments
blocks must appear before any other exectuable statements in a function.
Similar to "methods", "properties", etc., "arguments" is defined as a
keyword in the octave.gperf file so that converting "arguments" to the
ARGUMENTS token in the lexer and parser is simplified but it is not
really treated as a reserved keyword in the language. One known
problem with the current approach is that
function [...] = f (...)
arguments = 13;
...
end
will result in a parse error. A simple workaround is to place another
statement (that is not an arguments block) ahead of the "arguments =
..." line in the function. Fixing this problem generally might
require a different parsing method that allows a different type of
lookahead than we currently use.
NOTE: arguments blocks do not currently perform any actions.
Since they may provide default values and/or transform arguments to
different types or values, ignoring the arguments block can lead to
incorrect results.
Octave also currently allows arguments blocks in nested functions
though they should be rejected.
Special treatment of "arguments" and "endarguments" may be disabled by
defining the macro DISABLE_ARGUMENTS_VALIDATION_BLOCK. With this
macro defined, Octave's lexer will never return the ARGUMENTS token,
so the parser will fail to parse these program elements and the
behavior should be the same as prior to this change.
* pt-args-block.h, pt-args-block.cc: New files.
* libinterp/parse-tree/module.mk: Update.
* lex.h, lex.ll (lexical_feedback::m_arguments_is_keyword):
New member variable.
(lexical_feedback::reset): Reset m_arguments_is_keyword to false.
(iskeyword, Fiskeyword): Also handle "arguments" as a special case.
(base_lexer::make_keyword_token): Handle arguments and endarguments.
* parse.h, oct-parse.yy (base_parser::make_arguments_block,
base_parser::make_args_attribute_list,
base_parser::make_arg_validation,
base_parser::make_args_validation_list,
base_parser::append_args_validation_list,
base_parser::make_arg_size_spec,
base_parser::make_arg_validation_fcns): New functions.
(function_body, at_first_executable_stmt, function_body1,
arguments_block, arguments_beg, args_attr_list, args_validation_list,
arg_validation, size_spec, class_name, validation_fcns,
default_value): New non-terminals.
(ARGUMENTS): New token.
(function): Use new function_body and function_body1 non-terminals to
accept arguments blocks, but only at the beginning of a function.
(fcn_name): Set lexer.m_arguments_is_keyword to true after parsing
function name.
(param_list_beg): Set lexer.m_arguments_is_keyword to false while
parsing function parameter list.
(param_list_beg): Reset lexer.m_arguments_is_keyword to true after
parsing function parameter list.
(tree_arguments_block_type, tree_args_block_attribute_list_type,
tree_args_block_validation_list_type, tree_arg_size_spec_type,
tree_arg_validation_type, tree_arg_validation_fcns_type): New
non-terminal types. Also declare %destructors for them.
* octave.gperf (octave_kw_id): New IDs, arguments_kw and endarguments_kw.
Provide entries for arguments and endarguments keywords.
* pt-all.h: Include pt-args-block.h.
* pt-bp.h, pt-bp.cc (tree_breakpoint::visit_arguments_block,
tree_breakpoint::visit_args_block_attribute_list,
tree_breakpoint::visit_args_block_validation_list,
tree_breakpoint::visit_arg_validation,
tree_breakpoint::visit_arg_size_spec,
tree_breakpoint::visit_arg_validation_fcns): New virtual functions for
arguments block elements.
* pt-eval.h, pt-eval.cc (tree_evaluator::visit_arguments_block,
tree_evaluator::visit_args_block_attribute_list,
tree_evaluator::visit_args_block_validation_list,
tree_evaluator::visit_arg_validation,
tree_evaluator::visit_arg_size_spec,
tree_evaluator::visit_arg_validation_fcns): New virtual functions for
arguments block elements.
* pt-pr-code.h, pt-pr-code.cc (tree_print_code::visit_arguments_block,
tree_print_code::visit_args_block_attribute_list,
tree_print_code::visit_args_block_validation_list,
tree_print_code::visit_arg_validation,
tree_print_code::visit_arg_size_spec,
tree_print_code::visit_arg_validation_fcns): New virtual functions for
arguments block elements.
* pt-walk.h, pt-walk.cc (tree_walker::visit_arguments_block,
tree_walker::visit_args_block_attribute_list,
tree_walker::visit_args_block_validation_list,
tree_walker::visit_arg_validation, tree_walker::visit_arg_size_spec,
tree_walker::visit_arg_validation_fcns): New virtual functions for
arguments block elements.
* token.h (end_tok_type): New type, arguments_end.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 01 Jun 2021 13:34:57 -0400 |
parents | 6858992dfadf |
children | 14b098a6ba46 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 // Copyright (C) 1993-2021 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
142 | 25 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20075
diff
changeset
|
26 #if ! defined (octave_token_h) |
383 | 27 #define octave_token_h 1 |
142 | 28 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
29 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
30 |
1755 | 31 #include <string> |
32 | |
27766
0ca7f17de041
use file position object to track line and column info in lexer and parser
John W. Eaton <jwe@octave.org>
parents:
27765
diff
changeset
|
33 #include "filepos.h" |
28582
dc8de424fc72
use octave_value object to store numeric tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
34 #include "ov.h" |
16134
ec9c6222ef5a
move static parser helper functions to octave_parser class
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
35 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
36 namespace octave |
142 | 37 { |
27765
dd93e1fdc7db
require position info when creating tokens for the parser
John W. Eaton <jwe@octave.org>
parents:
26718
diff
changeset
|
38 class token |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
39 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
40 public: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
41 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
42 enum token_type |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
43 { |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
44 generic_token, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
45 keyword_token, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
46 string_token, |
28582
dc8de424fc72
use octave_value object to store numeric tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
47 numeric_token, |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
48 ettype_token, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
49 scls_name_token, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
50 }; |
142 | 51 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
52 enum end_tok_type |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
53 { |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
54 simple_end, |
29724
c19f8cbe0fd5
initial implementation of parsing for arguments validaton block (bug #59405)
John W. Eaton <jwe@octave.org>
parents:
29723
diff
changeset
|
55 arguments_end, |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
56 classdef_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
57 enumeration_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
58 events_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
59 for_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
60 function_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
61 if_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
62 methods_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
63 parfor_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
64 properties_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
65 switch_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
66 try_catch_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
67 unwind_protect_end, |
28517
6e8a9845d118
Add 'spmd' as interpreter keyword for Matlab compatibility (bug #58676).
Rik <rik@octave.org>
parents:
28078
diff
changeset
|
68 spmd_end, |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
69 while_end, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
70 }; |
142 | 71 |
27769
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
72 token (int tv, const filepos& beg_pos, const filepos& end_pos); |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
73 |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
74 token (int tv, bool is_keyword, const filepos& beg_pos |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
75 , const filepos& end_pos); |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
76 |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
77 token (int tv, const char *s, const filepos& beg_pos, |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
78 const filepos& end_pos); |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
79 |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
80 token (int tv, const std::string& s, const filepos& beg_pos, |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
81 const filepos& end_pos); |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
82 |
28582
dc8de424fc72
use octave_value object to store numeric tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
83 token (int tv, const octave_value& val, const std::string& s, |
dc8de424fc72
use octave_value object to store numeric tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
84 const filepos& beg_pos, const filepos& end_pos); |
27769
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
85 |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
86 token (int tv, end_tok_type t, const filepos& beg_pos, |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
87 const filepos& end_pos); |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
88 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
89 token (int tv, const std::string& mth, const std::string& cls, |
27769
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
90 const filepos& beg_pos, const filepos& end_pos); |
142 | 91 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
92 // No copying! |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
93 |
23372 | 94 token (const token&) = delete; |
16257
db7f07b22b9b
1/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
16255
diff
changeset
|
95 |
23372 | 96 token& operator = (const token&) = delete; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
97 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
98 ~token (void); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
99 |
23372 | 100 void mark_may_be_command (void) { m_maybe_cmd = true; } |
101 bool may_be_command (void) const { return m_maybe_cmd; } | |
16255
12bf6a3f8c45
store more info in token value class
John W. Eaton <jwe@octave.org>
parents:
16134
diff
changeset
|
102 |
23372 | 103 void mark_trailing_space (void) { m_tspc = true; } |
104 bool space_follows_token (void) const { return m_tspc; } | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
105 |
23372 | 106 int token_value (void) const { return m_tok_val; } |
107 bool token_value_is (int tv) const { return tv == m_tok_val; } | |
142 | 108 |
27769
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
109 filepos beg_pos (void) const { return m_beg_pos; } |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
110 filepos end_pos (void) const { return m_end_pos; } |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
111 |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
112 void beg_pos (const filepos& pos) { m_beg_pos = pos; } |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
113 void end_pos (const filepos& pos) { m_end_pos = pos; } |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
114 |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
115 // These will probably be removed. |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
116 int line (void) const { return m_beg_pos.line (); } |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
117 int column (void) const { return m_beg_pos.column (); } |
16255
12bf6a3f8c45
store more info in token value class
John W. Eaton <jwe@octave.org>
parents:
16134
diff
changeset
|
118 |
26059
da2bbcf1fbcd
Deprecate C++ function is_keyword in favor of iskeyword for readability.
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
119 bool iskeyword (void) const |
da2bbcf1fbcd
Deprecate C++ function is_keyword in favor of iskeyword for readability.
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
120 { |
da2bbcf1fbcd
Deprecate C++ function is_keyword in favor of iskeyword for readability.
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
121 return m_type_tag == keyword_token || m_type_tag == ettype_token; |
da2bbcf1fbcd
Deprecate C++ function is_keyword in favor of iskeyword for readability.
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
122 } |
da2bbcf1fbcd
Deprecate C++ function is_keyword in favor of iskeyword for readability.
Rik <rik@octave.org>
parents:
25103
diff
changeset
|
123 |
29723
6858992dfadf
enter symbols into current scope in parser instead of lexer
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
124 bool isstring (void) const { return m_type_tag == string_token; } |
16360
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16267
diff
changeset
|
125 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
126 std::string text (void) const; |
28582
dc8de424fc72
use octave_value object to store numeric tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
127 octave_value number (void) const; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
128 token_type ttype (void) const; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
129 end_tok_type ettype (void) const; |
142 | 130 |
26718
9b0335f4bc74
revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
131 std::string superclass_method_name (void) const; |
23372 | 132 std::string superclass_class_name (void) const; |
581 | 133 |
23372 | 134 std::string text_rep (void) const; |
3552 | 135 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
136 private: |
1288 | 137 |
23372 | 138 bool m_maybe_cmd; |
139 | |
140 bool m_tspc; | |
141 | |
27769
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
142 filepos m_beg_pos; |
07ffed9878ad
store begin and end position in tokens
John W. Eaton <jwe@octave.org>
parents:
27766
diff
changeset
|
143 filepos m_end_pos; |
23372 | 144 |
145 int m_tok_val; | |
146 | |
147 token_type m_type_tag; | |
148 | |
149 union tok_info | |
142 | 150 { |
23372 | 151 tok_info (void) { } |
152 | |
153 tok_info (const char *s) : m_str (new std::string (s)) { } | |
154 | |
155 tok_info (const std::string& str) : m_str (new std::string (str)) { } | |
156 | |
28582
dc8de424fc72
use octave_value object to store numeric tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
157 tok_info (const octave_value& num) : m_num (new octave_value (num)) { } |
23372 | 158 |
159 tok_info (end_tok_type et) : m_et (et) { } | |
160 | |
26718
9b0335f4bc74
revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
161 tok_info (const std::string& meth, const std::string& cls) |
9b0335f4bc74
revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
162 : m_superclass_info (new superclass_info (meth, cls)) |
23372 | 163 { } |
164 | |
165 tok_info (const tok_info&) = delete; | |
166 | |
167 tok_info& operator = (const tok_info&) = delete; | |
168 | |
169 ~tok_info (void) { } | |
170 | |
171 std::string *m_str; | |
172 | |
28582
dc8de424fc72
use octave_value object to store numeric tokens in the lexer
John W. Eaton <jwe@octave.org>
parents:
28517
diff
changeset
|
173 octave_value *m_num; |
23372 | 174 |
175 end_tok_type m_et; | |
176 | |
177 struct superclass_info | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
178 { |
23372 | 179 superclass_info (void) = delete; |
180 | |
26718
9b0335f4bc74
revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
181 superclass_info (const std::string& meth, |
26686
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
182 const std::string& cls) |
26718
9b0335f4bc74
revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
183 : m_method_name (meth), m_class_name (cls) |
23372 | 184 { } |
185 | |
186 superclass_info (const superclass_info&) = delete; | |
187 | |
188 superclass_info& operator = (const superclass_info&) = delete; | |
189 | |
190 ~superclass_info (void) = default; | |
191 | |
26718
9b0335f4bc74
revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
192 // The name of the method to call. This is the text before the |
9b0335f4bc74
revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
193 // "@" and may be of the form "object.method". |
9b0335f4bc74
revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
194 std::string m_method_name; |
9b0335f4bc74
revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
195 |
9b0335f4bc74
revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
196 // The name of the superclass. This is the text after the "@" |
9b0335f4bc74
revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents:
26686
diff
changeset
|
197 // and may be of the form "object.method". |
26686
581d01526b34
eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
198 std::string m_class_name; |
23372 | 199 }; |
200 | |
201 superclass_info *m_superclass_info; | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
202 }; |
23372 | 203 |
204 tok_info m_tok_info; | |
205 | |
206 std::string m_orig_text; | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
207 }; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
208 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
209 |
142 | 210 #endif |