diff options
| Commit | 4fca8e8e6c1056aed11437c87e9175232b48c8f4 (patch) | |
|---|---|---|
| Author | 2018-11-22 16:04:22 +0200 | |
| Committer | 2018-11-22 16:04:22 +0200 | |
| Files | bda85506ae253afd73d3ab36d3685b4e5bae3847 /spasm/src/asm/token.cpp | |
| IPL-4fca8e8e6c1056aed11437c87e9175232b48c8f4.tar IPL-4fca8e8e6c1056aed11437c87e9175232b48c8f4.tar.gz IPL-4fca8e8e6c1056aed11437c87e9175232b48c8f4.zip | ||
| Parent | 75faff8b35b8f9bfa0a00b973e9323c1dc4c614e (diff) | |
| Parent | ddc50fe944df0a33386a3213c8021f07ac8ffdd9 (diff) | |
Merge pull request #62 from SofiaCPP/feature/double
Feature/double
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; } |
