Add a new representation for tokens which should reflect the string
token as it could be found in the original source.
gcc/rust/ChangeLog:
* lex/rust-token.cc (Token::as_string): Add as_string
implementation.
* lex/rust-token.h: Add as_string prototype.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
}
return *str;
}
+
+std::string
+Token::as_string () const
+{
+ if (should_have_str ())
+ {
+ return get_str ();
+ }
+ else
+ {
+ return get_token_description ();
+ }
+}
} // namespace Rust
// Returns whether the token is a pure decimal int literal
bool is_pure_decimal () const { return type_hint == CORETYPE_PURE_DECIMAL; }
+
+ // Return the token representation as someone would find it in the original
+ // source code file.
+ std::string as_string () const;
};
} // namespace Rust