Literal
Literal::clone () const
{
- return {this->kind, this->text.clone (), this->has_suffix,
- this->suffix.clone ()};
+ return {this->kind, this->text.clone (), this->suffix.clone ()};
}
Literal
{
auto ffi_text = FFIString::make_ffistring (text);
auto ffi_suffix = FFIString::make_ffistring (suffix);
- return {kind, ffi_text, suffix != "", ffi_suffix};
+ return {kind, ffi_text, ffi_suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "u8" : "");
- return {LitKind::make_integer (), text, suffixed, suffix};
+ return {LitKind::make_integer (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "u16" : "");
- return {LitKind::make_integer (), text, suffixed, suffix};
+ return {LitKind::make_integer (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "u32" : "");
- return {LitKind::make_integer (), text, suffixed, suffix};
+ return {LitKind::make_integer (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "u64" : "");
- return {LitKind::make_integer (), text, suffixed, suffix};
+ return {LitKind::make_integer (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "i8" : "");
- return {LitKind::make_integer (), text, suffixed, suffix};
+ return {LitKind::make_integer (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "i16" : "");
- return {LitKind::make_integer (), text, suffixed, suffix};
+ return {LitKind::make_integer (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "i32" : "");
- return {LitKind::make_integer (), text, suffixed, suffix};
+ return {LitKind::make_integer (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "i64" : "");
- return {LitKind::make_integer (), text, suffixed, suffix};
+ return {LitKind::make_integer (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (str);
auto suffix = FFIString::make_ffistring ("");
- return {LitKind::make_str (), text, false, suffix};
+ return {LitKind::make_str (), text, suffix};
}
Literal
auto text
= FFIString::make_ffistring (std::string (vec.cbegin (), vec.cend ()));
auto suffix = FFIString::make_ffistring ("");
- return {LitKind::make_byte_str (), text, false, suffix};
+ return {LitKind::make_byte_str (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "f32" : "");
- return {LitKind::make_float (), text, suffixed, suffix};
+ return {LitKind::make_float (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "f64" : "");
- return {LitKind::make_float (), text, suffixed, suffix};
+ return {LitKind::make_float (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string ((char) ch));
auto suffix = FFIString::make_ffistring ("");
- return {LitKind::make_char (), text, false, suffix};
+ return {LitKind::make_char (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "usize" : "");
- return {LitKind::make_integer (), text, suffixed, suffix};
+ return {LitKind::make_integer (), text, suffix};
}
Literal
{
auto text = FFIString::make_ffistring (std::to_string (value));
auto suffix = FFIString::make_ffistring (suffixed ? "isize" : "");
- return {LitKind::make_integer (), text, suffixed, suffix};
+ return {LitKind::make_integer (), text, suffix};
}
LitKind
pub struct Literal {
kind: LitKind,
text: FFIString,
- has_suffix: bool,
suffix: FFIString,
// FIXME: Add span, cannot add whilst Span remain an empty type
}
Literal {
kind : LitKind::Integer,
text: FFIString::new(&n.to_string()),
- has_suffix : true,
suffix: FFIString::new(stringify!($kind))
}
}
Literal {
kind : LitKind::Integer,
text: FFIString::new(&n.to_string()),
- has_suffix : false,
suffix: FFIString::new("")
}
}
Literal {
kind: LitKind::Float,
text: FFIString::new(&repr),
- has_suffix: false,
suffix: FFIString::new(""),
}
}
Literal {
kind: LitKind::Float,
text: FFIString::new(&n.to_string()),
- has_suffix: true,
suffix: FFIString::new("f32"),
}
}
Literal {
kind: LitKind::Float,
text: FFIString::new(&repr),
- has_suffix: false,
suffix: FFIString::new(""),
}
}
Literal {
kind: LitKind::Float,
text: FFIString::new(&n.to_string()),
- has_suffix: true,
suffix: FFIString::new("f64"),
}
}
Literal {
kind: LitKind::Str,
text: FFIString::new(string),
- has_suffix: false,
suffix: FFIString::new(""),
}
}
Literal {
kind: LitKind::Char,
text: FFIString::new(&c.to_string()),
- has_suffix: false,
suffix: FFIString::new(""),
}
}
Literal {
kind: LitKind::ByteStr,
text: FFIString::new(&bytes.escape_ascii().to_string()),
- has_suffix: false,
suffix: FFIString::new(""),
}
}
_ => f.write_str(text)?,
}
- if self.has_suffix {
- f.write_str(&self.suffix.to_string())?;
- }
+ f.write_str(&self.suffix.to_string())?;
Ok(())
}
}
let mut lit = Literal {
kind: LitKind::Err,
text: FFIString::new(""),
- has_suffix: false,
suffix: FFIString::new(""),
};
// TODO: We might want to pass a LexError by reference to retrieve