Remove multiline string literals from ast
This commit is contained in:
parent
ea7518b183
commit
867595b5b9
1 changed files with 25 additions and 15 deletions
|
|
@ -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,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue