Mercurial > octave
changeset 33120:b8919be4c931
return token instead of token ID from make_keyword_token
* lex.h, lex.ll (base_lexer::make_keyword_token): Return token object
insted of token ID. Don't push token on token stack.
(handle_identifier): Push keyword token on token stack here.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 02 Mar 2024 15:00:54 -0500 |
parents | f83d0ab96c16 |
children | ee1868ed6aa1 |
files | libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll |
diffstat | 2 files changed, 16 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h Sat Mar 02 14:27:30 2024 -0500 +++ b/libinterp/parse-tree/lex.h Sat Mar 02 15:00:54 2024 -0500 @@ -647,7 +647,7 @@ bool inside_any_object_index (); - int make_keyword_token (const std::string& s); + token * make_keyword_token (const std::string& s); bool fq_identifier_contains_keyword (const std::string& s);
--- a/libinterp/parse-tree/lex.ll Sat Mar 02 14:27:30 2024 -0500 +++ b/libinterp/parse-tree/lex.ll Sat Mar 02 15:00:54 2024 -0500 @@ -2621,7 +2621,7 @@ return retval; } - int + token * base_lexer::make_keyword_token (const std::string& s) { // Token positions should have already been updated before this @@ -2632,7 +2632,7 @@ const octave_kw *kw = octave_kw_hash::in_word_set (s.c_str (), slen); if (! kw) - return 0; + return nullptr; bool previous_at_bos = m_at_beginning_of_statement; @@ -2670,7 +2670,7 @@ || m_parsed_function_name.top ()))) { m_at_beginning_of_statement = previous_at_bos; - return 0; + return nullptr; } tok = new token (kw->tok_id, token::simple_end, m_tok_beg, m_tok_end); @@ -2719,7 +2719,7 @@ case endarguments_kw: #if defined (DISABLE_ARGUMENTS_VALIDATION_BLOCK) - return 0; + return nullptr; #else tok = new token (kw->tok_id, token::arguments_end, m_tok_beg, m_tok_end); m_at_beginning_of_statement = true; @@ -2778,7 +2778,7 @@ if (! m_maybe_classdef_get_set_method) { m_at_beginning_of_statement = previous_at_bos; - return 0; + return nullptr; } break; @@ -2791,7 +2791,7 @@ if (! m_classdef_element_names_are_keywords) { m_at_beginning_of_statement = previous_at_bos; - return 0; + return nullptr; } // fall through ... @@ -2838,10 +2838,10 @@ case arguments_kw: #if defined (DISABLE_ARGUMENTS_VALIDATION_BLOCK) - return 0; + return nullptr; #else if (! m_arguments_is_keyword) - return 0; + return nullptr; break; #endif @@ -2880,9 +2880,7 @@ if (! tok) tok = new token (kw->tok_id, true, m_tok_beg, m_tok_end); - push_token (tok); - - return kw->tok_id; + return tok; } /* @@ -3509,21 +3507,23 @@ // m_at_beginning_of_statement. For example, if tok is an IF // token, then m_at_beginning_of_statement will be false. - int kw_token = make_keyword_token (ident); + token *tok = make_keyword_token (ident); // If we have a regular keyword, return it. // Keywords can be followed by identifiers. - if (kw_token) + if (tok) { m_looking_for_object_index = false; // The call to make_keyword_token set m_at_beginning_of_statement. - return count_token_internal (kw_token); + push_token (tok); + + return count_token_internal (tok->token_id ()); } - token *tok = new token (NAME, ident, m_tok_beg, m_tok_end); + tok = new token (NAME, ident, m_tok_beg, m_tok_end); // For compatibility with Matlab, the following symbols are // handled specially so that things like