diff options
1 files changed, 23 insertions, 10 deletions
| -rw-r--r-- | spasm/src/asm/token.cpp | 33 |
diff --git a/spasm/src/asm/token.cpp b/spasm/src/asm/token.cpp index 4f298cf..fa612e3 100644 --- a/spasm/src/asm/token.cpp +++ b/spasm/src/asm/token.cpp @@ -22,20 +22,33 @@ Token::Token(Token::Token_type type, const char* end) : _type(type), _lineno(lineno) { - if (_type == Integer || _type == XInteger) + switch (_type) { - _value_int = strtol(start, NULL, 0); - } - else if (_type == Ident) - { - if (end) + case Integer: + case XInteger: + { + _value_int = strtol(start, NULL, 0); + break; + } + case FloatingPoint: { - _value_str = std::string(start, end); + _value_double = strtod(start, NULL); + break; } - else + case Ident: { - _value_str = std::string(start); + if (end) + { + _value_str = std::string(start, end); + } + else + { + _value_str = std::string(start); + } + break; } + default: + break; } } @@ -44,7 +57,7 @@ Token::Token_type Token::type() const return _type; } -int Token::value_int() const +int64_t Token::value_int() const { return _value_int; } |
