# HG changeset patch # User Michael Goffioul # Date 1390491490 18000 # Node ID 02b349ccf0eca29065c953acb4d9977aa4f8f29d # Parent a91654d70f99aa728d2dd4b13965ea0d177e5ea5 Allow "end" method declaration/definition in classde files. * lex.ll (octave_base_lexer::is_keyword_token): Allow "end" keyword as function/method name in classdef files. * oct-parse.in.yy (rule method_decl): Add mid-rule action to enable proper function name parsing, e.g. allowing "end" as function/method name. diff -r a91654d70f99 -r 02b349ccf0ec libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Thu Jan 23 03:43:41 2014 -0500 +++ b/libinterp/parse-tree/lex.ll Thu Jan 23 10:38:10 2014 -0500 @@ -2344,10 +2344,9 @@ case end_kw: if (inside_any_object_index () - || (! reading_classdef_file - && (defining_func - && ! (looking_at_return_list - || parsed_function_name.top ())))) + || (defining_func + && ! (looking_at_return_list + || parsed_function_name.top ()))) { at_beginning_of_statement = previous_at_bos; return 0; diff -r a91654d70f99 -r 02b349ccf0ec libinterp/parse-tree/oct-parse.in.yy --- a/libinterp/parse-tree/oct-parse.in.yy Thu Jan 23 03:43:41 2014 -0500 +++ b/libinterp/parse-tree/oct-parse.in.yy Thu Jan 23 10:38:10 2014 -0500 @@ -1633,15 +1633,25 @@ ABORT_PARSE; } | identifier param_list - { if (! ($$ = parser.start_classdef_external_method ($1, $2))) + { + if (! ($$ = parser.start_classdef_external_method ($1, $2))) ABORT_PARSE; } ; method_decl : stash_comment method_decl1 { $$ = parser.finish_classdef_external_method ($2, 0, $1); } - | stash_comment return_list '=' method_decl1 - { $$ = parser.finish_classdef_external_method ($4, $2, $1); } + | stash_comment return_list '=' + { + lexer.defining_func++; + lexer.parsed_function_name.push (false); + } + method_decl1 + { + lexer.defining_func--; + lexer.parsed_function_name.pop (); + $$ = parser.finish_classdef_external_method ($5, $2, $1); + } ; method : method_decl