# HG changeset patch # User John W. Eaton # Date 1371694306 14400 # Node ID 0bf1d559b3214eb77f55bf383c836583e2714517 # Parent dd7ab7df2f29d8a4487c9b00bb296693b842ba08 always set at_beginning_of_statement when recognizing keywords (bug #38758) * lex.ll (octave_base_lexer::is_keyword_token): Always set at_beginning_of_statement if a keyword is recognized. 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 @@ -1899,6 +1899,9 @@ if (kw) { + // May be reset to true for some token types. + at_beginning_of_statement = false; + token *tok_val = 0; switch (kw->kw_id) @@ -2589,21 +2592,17 @@ current_input_column += flex_yyleng (); + assert (! at_beginning_of_statement); + return STRUCT_ELT; } - // The is_keyword_token may reset - // at_beginning_of_statement. For example, if it sees - // an else token, then the next token is at the beginning of a - // statement. - - // May set at_beginning_of_statement to true. + // If tok is a keyword token, then is_keyword_token will set + // at_beginning_of_statement. For example, if tok is and IF + // token, then at_beginning_of_statement will be false. + int kw_token = is_keyword_token (tok); - // If we found a keyword token, then the beginning_of_statement flag - // is already set. Otherwise, we won't be at the beginning of a - // statement. - if (looking_at_function_handle) { if (kw_token) @@ -2637,6 +2636,8 @@ looking_for_object_index = false; } + // The call to is_keyword_token set at_beginning_of_statement. + return kw_token; }