# HG changeset patch # User John W. Eaton # Date 1377745242 14400 # Node ID f0edd6c752e949c3bc0c49c81d8b8d9507a5c874 # Parent 040752d07240202b71fad29954a016a482b707b1 don't convert "end" token to "__end__" for indexing * lex.ll (octave_base_lexer::handle_identifier): Don't translate "end" to "__end__". * pt-arg-list.cc (Fend): Rename from F__end__. * pt-id.h (tree_identifier::has_magic_end): Recognize "end" instead of "__end__". * pt-idx.cc: Refer to "end" in comment instead of "__end__". * variables.cc (symbol_exist): Return early if keyword is found. * resource-manager.cc (resource_manager::octave_keywords): Delete __end__ from the list. diff -r 040752d07240 -r f0edd6c752e9 libgui/src/resource-manager.cc --- a/libgui/src/resource-manager.cc Fri Aug 30 10:52:16 2013 -0400 +++ b/libgui/src/resource-manager.cc Wed Aug 28 23:00:42 2013 -0400 @@ -308,7 +308,6 @@ "__display_tokens__ " "__dsearchn__ " "__dump_symtab_info__ " - "__end__ " "__error_text__ " "__finish__ " "__fltk_ginput__ " diff -r 040752d07240 -r f0edd6c752e9 libinterp/corefcn/variables.cc --- a/libinterp/corefcn/variables.cc Fri Aug 30 10:52:16 2013 -0400 +++ b/libinterp/corefcn/variables.cc Wed Aug 28 23:00:42 2013 -0400 @@ -401,6 +401,8 @@ struct_elts = name.substr (pos+1); symbol_name = name.substr (0, pos); } + else if (is_keyword (symbol_name)) + return retval; // We shouldn't need to look in the global symbol table, since any // name that is visible in the current scope will be in the local diff -r 040752d07240 -r f0edd6c752e9 libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Fri Aug 30 10:52:16 2013 -0400 +++ b/libinterp/parse-tree/lex.ll Wed Aug 28 23:00:42 2013 -0400 @@ -2723,11 +2723,7 @@ return kw_token; } - // Find the token in the symbol table. Beware the magic - // transformation of the end keyword... - - if (tok == "end") - tok = "__end__"; + // Find the token in the symbol table. symbol_table::scope_id sid = symtab_context.curr_scope (); @@ -2754,7 +2750,9 @@ current_input_column += flex_yyleng (); - if (tok != "__end__") + // The magic end index can't be indexed. + + if (tok != "end") looking_for_object_index = true; at_beginning_of_statement = false; diff -r 040752d07240 -r f0edd6c752e9 libinterp/parse-tree/pt-arg-list.cc --- a/libinterp/parse-tree/pt-arg-list.cc Fri Aug 30 10:52:16 2013 -0400 +++ b/libinterp/parse-tree/pt-arg-list.cc Wed Aug 28 23:00:42 2013 -0400 @@ -126,7 +126,7 @@ static int index_position = 0; static int num_indices = 0; -DEFCONSTFUN (__end__, , , +DEFCONSTFUN (end, , , "internal function") { octave_value retval; diff -r 040752d07240 -r f0edd6c752e9 libinterp/parse-tree/pt-id.h --- a/libinterp/parse-tree/pt-id.h Fri Aug 30 10:52:16 2013 -0400 +++ b/libinterp/parse-tree/pt-id.h Wed Aug 28 23:00:42 2013 -0400 @@ -55,7 +55,7 @@ ~tree_identifier (void) { } - bool has_magic_end (void) const { return (name () == "__end__"); } + bool has_magic_end (void) const { return (name () == "end"); } bool is_identifier (void) const { return true; } diff -r 040752d07240 -r f0edd6c752e9 libinterp/parse-tree/pt-idx.cc --- a/libinterp/parse-tree/pt-idx.cc Fri Aug 30 10:52:16 2013 -0400 +++ b/libinterp/parse-tree/pt-idx.cc Wed Aug 28 23:00:42 2013 -0400 @@ -360,7 +360,7 @@ // contains the second (or third, etc.) "end" token, // so we must evaluate everything up to the point of // that argument list so we can pass the appropriate - // value to the built-in __end__ function. + // value to the built-in end function. const octave_value_list tmp_list = tmp.subsref (type.substr (tmpi, i - tmpi), idx, nargout);