Remove multiline string literals from ast

This commit is contained in:
Joscha 2022-11-20 17:14:38 +01:00
parent ea7518b183
commit 867595b5b9

View file

@ -54,26 +54,36 @@ impl HasSpan for NumLit {
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum StringLit { pub enum StringLitElem {
/// - `"Hello world\n"` /// Normal unescaped characters
/// - `""` Plain(String),
Inline(String, Span), /// `\u{xxxx}`
Unicode(char),
/// `\\`
Backslash,
/// `\'`
SingleQuote,
/// `\"'`
DoubleQuote,
/// `\t`
Tab,
/// `\r`
CarriageReturn,
/// `\n`
Newline,
}
/// ```text /// - `"Hello world\n"`
/// """ /// - `""`
/// Hello, #[derive(Debug, Clone)]
/// world! pub struct StringLit {
/// """ elems: Vec<StringLitElem>,
/// ``` span: Span,
Multiline(String, Span),
} }
impl HasSpan for StringLit { impl HasSpan for StringLit {
fn span(&self) -> Span { fn span(&self) -> Span {
match self { self.span
StringLit::Inline(_, span) => *span,
StringLit::Multiline(_, span) => *span,
}
} }
} }