Mercurial > octave
diff libinterp/parse-tree/lex.ll @ 29759:ad1491462d13
allow properties function to be called inside classdef method (bug #60763)
* lex.h, lex.ll (lexical_feedback::m_classdef_element_names_are_keywords):
New data member with initial value of false.
(lexical_feedback::reset): Reset it to false.
(base_lexer::make_keyword_token): Use m_classdef_element_names_are_keywords
instead of m_parsing_classdef to decide whether "properties",
"methods", "events", and "enumeration" are handled as keywords.
* oct-parse.yy (properties_beg, methods_beg, events_beg, enumeration_beg):
New non-terminals. Use instead of PROPERTIES, METHODS, EVENTS, and
ENUMERATION in properties_block, methods_block, events_block, and
enum_block. Set lexer.m_classdef_element_names_are_keywords to false
once a block name is recognized.
(property_list, methods_list, events_list, enum_list): Set
lexer.m_classdef_element_names_are_keywords to true at the end of a block.
(classdef_beg): Set lexer.m_classdef_element_names_are_keywords to true.
(class_body): Set lexer.m_classdef_element_names_are_keywords to false.
* test/classdef/bug_60763.m: New file.
* test/classdef/module.mk: Update.
* classdef.tst: New test.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 14 Jun 2021 16:43:33 -0400 |
parents | 05d7b7e64811 |
children | 0b01806bb663 |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll Mon Jun 14 22:00:52 2021 +0200 +++ b/libinterp/parse-tree/lex.ll Mon Jun 14 16:43:33 2021 -0400 @@ -2239,6 +2239,7 @@ m_looking_for_object_index = false; m_looking_at_indirect_ref = false; m_arguments_is_keyword = false; + m_classdef_element_names_are_keywords = false; m_parsing_anon_fcn_body = false; m_parsing_class_method = false; m_parsing_classdef = false; @@ -2843,7 +2844,7 @@ case properties_kw: // 'properties', 'methods' and 'events' are keywords for // classdef blocks. - if (! m_parsing_classdef) + if (! m_classdef_element_names_are_keywords) { m_at_beginning_of_statement = previous_at_bos; return 0;