Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/tokenizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ std::unique_ptr<Token> Tokenizer::NextToken() {
if (tok_str.size() > 1 && tok_str[0] == '-')
tok->SetNegative();

tok->SetOriginalString(tok_str);

// If the number isn't the whole token then move back so we can then parse
// the string portion.
auto diff = size_t(final_pos - tok_str.c_str());
Expand Down
7 changes: 7 additions & 0 deletions src/tokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ class Token {
return uint64_t(std::strtoull(string_value_.c_str(), nullptr, 16));
}

/// The OriginalString is set for integer and double values to store the
/// unparsed number which we can return in error messages.
void SetOriginalString(const std::string& orig_string) {
string_value_ = orig_string;
}
std::string ToOriginalString() const { return string_value_; }

private:
TokenType type_;
std::string string_value_;
Expand Down
Loading