# HG changeset patch # User John W. Eaton # Date 1294601635 18000 # Node ID 21b5284fa78d9c4de17c5a8276612d8677755217 # Parent ae96756561d07efb485187fdfa965d18d4026c1b avoid error when parsing nested functions diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2011-01-09 John W. Eaton + + * lex.h, lex.ll, oct-parse.yy (lexer_flags::parsed_function_name): + Declare to be std::stack instead of bool. Change all uses. + Bug #32083. + 2011-01-08 Konstantinos Poulios * gl-render.cc (opengl_renderer::draw_axes): Revert positionmode diff --git a/src/lex.h b/src/lex.h --- a/src/lex.h +++ b/src/lex.h @@ -25,6 +25,7 @@ #define octave_lex_h 1 #include +#include // FIXME -- these input buffer things should be members of a // parser input stream class. @@ -117,9 +118,10 @@ // structure element. bool looking_at_indirect_ref; - // TRUE means that we've already seen the name of this function. - // Should only matter if current_function_level > 0 - bool parsed_function_name; + // If the top of the stack is TRUE, then we've already seen the name + // of the current function. Should only matter if + // current_function_level > 0 + std::stack parsed_function_name; // TRUE means we are parsing a class method in function or classdef file. bool parsing_class_method; diff --git a/src/lex.ll b/src/lex.ll --- a/src/lex.ll +++ b/src/lex.ll @@ -617,7 +617,8 @@ lexer_flags.looking_for_object_index = false; lexer_flags.at_beginning_of_statement = false; - if (lexer_flags.defining_func && ! lexer_flags.parsed_function_name) + if (lexer_flags.defining_func + && ! lexer_flags.parsed_function_name.top ()) lexer_flags.looking_at_return_list = true; else lexer_flags.looking_at_matrix_or_assign_lhs = true; @@ -1470,7 +1471,7 @@ && (inside_any_object_index () || (lexer_flags.defining_func && ! (lexer_flags.looking_at_return_list - || lexer_flags.parsed_function_name)))) + || lexer_flags.parsed_function_name.top ())))) return 0; yylval.tok_val = new token (token::simple_end, l, c); @@ -1581,7 +1582,7 @@ promptflag--; lexer_flags.defining_func++; - lexer_flags.parsed_function_name = false; + lexer_flags.parsed_function_name.push (false); if (! (reading_fcn_file || reading_script_file || reading_classdef_file)) @@ -3333,7 +3334,11 @@ // Not initially defining a function. defining_func = 0; - parsed_function_name = false; + + // Not parsing an object index. + while (! parsed_function_name.empty ()) + parsed_function_name.pop (); + parsing_class_method = false; // Not initially defining a class with classdef. diff --git a/src/oct-parse.yy b/src/oct-parse.yy --- a/src/oct-parse.yy +++ b/src/oct-parse.yy @@ -1377,7 +1377,7 @@ { std::string id_name = $1->name (); - lexer_flags.parsed_function_name = true; + lexer_flags.parsed_function_name.top () = true; lexer_flags.maybe_classdef_get_set_method = false; $$ = $1; @@ -2998,7 +2998,7 @@ current_function_depth--; lexer_flags.defining_func--; - lexer_flags.parsed_function_name = false; + lexer_flags.parsed_function_name.pop (); lexer_flags.looking_at_return_list = false; lexer_flags.looking_at_parameter_list = false; }