# HG changeset patch # User John W. Eaton # Date 1510176607 18000 # Node ID 81d723f0cdfe414e6a1c818d82fe63b6f551c26a # Parent 51954e5cbbc51c224d0bd485489ed1496286be88 clean up change merged from stable * pt-decl.h (tree_decl_elt::name): Now const. (tree_decl_init_list::variable_names): New function. * oct-parse.in.yy (base_parser::make_decl_command): Call tree_decl_init_list::variable_names instead of looping here. diff -r 51954e5cbbc5 -r 81d723f0cdfe libinterp/parse-tree/oct-parse.in.yy --- a/libinterp/parse-tree/oct-parse.in.yy Wed Nov 08 16:32:48 2017 -0500 +++ b/libinterp/parse-tree/oct-parse.in.yy Wed Nov 08 16:30:07 2017 -0500 @@ -3962,17 +3962,8 @@ int l = tok_val->line (); int c = tok_val->column (); - std::list names; - for (tree_decl_init_list::iterator p = lst->begin (); - p != lst->end (); p++) - { - tree_decl_elt *elt = *p; - - std::string nm = elt->name (); - if (! nm.empty ()) - names.push_back (nm); - } - m_lexer.mark_as_variables (names); + if (lst) + m_lexer.mark_as_variables (lst->variable_names ()); switch (tok) { diff -r 51954e5cbbc5 -r 81d723f0cdfe libinterp/parse-tree/pt-decl.h --- a/libinterp/parse-tree/pt-decl.h Wed Nov 08 16:32:48 2017 -0500 +++ b/libinterp/parse-tree/pt-decl.h Wed Nov 08 16:30:07 2017 -0500 @@ -25,6 +25,7 @@ #include "octave-config.h" +#include #include #include "base-list.h" @@ -89,7 +90,7 @@ tree_identifier * ident (void) { return id; } - std::string name (void) { return id ? id->name () : ""; } + std::string name (void) const { return id ? id->name () : ""; } tree_expression * expression (void) { return expr; } @@ -147,6 +148,21 @@ elt->mark_persistent (); } + std::list variable_names (void) const + { + std::list retval; + + for (const tree_decl_elt *elt : *this) + { + std::string nm = elt->name (); + + if (! nm.empty ()) + retval.push_back (nm); + } + + return retval; + } + void accept (tree_walker& tw) { tw.visit_decl_init_list (*this);