comparison libinterp/parse-tree/pt-misc.cc @ 16360:11115c237231

recognize variables when parsing (bug #38576) * lex.h, lex.ll (lexical_feedback::mark_as_variable, lexical_feedback::maybe_mark_previous_token_as_variable, lexical_feedback::mark_as_variables, octave_lexer::is_variable): New fucntions. ("="): Call maybe_mark_previous_toke_as_variable. (handle_identifier): Don't tag variables as possible commands. (param_list): Mark names in list as variables. (octave_base_parser::validate_matrix_for_assignment): Likewise. * pt-arg-list.h, pt-arg-list.cc (tree_argument_list::variable_names): New function. * pt-misc.h, pt-misc.cc (tree_parameter_list::variable_names): New function. * token.h, token.cc (token::symbol_name, token::is_symbol): New functions. * test/bug-38576.tst: New file. * test/Makefile.am (FCN_FILES): Add bug-38576.tst to the list.
author John W. Eaton <jwe@octave.org>
date Sat, 23 Mar 2013 15:02:29 -0400
parents 049e8bbff782
children d63878346099
comparison
equal deleted inserted replaced
16359:253e13e77d12 16360:11115c237231
226 226
227 ref.assign (octave_value::op_asn_eq, octave_value ()); 227 ref.assign (octave_value::op_asn_eq, octave_value ());
228 } 228 }
229 } 229 }
230 230
231 std::list<std::string>
232 tree_parameter_list::variable_names (void) const
233 {
234 std::list<std::string> retval;
235
236 for (const_iterator p = begin (); p != end (); p++)
237 {
238 tree_decl_elt *elt = *p;
239
240 retval.push_back (elt->name ());
241 }
242
243 return retval;
244 }
245
231 octave_value_list 246 octave_value_list
232 tree_parameter_list::convert_to_const_vector (int nargout, 247 tree_parameter_list::convert_to_const_vector (int nargout,
233 const Cell& varargout) 248 const Cell& varargout)
234 { 249 {
235 octave_idx_type vlen = varargout.numel (); 250 octave_idx_type vlen = varargout.numel ();