# HG changeset patch # User John W. Eaton # Date 1234200192 18000 # Node ID 1652e39b934e9642177f06e4bdd4a3bc5e082184 # Parent 314be237cd5b716245f5c2ffb4d6297b777d6bb0 handle command names in declaration lists diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2009-02-09 John W. Eaton + + * lex.l (lexical_feedback::looking_at_decl_list): New data member. + * lex.l (lexical_feedback::init): Initialize it. + (handle_identifier): Also force local variable if looking_at_decl_list. + * parse.y (parsing_decl_list): New non-terminal. + (declaration): Use it. Set lexer_flags.looking_at_decl_list to + false after parsing the declaration. + 2009-02-09 Jaroslav Hajek * TEMPLATE-INST/Array-tc.cc: Reflect changes in octave_sort. diff --git a/src/lex.h b/src/lex.h --- 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're parsing a declaration list (global or + // persistent). + bool looking_at_decl_list; + // TRUE means we are looking at the initializer expression for a // parameter list element. bool looking_at_initializer_expression; diff --git a/src/lex.l b/src/lex.l --- a/src/lex.l +++ b/src/lex.l @@ -2768,6 +2768,7 @@ if (is_command_name (tok) && ! is_variable (tok)) { if (next_tok_is_eq + || lexer_flags.looking_at_decl_list || lexer_flags.looking_at_return_list || (lexer_flags.looking_at_parameter_list && ! lexer_flags.looking_at_initializer_expression)) @@ -2841,9 +2842,10 @@ // Not initiallly looking at a function handle. looking_at_function_handle = 0; - // Not parsing a function return or parameter list. + // Not parsing a function return, parameter, or declaration list. looking_at_return_list = false; looking_at_parameter_list = false; + looking_at_decl_list = false; // Not looking at an argument list initializer expression. looking_at_initializer_expression = false; diff --git a/src/parse.y b/src/parse.y --- a/src/parse.y +++ b/src/parse.y @@ -929,10 +929,20 @@ // Declaration statemnts // ===================== -declaration : GLOBAL decl1 - { $$ = make_decl_command (GLOBAL, $1, $2); } - | STATIC decl1 - { $$ = make_decl_command (STATIC, $1, $2); } +parsing_decl_list + : // empty + { lexer_flags.looking_at_decl_list = true; } + +declaration : GLOBAL parsing_decl_list decl1 + { + $$ = make_decl_command (GLOBAL, $1, $3); + lexer_flags.looking_at_decl_list = false; + } + | STATIC parsing_decl_list decl1 + { + $$ = make_decl_command (STATIC, $1, $3); + lexer_flags.looking_at_decl_list = false; + } ; decl1 : decl2