Mercurial > octave
diff libinterp/parse-tree/lex.ll @ 28582:dc8de424fc72
use octave_value object to store numeric tokens in the lexer
* lex.ll (base_lexer::handle_number): Use octave_value object to store
numeric values.
(base_lexer::display_token): Use octave_value::print_raw to display
value of numeric tokens.
* oct-parse.yy (NUM, IMAG_NUM): Replace with single NUMBER token ID.
Change all uses.
* token.h, token.cc (tok_info::m_num): Use octave_value object instead
of double to store numeric values. Update all uses.
(token::number): Return octave_value instead of double. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 16 Jul 2020 16:02:45 -0400 |
parents | 0ecec070c086 |
children | 96e7dc4c2214 |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll Wed Jul 15 10:31:37 2020 -0400 +++ b/libinterp/parse-tree/lex.ll Thu Jul 16 16:02:45 2020 -0400 @@ -2861,8 +2861,9 @@ case magic_line_kw: { int l = m_tok_beg.line (); - tok_val = new token (magic_line_kw, static_cast<double> (l), - "", m_tok_beg, m_tok_end); + octave_value ov_value (static_cast<double> (l)); + tok_val = new token (magic_line_kw, ov_value, "", + m_tok_beg, m_tok_end); } break; @@ -2996,9 +2997,12 @@ update_token_positions (flex_yyleng ()); - push_token (new token (NUM, value, yytxt, m_tok_beg, m_tok_end)); - - return count_token_internal (imag ? IMAG_NUM : NUM); + octave_value ov_value + = imag ? octave_value (Complex (0.0, value)) : octave_value (value); + + push_token (new token (NUMBER, ov_value, yytxt, m_tok_beg, m_tok_end)); + + return count_token_internal (NUMBER); } void @@ -3427,12 +3431,13 @@ case POW: std::cerr << "POW\n"; break; case EPOW: std::cerr << "EPOW\n"; break; - case NUM: - case IMAG_NUM: + case NUMBER: { token *tok_val = current_token (); - std::cerr << (tok == NUM ? "NUM" : "IMAG_NUM") - << " [" << tok_val->number () << "]\n"; + std::cerr << "NUMBER ["; + octave_value num = tok_val->number (); + num.print_raw (std::cerr); + std::cerr << "]\n"; } break;