# HG changeset patch # User John W. Eaton # Date 1361839546 18000 # Node ID 6b26e18d1dcb075d433c84212a98a051b3089c9b # Parent 4b6c44096862cda8c610134145bccfc4087396ed reorder data members in lexical_feedback class * lex.h, lex.ll (lexical_feedback): Reorder data members in class to group bool, int, and container classes. (lexical_feedback::lexical_feedback, lexical_feedback::init): Reorder initialization to match. diff --git a/libinterp/parse-tree/lex.h b/libinterp/parse-tree/lex.h --- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -61,20 +61,19 @@ public: lexical_feedback (void) - - : bracketflag (0), braceflag (0), looping (0), - convert_spaces_to_comma (true), at_beginning_of_statement (true), - defining_func (0), looking_at_function_handle (0), - looking_at_anon_fcn_args (true), - looking_at_return_list (false), looking_at_parameter_list (false), - looking_at_decl_list (false), looking_at_initializer_expression (false), - looking_at_matrix_or_assign_lhs (false), looking_at_object_index (), - looking_for_object_index (false), do_comma_insert (false), - looking_at_indirect_ref (false), parsed_function_name (), - parsing_class_method (false), maybe_classdef_get_set_method (false), - parsing_classdef (false), quote_is_transpose (false), + : convert_spaces_to_comma (true), do_comma_insert (false), + at_beginning_of_statement (true), + looking_at_anon_fcn_args (true), looking_at_return_list (false), + looking_at_parameter_list (false), looking_at_decl_list (false), + looking_at_initializer_expression (false), + looking_at_matrix_or_assign_lhs (false), + looking_for_object_index (false), + looking_at_indirect_ref (false), parsing_class_method (false), + maybe_classdef_get_set_method (false), parsing_classdef (false), + quote_is_transpose (false), bracketflag (0), braceflag (0), + looping (0), defining_func (0), looking_at_function_handle (0), + looking_at_object_index (), parsed_function_name (), pending_local_variables () - { init (); } @@ -83,29 +82,17 @@ void init (void); - // Square bracket level count. - int bracketflag; - - // Curly brace level count. - int braceflag; - - // TRUE means we're in the middle of defining a loop. - int looping; - // TRUE means that we should convert spaces to a comma inside a // matrix definition. bool convert_spaces_to_comma; + // GAG. Stupid kludge so that [[1,2][3,4]] will work. + bool do_comma_insert; + // TRUE means we are at the beginning of a statement, where a // command name is possible. bool at_beginning_of_statement; - // Nonzero means we're in the middle of defining a function. - int defining_func; - - // Nonzero means we are parsing a function handle. - int looking_at_function_handle; - // TRUE means we are parsing an anonymous function argument list. bool looking_at_anon_fcn_args; @@ -127,25 +114,13 @@ // multi-value assignment statement. bool looking_at_matrix_or_assign_lhs; - // If the front of the list is TRUE, the closest paren, brace, or - // bracket nesting is an index for an object. - std::list looking_at_object_index; - // Object index not possible until we've seen something. bool looking_for_object_index; - // GAG. Stupid kludge so that [[1,2][3,4]] will work. - bool do_comma_insert; - // TRUE means we're looking at an indirect reference to a // structure element. bool looking_at_indirect_ref; - // 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; @@ -160,6 +135,30 @@ // Return transpose or start a string? bool quote_is_transpose; + // Square bracket level count. + int bracketflag; + + // Curly brace level count. + int braceflag; + + // TRUE means we're in the middle of defining a loop. + int looping; + + // Nonzero means we're in the middle of defining a function. + int defining_func; + + // Nonzero means we are parsing a function handle. + int looking_at_function_handle; + + // If the front of the list is TRUE, the closest paren, brace, or + // bracket nesting is an index for an object. + std::list looking_at_object_index; + + // 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; + // Set of identifiers that might be local variable names. std::set pending_local_variables; diff --git a/libinterp/parse-tree/lex.ll b/libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -213,7 +213,7 @@ // TRUE means that we have encountered EOF on the input stream. bool parser_end_of_input = false; -// Flags that need to be shared between the lexer and parser. +// The state of the lexer. lexical_feedback lexer_flags; // Stack to hold tokens so that we can delete them when the parser is @@ -3401,33 +3401,16 @@ void lexical_feedback::init (void) { - // Not initially defining a matrix list. - bracketflag = 0; - - // Not initially defining a cell array list. - braceflag = 0; - - // Not initially inside a loop or if statement. - looping = 0; - - // Not initially defining a function. - defining_func = 0; - - // 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. - maybe_classdef_get_set_method = false; - parsing_classdef = false; - - // Not initiallly looking at a function handle. - looking_at_function_handle = 0; + // No need to do comma insert or convert spaces to comma at + // beginning of input. + convert_spaces_to_comma = true; + do_comma_insert = false; + + // Yes, we are at the beginning of a statement. + at_beginning_of_statement = true; // Not initiallly looking at an anonymous function argument list. - looking_at_anon_fcn_args = 0; + looking_at_anon_fcn_args = false; // Not parsing a function return, parameter, or declaration list. looking_at_return_list = false; @@ -3441,29 +3424,49 @@ // assignment statement. looking_at_matrix_or_assign_lhs = false; + // Object index not possible until we've seen something. + looking_for_object_index = false; + + // Not initially looking at indirect references. + looking_at_indirect_ref = false; + + // Not initially parsing a class method. + parsing_class_method = false; + + // Not initially defining a class with classdef. + maybe_classdef_get_set_method = false; + parsing_classdef = false; + + // Quote marks strings intially. + quote_is_transpose = false; + + // Not initially defining a matrix list. + bracketflag = 0; + + // Not initially defining a cell array list. + braceflag = 0; + + // Not initially inside a loop or if statement. + looping = 0; + + // Not initially defining a function. + defining_func = 0; + + // Not initiallly looking at a function handle. + looking_at_function_handle = 0; + // Not parsing an object index. while (! looking_at_object_index.empty ()) looking_at_object_index.pop_front (); + // Not parsing an object index. + while (! parsed_function_name.empty ()) + parsed_function_name.pop (); + + // The closest paren, brace, or bracket nesting is not an object + // index. looking_at_object_index.push_front (false); - // Object index not possible until we've seen something. - looking_for_object_index = false; - - // Yes, we are at the beginning of a statement. - at_beginning_of_statement = true; - - // No need to do comma insert or convert spaces to comma at - // beginning of input. - convert_spaces_to_comma = true; - do_comma_insert = false; - - // Not initially looking at indirect references. - looking_at_indirect_ref = false; - - // Quote marks strings intially. - quote_is_transpose = false; - // Set of identifiers that might be local variable names is empty. pending_local_variables.clear (); }