Mercurial > octave
diff libinterp/parse-tree/lex.ll @ 26686:581d01526b34
eliminate unnecessary tree_funcall class
The tree_funcall class was only used to handled generated calls to
internal functions used by classdef superclass reference and metaclass
query operations. This change replaces those function calls by
something more direct.
* pt-classdef.h, pt-classdef.cc (tree_superclass_ref,
tree_metaclass_query): New classes.
* pt-walk.h (tree_walker::visit_tree_funcall): Delete. Update all
derived classes.
(tree_walker::visit_superclass_ref,
tree_walker::visit_metaclass_query): New virtual functions.
* pt-pr-code.h, pt-pr-code.cc (tree_print_code::visit
(tree_print_code::visit_superclass_ref,
tree_print_code::visit_metaclass_query):
Correctly print these parse tree elements.
* oct-parse.yy (superclass_identifier, meta_identifier): Use new
tree_superclass_ref tree_metaclass_query classes instead of
tree_funcall to represent these language elements.
* lex.ll (base_lexer::handle_superclass_identifier): Attempt to make
intent of code clearer. Save line and column info in token.
* pt-eval.h, pt-eval.cc (tree_evaluator::visit_funcall): Delete.
(tree_evaluator::visit_superclass_ref,
tree_evaluator::visit_metaclass_query): New functions. Handle
superclass reference and metaclass query operations more directly.
* ov-classdef.h, ov-classdef.cc (F__superclass_reference__,
F__meta_class_query__): Delete.
(class octave_classdef_superclass_ref): Work directly with
method or object and class names as strings instead of octave_value
objects.
(octave_classdef::superclass_ref, octave_classdef::metaclass_query):
New static functions.
* token.h, token.cc: Attempt to use clearer names for superclass
reference tokens.
* pt-funcall.h, pt-funcall.cc: Delete.
* libinterp/parse-tree/module.mk: Update.
* pt-all.h: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 07 Feb 2019 00:03:55 +0000 |
parents | 05fc703b419a |
children | 606605d0cd31 |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll Wed Feb 06 15:02:37 2019 -0800 +++ b/libinterp/parse-tree/lex.ll Thu Feb 07 00:03:55 2019 +0000 @@ -2965,13 +2965,14 @@ int base_lexer::handle_superclass_identifier (void) { - std::string meth = flex_yytext (); - - size_t pos = meth.find ("@"); - std::string cls = meth.substr (pos + 1); - meth = meth.substr (0, pos); - - bool kw_token = (is_keyword_token (meth) + std::string txt = flex_yytext (); + + size_t pos = txt.find ("@"); + + std::string meth_or_obj = txt.substr (0, pos); + std::string cls = txt.substr (pos + 1); + + bool kw_token = (is_keyword_token (meth_or_obj) || fq_identifier_contains_keyword (cls)); if (kw_token) @@ -2986,7 +2987,7 @@ return count_token_internal (LEXICAL_ERROR); } - push_token (new token (SUPERCLASSREF, meth, cls, + push_token (new token (SUPERCLASSREF, meth_or_obj, cls, m_input_line_number, m_current_input_column)); m_current_input_column += flex_yyleng ();