Auto merge of #14837 - Veykril:rustc-lexer, r=Veykril

Support c string literals
This commit is contained in:
bors 2023-05-18 11:55:38 +00:00
commit 9ce95674e8
24 changed files with 374 additions and 155 deletions

View file

@ -85,6 +85,7 @@ impl fmt::Display for FloatTypeWrapper {
pub enum Literal {
String(Box<str>),
ByteString(Box<[u8]>),
CString(Box<str>),
Char(char),
Bool(bool),
Int(i128, Option<BuiltinInt>),
@ -135,6 +136,10 @@ impl From<ast::LiteralKind> for Literal {
let text = s.value().map(Box::from).unwrap_or_else(Default::default);
Literal::String(text)
}
LiteralKind::CString(s) => {
let text = s.value().map(Box::from).unwrap_or_else(Default::default);
Literal::CString(text)
}
LiteralKind::Byte(b) => {
Literal::Uint(b.value().unwrap_or_default() as u128, Some(BuiltinUint::U8))
}