diff libinterp/parse-tree/lex.h @ 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.h	Mon Jun 14 22:00:52 2021 +0200
+++ b/libinterp/parse-tree/lex.h	Mon Jun 14 16:43:33 2021 -0400
@@ -276,6 +276,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),
@@ -390,6 +391,10 @@
     // true means arguments is handled as keyword.
     bool m_arguments_is_keyword;
 
+    // true means "properties", "methods", "events", and "enumeration"
+    // are treated like keywords.
+    bool m_classdef_element_names_are_keywords;
+
     // true means we are parsing the body of an anonymous function.
     bool m_parsing_anon_fcn_body;