Mercurial > octave
diff libinterp/parse-tree/oct-parse.yy @ 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 | 605b9e811bf3 |
children | f0414ee0fefe |
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.yy Wed Jul 15 10:31:37 2020 -0400 +++ b/libinterp/parse-tree/oct-parse.yy Thu Jul 16 16:02:45 2020 -0400 @@ -199,7 +199,7 @@ %token <tok_val> LEFTDIV EMUL EDIV ELEFTDIV EPLUS EMINUS %token <tok_val> HERMITIAN TRANSPOSE %token <tok_val> PLUS_PLUS MINUS_MINUS POW EPOW -%token <tok_val> NUM IMAG_NUM +%token <tok_val> NUMBER %token <tok_val> STRUCT_ELT %token <tok_val> NAME %token <tok_val> END @@ -541,10 +541,8 @@ { $$ = parser.make_constant (SQ_STRING, $1); } ; -constant : NUM - { $$ = parser.make_constant (NUM, $1); } - | IMAG_NUM - { $$ = parser.make_constant (IMAG_NUM, $1); } +constant : NUMBER + { $$ = parser.make_constant (NUMBER, $1); } | string { $$ = $1; } ; @@ -2583,18 +2581,9 @@ switch (op) { - case NUM: + case NUMBER: { - octave_value tmp (tok_val->number ()); - retval = new tree_constant (tmp, l, c); - retval->stash_original_text (tok_val->text_rep ()); - } - break; - - case IMAG_NUM: - { - octave_value tmp (Complex (0.0, tok_val->number ())); - retval = new tree_constant (tmp, l, c); + retval = new tree_constant (tok_val->number (), l, c); retval->stash_original_text (tok_val->text_rep ()); } break;