Mercurial > hg > octave-nkf
changeset 18409:02b349ccf0ec
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.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Thu, 23 Jan 2014 10:38:10 -0500 |
parents | a91654d70f99 |
children | 097202cbe564 |
files | libinterp/parse-tree/lex.ll libinterp/parse-tree/oct-parse.in.yy |
diffstat | 2 files changed, 16 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -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;
--- a/libinterp/parse-tree/oct-parse.in.yy +++ b/libinterp/parse-tree/oct-parse.in.yy @@ -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