mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
Parse deprecated interpolation syntax differently
This commit is contained in:
parent
08ab7996a0
commit
af8e9c7292
7 changed files with 47 additions and 11 deletions
|
@ -119,10 +119,11 @@ pub struct WhenPattern<'a> {
|
|||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum StrSegment<'a> {
|
||||
Plaintext(&'a str), // e.g. "foo"
|
||||
Unicode(Loc<&'a str>), // e.g. "00A0" in "\u(00A0)"
|
||||
EscapedChar(EscapedChar), // e.g. '\n' in "Hello!\n"
|
||||
Interpolated(Loc<&'a Expr<'a>>), // e.g. (name) in "Hi, \(name)!"
|
||||
Plaintext(&'a str), // e.g. "foo"
|
||||
Unicode(Loc<&'a str>), // e.g. "00A0" in "\u(00A0)"
|
||||
EscapedChar(EscapedChar), // e.g. '\n' in "Hello!\n"
|
||||
Interpolated(Loc<&'a Expr<'a>>),
|
||||
DeprecatedInterpolated(Loc<&'a Expr<'a>>), // The old "$(...)" syntax - will be removed someday
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
|
@ -216,6 +217,7 @@ impl<'a> TryFrom<StrSegment<'a>> for SingleQuoteSegment<'a> {
|
|||
StrSegment::Unicode(s) => Ok(SingleQuoteSegment::Unicode(s)),
|
||||
StrSegment::EscapedChar(s) => Ok(SingleQuoteSegment::EscapedChar(s)),
|
||||
StrSegment::Interpolated(_) => Err(ESingleQuote::InterpolationNotAllowed),
|
||||
StrSegment::DeprecatedInterpolated(_) => Err(ESingleQuote::InterpolationNotAllowed),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1590,7 +1592,9 @@ impl<'a> Malformed for StrSegment<'a> {
|
|||
fn is_malformed(&self) -> bool {
|
||||
match self {
|
||||
StrSegment::Plaintext(_) | StrSegment::Unicode(_) | StrSegment::EscapedChar(_) => false,
|
||||
StrSegment::Interpolated(expr) => expr.is_malformed(),
|
||||
StrSegment::Interpolated(expr) | StrSegment::DeprecatedInterpolated(expr) => {
|
||||
expr.is_malformed()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue