Mercurial > octave
diff libinterp/parse-tree/token.h @ 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 | 6e8a9845d118 |
children | 7854d5752dd2 |
line wrap: on
line diff
--- a/libinterp/parse-tree/token.h Wed Jul 15 10:31:37 2020 -0400 +++ b/libinterp/parse-tree/token.h Thu Jul 16 16:02:45 2020 -0400 @@ -31,6 +31,7 @@ #include <string> #include "filepos.h" +#include "ov.h" #include "symrec.h" namespace octave @@ -44,7 +45,7 @@ generic_token, keyword_token, string_token, - double_token, + numeric_token, ettype_token, sym_rec_token, scls_name_token, @@ -80,8 +81,8 @@ token (int tv, const std::string& s, const filepos& beg_pos, const filepos& end_pos); - token (int tv, double d, const std::string& s, const filepos& beg_pos, - const filepos& end_pos); + token (int tv, const octave_value& val, const std::string& s, + const filepos& beg_pos, const filepos& end_pos); token (int tv, end_tok_type t, const filepos& beg_pos, const filepos& end_pos); @@ -131,7 +132,7 @@ std::string text (void) const; std::string symbol_name (void) const; - double number (void) const; + octave_value number (void) const; token_type ttype (void) const; end_tok_type ettype (void) const; symbol_record sym_rec (void) const; @@ -162,7 +163,7 @@ tok_info (const std::string& str) : m_str (new std::string (str)) { } - tok_info (double num) : m_num (num) { } + tok_info (const octave_value& num) : m_num (new octave_value (num)) { } tok_info (end_tok_type et) : m_et (et) { } @@ -182,7 +183,7 @@ std::string *m_str; - double m_num; + octave_value *m_num; end_tok_type m_et;