diff options
| Commit | 6e19bb560d474736d45f5be011ff0830c7019991 (patch) | |
|---|---|---|
| Author | 2018-11-05 23:34:00 +0200 | |
| Committer | 2018-11-05 23:34:00 +0200 | |
| Files | 42d29cf1c4e6a535ba526f434debaac3a70df2c6 /src/asm/token.cpp | |
| IPL-6e19bb560d474736d45f5be011ff0830c7019991.tar IPL-6e19bb560d474736d45f5be011ff0830c7019991.tar.gz IPL-6e19bb560d474736d45f5be011ff0830c7019991.zip | ||
Squashed 'spasm/' content from commit 08ee95d
git-subtree-dir: spasm
git-subtree-split: 08ee95d89054ba0d33697d613799a0a013aedf89
1 files changed, 65 insertions, 0 deletions
| -rw-r--r-- | src/asm/token.cpp | 65 |
diff --git a/src/asm/token.cpp b/src/asm/token.cpp new file mode 100644 index 0000000..6c88bef --- /dev/null +++ b/src/asm/token.cpp @@ -0,0 +1,65 @@ +#include <memory> +#include <new> +#include <queue> +#include <string> + +#include "token.hpp" + +namespace SpasmImpl +{ +namespace ASM +{ +namespace Lexer +{ +Token::Token(Token_type type) + : _type(type), _lineno(0), _value_int(0), _value_str("") +{ +} + +Token::Token(Token::Token_type type, + size_t lineno, + const char* start, + const char* end) + : _type(type), _lineno(lineno) +{ + if (_type == integer || _type == xinteger) + { + _value_int = strtol(start, NULL, 0); + } + else if (_type == ident) + { + if (end) + { + _value_str = std::string(start, end); + } + else + { + _value_str = std::string(start); + } + } +} + +Token::Token_type Token::type() const +{ + return _type; +} + +int Token::value_int() const +{ + return _value_int; +} + +const std::string& Token::value_str() const +{ + return _value_str; +} + +size_t Token::lineno() const +{ + return _lineno; +} + +} // namespace Lexer + +} // namespace ASM +} // namespace SpasmImpl |
