mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Get things compiling
This commit is contained in:
parent
70bef827a7
commit
f35e43768a
18 changed files with 541 additions and 253 deletions
|
@ -84,6 +84,26 @@ pub struct WhenPattern<'a> {
|
|||
pub guard: Option<Loc<Expr<'a>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum StrSegment<'a> {
|
||||
Plaintext(&'a str), // e.g. "foo"
|
||||
Unicode(Loc<&'a str>), // e.g. "00A0" in "\u(00A0)"
|
||||
EscapedChar(char), // e.g. '\n' in "Hello!\n"
|
||||
Interpolated {
|
||||
// e.g. "App.version" in "Version: \(App.version)"
|
||||
module_name: &'a str,
|
||||
ident: &'a str,
|
||||
region: Region,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum StrLiteral<'a> {
|
||||
PlainLine(&'a str),
|
||||
LineWithEscapes(&'a [StrSegment<'a>]),
|
||||
Block(&'a [&'a [StrSegment<'a>]]),
|
||||
}
|
||||
|
||||
/// A parsed expression. This uses lifetimes extensively for two reasons:
|
||||
///
|
||||
/// 1. It uses Bump::alloc for all allocations, which returns a reference.
|
||||
|
@ -105,8 +125,7 @@ pub enum Expr<'a> {
|
|||
},
|
||||
|
||||
// String Literals
|
||||
Str(&'a str),
|
||||
BlockStr(&'a [&'a str]),
|
||||
Str(StrLiteral<'a>), // string without escapes in it
|
||||
/// Look up exactly one field on a record, e.g. (expr).foo.
|
||||
Access(&'a Expr<'a>, &'a str),
|
||||
/// e.g. `.foo`
|
||||
|
@ -336,8 +355,7 @@ pub enum Pattern<'a> {
|
|||
is_negative: bool,
|
||||
},
|
||||
FloatLiteral(&'a str),
|
||||
StrLiteral(&'a str),
|
||||
BlockStrLiteral(&'a [&'a str]),
|
||||
StrLiteral(StrLiteral<'a>),
|
||||
Underscore,
|
||||
|
||||
// Space
|
||||
|
@ -455,7 +473,6 @@ impl<'a> Pattern<'a> {
|
|||
) => string_x == string_y && base_x == base_y && is_negative_x == is_negative_y,
|
||||
(FloatLiteral(x), FloatLiteral(y)) => x == y,
|
||||
(StrLiteral(x), StrLiteral(y)) => x == y,
|
||||
(BlockStrLiteral(x), BlockStrLiteral(y)) => x == y,
|
||||
(Underscore, Underscore) => true,
|
||||
|
||||
// Space
|
||||
|
@ -584,7 +601,7 @@ impl<'a> Spaceable<'a> for Def<'a> {
|
|||
pub enum Attempting {
|
||||
List,
|
||||
Keyword,
|
||||
StringLiteral,
|
||||
StrLiteral,
|
||||
RecordLiteral,
|
||||
RecordFieldLabel,
|
||||
InterpolatedString,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue