Mercurial > hg > octave-avbm
changeset 7634:ae90e05ad299
fix parameter list initializer bug
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 25 Mar 2008 14:32:00 -0400 |
parents | ba15376ddfe1 |
children | ba7a3e20ee3d |
files | src/ChangeLog src/lex.h src/lex.l src/parse.y |
diffstat | 4 files changed, 29 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2008-03-25 John W. Eaton <jwe@octave.org> + + * lex.h (lexical_feedback::looking_at_initializer_expression): + New data member. + * lex.l (lexical_feedback::init): Initialize it. + (handle_identifier): Don't unconditionally force identifiers to be + variables in the current scope. Don't call force_local_variable + for symbols that appear in parameter initializer expressions. + * parse.y (decl_param_init): New parser "subroutine". + (decl2): Use it. Set lexer_flags.looking_at_initializer_expression + to false after parsing initializer. + 2008-03-24 David Bateman <dbateman@free.fr> * data.cc (map_s_s): Fix for sparse/sparse mappers that resulted
--- a/src/lex.h +++ b/src/lex.h @@ -92,6 +92,10 @@ // TRUE means we're parsing the parameter list for a function. bool looking_at_parameter_list; + // TRUE means we are looking at the initializer expression for a + // parameter list element. + bool looking_at_initializer_expression; + // TRUE means we're parsing a matrix or the left hand side of // multi-value assignment statement. bool looking_at_matrix_or_assign_lhs;
--- a/src/lex.l +++ b/src/lex.l @@ -2286,7 +2286,8 @@ { if (next_tok_is_eq || lexer_flags.looking_at_return_list - || lexer_flags.looking_at_parameter_list + || (lexer_flags.looking_at_parameter_list + && ! lexer_flags.looking_at_initializer_expression) || lexer_flags.looking_at_matrix_or_assign_lhs) { force_local_variable (tok); @@ -2312,11 +2313,6 @@ yylval.tok_val = new token (&(symbol_table::insert (tok)), input_line_number, current_input_column); - // FIXME -- this forces a link for tok in the chain of variables for - // the current scope. Probably this step should be done - // differently, maybe in symbol_table::insert? - symbol_table::varref (tok); - token_stack.push (yylval.tok_val); // After seeing an identifer, it is ok to convert spaces to a comma @@ -2364,6 +2360,9 @@ looking_at_return_list = false; looking_at_parameter_list = false; + // Not looking at an argument list initializer expression. + looking_at_initializer_expression = false; + // Not parsing a matrix or the left hand side of multi-value // assignment statement. looking_at_matrix_or_assign_lhs = false;
--- a/src/parse.y +++ b/src/parse.y @@ -929,10 +929,16 @@ } ; +decl_param_init : // empty + { lexer_flags.looking_at_initializer_expression = true; } + decl2 : identifier { $$ = new tree_decl_elt ($1); } - | identifier '=' expression - { $$ = new tree_decl_elt ($1, $3); } + | identifier '=' decl_param_init expression + { + lexer_flags.looking_at_initializer_expression = false; + $$ = new tree_decl_elt ($1, $4); + } ; // ====================