Mercurial > hg > octave-lyh
changeset 17363:f0edd6c752e9
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.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 28 Aug 2013 23:00:42 -0400 |
parents | 040752d07240 |
children | 8925147a0101 |
files | libgui/src/resource-manager.cc libinterp/corefcn/variables.cc libinterp/parse-tree/lex.ll libinterp/parse-tree/pt-arg-list.cc libinterp/parse-tree/pt-id.h libinterp/parse-tree/pt-idx.cc |
diffstat | 6 files changed, 9 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/resource-manager.cc +++ b/libgui/src/resource-manager.cc @@ -308,7 +308,6 @@ "__display_tokens__ " "__dsearchn__ " "__dump_symtab_info__ " - "__end__ " "__error_text__ " "__finish__ " "__fltk_ginput__ "
--- a/libinterp/corefcn/variables.cc +++ b/libinterp/corefcn/variables.cc @@ -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
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -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;
--- a/libinterp/parse-tree/pt-arg-list.cc +++ b/libinterp/parse-tree/pt-arg-list.cc @@ -126,7 +126,7 @@ static int index_position = 0; static int num_indices = 0; -DEFCONSTFUN (__end__, , , +DEFCONSTFUN (end, , , "internal function") { octave_value retval;
--- a/libinterp/parse-tree/pt-id.h +++ b/libinterp/parse-tree/pt-id.h @@ -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; }
--- a/libinterp/parse-tree/pt-idx.cc +++ b/libinterp/parse-tree/pt-idx.cc @@ -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);