add suffixed:u8 to Expr::Var

This commit is contained in:
Luke Boswell 2024-03-26 11:38:51 +11:00
parent a418bf4fb8
commit 0a3b9c34b3
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
134 changed files with 466 additions and 107 deletions

View file

@ -692,7 +692,7 @@ impl<'a> RemoveSpaces<'a> for Expr<'a> {
Expr::Record(a) => Expr::Record(a.remove_spaces(arena)), Expr::Record(a) => Expr::Record(a.remove_spaces(arena)),
Expr::RecordBuilder(a) => Expr::RecordBuilder(a.remove_spaces(arena)), Expr::RecordBuilder(a) => Expr::RecordBuilder(a.remove_spaces(arena)),
Expr::Tuple(a) => Expr::Tuple(a.remove_spaces(arena)), Expr::Tuple(a) => Expr::Tuple(a.remove_spaces(arena)),
Expr::Var { module_name, ident } => Expr::Var { module_name, ident }, Expr::Var { module_name, ident, suffixed } => Expr::Var { module_name, ident, suffixed },
Expr::Underscore(a) => Expr::Underscore(a), Expr::Underscore(a) => Expr::Underscore(a),
Expr::Tag(a) => Expr::Tag(a), Expr::Tag(a) => Expr::Tag(a),
Expr::OpaqueRef(a) => Expr::OpaqueRef(a), Expr::OpaqueRef(a) => Expr::OpaqueRef(a),

View file

@ -289,6 +289,7 @@ pub enum Expr<'a> {
Var { Var {
module_name: &'a str, // module_name will only be filled if the original Roc code stated something like `5 + SomeModule.myVar`, module_name will be blank if it was `5 + myVar` module_name: &'a str, // module_name will only be filled if the original Roc code stated something like `5 + SomeModule.myVar`, module_name will be blank if it was `5 + myVar`
ident: &'a str, ident: &'a str,
suffixed: u8, // how many `!` suffixes, for example `doTheThing!!` executes a Task that returns a Task
}, },
Underscore(&'a str), Underscore(&'a str),
@ -1395,11 +1396,13 @@ impl<'a> Expr<'a> {
pub const REPL_OPAQUE_FUNCTION: Self = Expr::Var { pub const REPL_OPAQUE_FUNCTION: Self = Expr::Var {
module_name: "", module_name: "",
ident: "<function>", ident: "<function>",
suffixed: 0,
}; };
pub const REPL_RUNTIME_CRASH: Self = Expr::Var { pub const REPL_RUNTIME_CRASH: Self = Expr::Var {
module_name: "", module_name: "",
ident: "*", ident: "*",
suffixed: 0,
}; };
pub fn loc_ref(&'a self, region: Region) -> Loc<&'a Self> { pub fn loc_ref(&'a self, region: Region) -> Loc<&'a Self> {

View file

@ -42,7 +42,7 @@ pub enum Ident<'a> {
Access { Access {
module_name: &'a str, module_name: &'a str,
parts: &'a [Accessor<'a>], parts: &'a [Accessor<'a>],
suffixed: bool, suffixed: u8,
}, },
/// `.foo { foo: 42 }` or `.1 (1, 2, 3)` /// `.foo { foo: 42 }` or `.1 (1, 2, 3)`
AccessorFunction(Accessor<'a>), AccessorFunction(Accessor<'a>),
@ -192,7 +192,7 @@ pub fn parse_ident<'a>(
match chomp_identifier_chain(arena, state.bytes(), state.pos()) { match chomp_identifier_chain(arena, state.bytes(), state.pos()) {
Ok((width, ident)) => { Ok((width, ident)) => {
let state = advance_state!(state, width as usize)?; let mut state = advance_state!(state, width as usize)?;
if let Ident::Access { if let Ident::Access {
module_name, parts, .. module_name, parts, ..
} = ident } = ident
@ -206,21 +206,20 @@ pub fn parse_ident<'a>(
} }
} }
} }
// Parse any `!` suffixes
let mut suffixed = 0u8;
while state.bytes().starts_with(b"!") {
suffixed = suffixed.saturating_add(1);
state = state.advance(1);
} }
// Parse a suffixed `!` expression
if state.bytes().starts_with(b"!") {
if let Ident::Access {
module_name, parts, ..
} = ident
{
let new_ident = Ident::Access { let new_ident = Ident::Access {
module_name, module_name,
parts, parts,
suffixed: true, suffixed,
}; };
return Ok((MadeProgress, new_ident, state.advance(1))); return Ok((MadeProgress, new_ident, state));
}
} }
Ok((MadeProgress, ident, state)) Ok((MadeProgress, ident, state))
@ -534,7 +533,7 @@ fn chomp_identifier_chain<'a>(
let ident = Ident::Access { let ident = Ident::Access {
module_name, module_name,
parts: parts.into_bump_slice(), parts: parts.into_bump_slice(),
suffixed: false, suffixed: 0,
}; };
Ok((chomped as u32, ident)) Ok((chomped as u32, ident))
@ -570,7 +569,7 @@ fn chomp_identifier_chain<'a>(
let ident = Ident::Access { let ident = Ident::Access {
module_name: "", module_name: "",
parts: arena.alloc([Accessor::RecordField(value)]), parts: arena.alloc([Accessor::RecordField(value)]),
suffixed: false, suffixed: 0,
}; };
Ok((chomped as u32, ident)) Ok((chomped as u32, ident))
} }

View file

@ -51,7 +51,7 @@ pub fn loc_pattern_help<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, EPattern<'a>>
let pattern_state = state.clone(); let pattern_state = state.clone();
// Return early with the suffixed statement // Return early with the suffixed statement
if let Pattern::Stmt(_) = pattern.value { if let Pattern::BangSuffixed(_,_) = pattern.value {
return Ok((MadeProgress, pattern, pattern_state)); return Ok((MadeProgress, pattern, pattern_state));
} }
@ -397,14 +397,14 @@ fn loc_ident_pattern_help<'a>(
parts, parts,
suffixed, suffixed,
.. ..
} if suffixed => { } if suffixed > 0 => {
if module_name.is_empty() && parts.len() == 1 { if module_name.is_empty() && parts.len() == 1 {
if let Accessor::RecordField(var) = &parts[0] { if let Accessor::RecordField(var) = &parts[0] {
return Ok(( return Ok((
MadeProgress, MadeProgress,
Loc { Loc {
region: loc_ident.region, region: loc_ident.region,
value: Pattern::Stmt(var), value: Pattern::BangSuffixed(var, suffixed),
}, },
state, state,
)); ));
@ -416,7 +416,7 @@ fn loc_ident_pattern_help<'a>(
MadeProgress, MadeProgress,
Loc { Loc {
region: loc_ident.region, region: loc_ident.region,
value: Pattern::Stmt(arena.alloc(format!("{}.{}", module_name, var))), value: Pattern::BangSuffixed(arena.alloc(format!("{}.{}", module_name, var)), suffixed),
}, },
state, state,
)); ));

View file

@ -175,6 +175,7 @@ mod test_parse {
let expr = arena.alloc(Var { let expr = arena.alloc(Var {
module_name: "", module_name: "",
ident: "name", ident: "name",
suffixed: false,
}); });
bumpalo::vec![in arena; bumpalo::vec![in arena;
@ -191,6 +192,7 @@ mod test_parse {
let expr = arena.alloc(Var { let expr = arena.alloc(Var {
module_name: "", module_name: "",
ident: "name", ident: "name",
suffixed: false,
}); });
bumpalo::vec![in arena; bumpalo::vec![in arena;
@ -236,6 +238,7 @@ mod test_parse {
let expr = arena.alloc(Var { let expr = arena.alloc(Var {
module_name: "", module_name: "",
ident: "name", ident: "name",
suffixed: false,
}); });
bumpalo::vec![in arena; bumpalo::vec![in arena;
@ -251,11 +254,13 @@ mod test_parse {
let expr1 = arena.alloc(Var { let expr1 = arena.alloc(Var {
module_name: "", module_name: "",
ident: "name", ident: "name",
suffixed: false,
}); });
let expr2 = arena.alloc(Var { let expr2 = arena.alloc(Var {
module_name: "", module_name: "",
ident: "project", ident: "project",
suffixed: false,
}); });
bumpalo::vec![in arena; bumpalo::vec![in arena;
@ -276,11 +281,13 @@ mod test_parse {
let expr1 = arena.alloc(Var { let expr1 = arena.alloc(Var {
module_name: "", module_name: "",
ident: "name", ident: "name",
suffixed: false,
}); });
let expr2 = arena.alloc(Var { let expr2 = arena.alloc(Var {
module_name: "", module_name: "",
ident: "project", ident: "project",
suffixed: false,
}); });
bumpalo::vec![in arena; bumpalo::vec![in arena;

View file

@ -1,2 +0,0 @@
Stdout.line!
"Not the same ident, shouldn't parse as an single expr"

View file

@ -1,3 +0,0 @@
line! "Foo"
read "Bar"

View file

@ -2,6 +2,7 @@ When(
@5-6 Var { @5-6 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
[ [
WhenBranch { WhenBranch {

View file

@ -2,6 +2,7 @@ When(
@5-6 Var { @5-6 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
[ [
WhenBranch { WhenBranch {

View file

@ -4,6 +4,7 @@ BinOps(
@0-1 Var { @0-1 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
@2-3 Plus, @2-3 Plus,
), ),

View file

@ -86,6 +86,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -96,6 +96,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -78,6 +78,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -2,19 +2,23 @@ Apply(
@0-1 Var { @0-1 Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
[ [
@2-3 Var { @2-3 Var {
module_name: "", module_name: "",
ident: "b", ident: "b",
suffixed: 0,
}, },
@4-5 Var { @4-5 Var {
module_name: "", module_name: "",
ident: "c", ident: "c",
suffixed: 0,
}, },
@6-7 Var { @6-7 Var {
module_name: "", module_name: "",
ident: "d", ident: "d",
suffixed: 0,
}, },
], ],
Space, Space,

View file

@ -2,6 +2,7 @@ Apply(
@0-4 Var { @0-4 Var {
module_name: "", module_name: "",
ident: "whee", ident: "whee",
suffixed: 0,
}, },
[ [
@6-8 Num( @6-8 Num(

View file

@ -3,6 +3,7 @@ Apply(
@1-5 Var { @1-5 Var {
module_name: "", module_name: "",
ident: "whee", ident: "whee",
suffixed: 0,
}, },
@0-1 Negate, @0-1 Negate,
), ),
@ -13,6 +14,7 @@ Apply(
@10-13 Var { @10-13 Var {
module_name: "", module_name: "",
ident: "foo", ident: "foo",
suffixed: 0,
}, },
], ],
Space, Space,

View file

@ -3,6 +3,7 @@ Apply(
@1-5 Var { @1-5 Var {
module_name: "", module_name: "",
ident: "whee", ident: "whee",
suffixed: 0,
}, },
@0-1 Not, @0-1 Not,
), ),
@ -13,6 +14,7 @@ Apply(
@10-13 Var { @10-13 Var {
module_name: "", module_name: "",
ident: "foo", ident: "foo",
suffixed: 0,
}, },
], ],
Space, Space,

View file

@ -2,6 +2,7 @@ Apply(
@0-4 Var { @0-4 Var {
module_name: "", module_name: "",
ident: "whee", ident: "whee",
suffixed: 0,
}, },
[ [
@5-6 Num( @5-6 Num(

View file

@ -2,6 +2,7 @@ RecordAccess(
Var { Var {
module_name: "", module_name: "",
ident: "rec", ident: "rec",
suffixed: 0,
}, },
"field", "field",
) )

View file

@ -1,4 +1,5 @@
Var { Var {
module_name: "", module_name: "",
ident: "whee", ident: "whee",
suffixed: 0,
} }

View file

@ -3,6 +3,7 @@ Apply(
Var { Var {
module_name: "", module_name: "",
ident: "f", ident: "f",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -4,6 +4,7 @@ BinOps(
@0-1 Var { @0-1 Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
@2-4 And, @2-4 And,
), ),
@ -18,6 +19,7 @@ BinOps(
@9-10 Var { @9-10 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
), ),
[ [

View file

@ -4,6 +4,7 @@ BinOps(
@0-1 Var { @0-1 Var {
module_name: "", module_name: "",
ident: "i", ident: "i",
suffixed: 0,
}, },
@1-2 GreaterThan, @1-2 GreaterThan,
), ),
@ -19,6 +20,7 @@ BinOps(
@6-7 Var { @6-7 Var {
module_name: "", module_name: "",
ident: "s", ident: "s",
suffixed: 0,
}, },
), ),
[ [
@ -30,6 +32,7 @@ BinOps(
@9-10 Var { @9-10 Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
@8-9 Negate, @8-9 Negate,
), ),

View file

@ -30,6 +30,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "q", ident: "q",
suffixed: 0,
}, },
[ [
LineComment( LineComment(

View file

@ -3,6 +3,7 @@ ParensAround(
Var { Var {
module_name: "", module_name: "",
ident: "i", ident: "i",
suffixed: 0,
}, },
[ [
LineComment( LineComment(

View file

@ -46,6 +46,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "j", ident: "j",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -36,6 +36,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "e", ident: "e",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -98,11 +98,13 @@ Defs(
@50-53 Var { @50-53 Var {
module_name: "", module_name: "",
ident: "try", ident: "try",
suffixed: 0,
}, },
[ [
@54-57 Var { @54-57 Var {
module_name: "", module_name: "",
ident: "foo", ident: "foo",
suffixed: 0,
}, },
@59-73 ParensAround( @59-73 ParensAround(
Closure( Closure(

View file

@ -28,5 +28,6 @@ Defs(
@4-5 Var { @4-5 Var {
module_name: "", module_name: "",
ident: "i", ident: "i",
suffixed: 0,
}, },
) )

View file

@ -46,6 +46,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "str", ident: "str",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -2,6 +2,7 @@ RecordUpdate {
update: @1-2 Var { update: @1-2 Var {
module_name: "", module_name: "",
ident: "e", ident: "e",
suffixed: 0,
}, },
fields: [], fields: [],
} }

View file

@ -4,6 +4,7 @@ BinOps(
@0-1 Var { @0-1 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
@1-3 Equals, @1-3 Equals,
), ),
@ -11,5 +12,6 @@ BinOps(
@3-4 Var { @3-4 Var {
module_name: "", module_name: "",
ident: "y", ident: "y",
suffixed: 0,
}, },
) )

View file

@ -4,6 +4,7 @@ BinOps(
@0-1 Var { @0-1 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
@2-4 Equals, @2-4 Equals,
), ),
@ -11,5 +12,6 @@ BinOps(
@5-6 Var { @5-6 Var {
module_name: "", module_name: "",
ident: "y", ident: "y",
suffixed: 0,
}, },
) )

View file

@ -33,6 +33,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -123,6 +123,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "table", ident: "table",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -101,6 +101,7 @@ Defs(
@31-32 Var { @31-32 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
), ),
}, },
@ -111,6 +112,7 @@ Defs(
@34-35 Var { @34-35 Var {
module_name: "", module_name: "",
ident: "f", ident: "f",
suffixed: 0,
}, },
[ [
@36-47 Tuple( @36-47 Tuple(

View file

@ -87,6 +87,7 @@ Defs(
@33-34 Var { @33-34 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
@36-41 BinOps( @36-41 BinOps(
[ [
@ -94,6 +95,7 @@ Defs(
@36-37 Var { @36-37 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
@38-39 Plus, @38-39 Plus,
), ),
@ -113,6 +115,7 @@ Defs(
@44-45 Var { @44-45 Var {
module_name: "", module_name: "",
ident: "f", ident: "f",
suffixed: 0,
}, },
[ [
@46-48 Num( @46-48 Num(

View file

@ -18,6 +18,7 @@ BinOps(
Var { Var {
module_name: "Str", module_name: "Str",
ident: "toUtf8", ident: "toUtf8",
suffixed: 0,
}, },
[ [
Newline, Newline,
@ -31,6 +32,7 @@ BinOps(
@28-36 Var { @28-36 Var {
module_name: "List", module_name: "List",
ident: "map", ident: "map",
suffixed: 0,
}, },
[ [
@37-54 Closure( @37-54 Closure(
@ -45,6 +47,7 @@ BinOps(
@46-50 Var { @46-50 Var {
module_name: "", module_name: "",
ident: "byte", ident: "byte",
suffixed: 0,
}, },
@51-52 Plus, @51-52 Plus,
), ),
@ -67,5 +70,6 @@ BinOps(
@58-70 Var { @58-70 Var {
module_name: "List", module_name: "List",
ident: "reverse", ident: "reverse",
suffixed: 0,
}, },
) )

View file

@ -38,6 +38,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
[ [
Newline, Newline,
@ -47,6 +48,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "b", ident: "b",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -19,5 +19,6 @@ BinOps(
@6-7 Var { @6-7 Var {
module_name: "", module_name: "",
ident: "i", ident: "i",
suffixed: 0,
}, },
) )

View file

@ -50,6 +50,7 @@ Defs {
Var { Var {
module_name: "", module_name: "",
ident: "i", ident: "i",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -11,6 +11,7 @@ Backpassing(
@8-17 Var { @8-17 Var {
module_name: "List", module_name: "List",
ident: "map2", ident: "map2",
suffixed: 0,
}, },
[ [
@18-20 List( @18-20 List(
@ -29,6 +30,7 @@ Backpassing(
@25-26 Var { @25-26 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
@27-28 Plus, @27-28 Plus,
), ),
@ -36,6 +38,7 @@ Backpassing(
@29-30 Var { @29-30 Var {
module_name: "", module_name: "",
ident: "y", ident: "y",
suffixed: 0,
}, },
), ),
[ [

View file

@ -32,6 +32,7 @@ Defs {
@26-27 Var { @26-27 Var {
module_name: "", module_name: "",
ident: "f", ident: "f",
suffixed: 0,
}, },
[ [
@28-30 Record( @28-30 Record(

View file

@ -17,6 +17,7 @@ Backpassing(
@10-11 Var { @10-11 Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
@12-13 SpaceBefore( @12-13 SpaceBefore(
Tag( Tag(

View file

@ -2,6 +2,7 @@ Apply(
@0-1 Var { @0-1 Var {
module_name: "", module_name: "",
ident: "e", ident: "e",
suffixed: 0,
}, },
[ [
@1-10 Str( @1-10 Str(

View file

@ -4,6 +4,7 @@ RecordAccess(
Var { Var {
module_name: "", module_name: "",
ident: "rec", ident: "rec",
suffixed: 0,
}, },
"abc", "abc",
), ),

View file

@ -2,6 +2,7 @@ UnaryOp(
@1-4 Var { @1-4 Var {
module_name: "", module_name: "",
ident: "inf", ident: "inf",
suffixed: 0,
}, },
@0-1 Negate, @0-1 Negate,
) )

View file

@ -33,12 +33,14 @@ Defs(
@6-7 Var { @6-7 Var {
module_name: "", module_name: "",
ident: "g", ident: "g",
suffixed: 0,
}, },
@5-6 Negate, @5-6 Negate,
), ),
@8-9 Var { @8-9 Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
], ],
Space, Space,
@ -50,6 +52,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -51,6 +51,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "foo", ident: "foo",
suffixed: 0,
}, },
[ [
Newline, Newline,
@ -60,6 +61,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "bar", ident: "bar",
suffixed: 0,
}, },
[ [
Newline, Newline,
@ -73,6 +75,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "task", ident: "task",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -95,6 +95,7 @@ Defs {
@81-85 Var { @81-85 Var {
module_name: "", module_name: "",
ident: "num1", ident: "num1",
suffixed: 0,
}, },
@86-88 NotEquals, @86-88 NotEquals,
), ),
@ -102,6 +103,7 @@ Defs {
@89-93 Var { @89-93 Var {
module_name: "", module_name: "",
ident: "num2", ident: "num2",
suffixed: 0,
}, },
), ),
[ [
@ -117,6 +119,7 @@ Defs {
@99-111 Var { @99-111 Var {
module_name: "", module_name: "",
ident: "wrappedNotEq", ident: "wrappedNotEq",
suffixed: 0,
}, },
[ [
@112-113 Num( @112-113 Num(

View file

@ -4,6 +4,7 @@ If(
@3-5 Var { @3-5 Var {
module_name: "", module_name: "",
ident: "t1", ident: "t1",
suffixed: 0,
}, },
@13-14 SpaceBefore( @13-14 SpaceBefore(
SpaceAfter( SpaceAfter(
@ -23,6 +24,7 @@ If(
@23-25 Var { @23-25 Var {
module_name: "", module_name: "",
ident: "t2", ident: "t2",
suffixed: 0,
}, },
@33-34 SpaceBefore( @33-34 SpaceBefore(
SpaceAfter( SpaceAfter(

View file

@ -108,6 +108,7 @@ Full {
@210-221 Var { @210-221 Var {
module_name: "Stdout", module_name: "Stdout",
ident: "line", ident: "line",
suffixed: 0,
}, },
[ [
@222-246 Str( @222-246 Str(

View file

@ -43,6 +43,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "p", ident: "p",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -32,6 +32,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -15,6 +15,7 @@ SpaceBefore(
@30-31 Var { @30-31 Var {
module_name: "", module_name: "",
ident: "y", ident: "y",
suffixed: 0,
}, },
), ),
), ),
@ -22,6 +23,7 @@ SpaceBefore(
Var { Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -30,6 +30,7 @@ Defs(
@12-14 Var { @12-14 Var {
module_name: "", module_name: "",
ident: "id", ident: "id",
suffixed: 0,
}, },
[ [
@16-21 ParensAround( @16-21 ParensAround(
@ -56,6 +57,7 @@ Defs(
@23-25 Var { @23-25 Var {
module_name: "", module_name: "",
ident: "it", ident: "it",
suffixed: 0,
}, },
[ [
@26-28 Record( @26-28 Record(

View file

@ -6,10 +6,12 @@ Apply(
@5-6 Var { @5-6 Var {
module_name: "", module_name: "",
ident: "m", ident: "m",
suffixed: 0,
}, },
@7-8 Var { @7-8 Var {
module_name: "", module_name: "",
ident: "n", ident: "n",
suffixed: 0,
}, },
], ],
Space, Space,

View file

@ -2,6 +2,7 @@ When(
@5-6 Var { @5-6 Var {
module_name: "", module_name: "",
ident: "n", ident: "n",
suffixed: 0,
}, },
[ [
WhenBranch { WhenBranch {

View file

@ -2,6 +2,7 @@ When(
@5-6 Var { @5-6 Var {
module_name: "", module_name: "",
ident: "n", ident: "n",
suffixed: 0,
}, },
[ [
WhenBranch { WhenBranch {
@ -31,6 +32,7 @@ When(
@24-25 Var { @24-25 Var {
module_name: "", module_name: "",
ident: "n", ident: "n",
suffixed: 0,
}, },
@26-27 Plus, @26-27 Plus,
), ),
@ -38,6 +40,7 @@ When(
@28-29 Var { @28-29 Var {
module_name: "", module_name: "",
ident: "m", ident: "m",
suffixed: 0,
}, },
), ),
guard: None, guard: None,

View file

@ -50,5 +50,6 @@ Defs(
@12-14 Var { @12-14 Var {
module_name: "", module_name: "",
ident: "e0", ident: "e0",
suffixed: 0,
}, },
) )

View file

@ -23,6 +23,7 @@ Defs(
@4-7 Var { @4-7 Var {
module_name: "", module_name: "",
ident: "foo", ident: "foo",
suffixed: 0,
}, },
[ [
@9-28 ParensAround( @9-28 ParensAround(
@ -30,6 +31,7 @@ Defs(
@9-12 Var { @9-12 Var {
module_name: "", module_name: "",
ident: "baz", ident: "baz",
suffixed: 0,
}, },
[ [
@13-28 Record( @13-28 Record(
@ -42,6 +44,7 @@ Defs(
@22-26 Var { @22-26 Var {
module_name: "", module_name: "",
ident: "blah", ident: "blah",
suffixed: 0,
}, },
), ),
[ [
@ -68,6 +71,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -23,6 +23,7 @@ Defs(
@4-7 Var { @4-7 Var {
module_name: "", module_name: "",
ident: "foo", ident: "foo",
suffixed: 0,
}, },
[ [
@8-22 Record( @8-22 Record(
@ -38,6 +39,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "blah", ident: "blah",
suffixed: 0,
}, },
[ [
Newline, Newline,
@ -64,6 +66,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -49,6 +49,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -23,6 +23,7 @@ Defs(
@4-7 Var { @4-7 Var {
module_name: "", module_name: "",
ident: "foo", ident: "foo",
suffixed: 0,
}, },
[ [
@8-23 Record( @8-23 Record(
@ -35,6 +36,7 @@ Defs(
@17-21 Var { @17-21 Var {
module_name: "", module_name: "",
ident: "blah", ident: "blah",
suffixed: 0,
}, },
), ),
[ [
@ -57,6 +59,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -41,6 +41,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -44,6 +44,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -30,6 +30,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -30,6 +30,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "a", ident: "a",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -3,6 +3,7 @@ Apply(
Var { Var {
module_name: "", module_name: "",
ident: "whee", ident: "whee",
suffixed: 0,
}, },
), ),
[ [

View file

@ -3,6 +3,7 @@ RecordAccess(
Var { Var {
module_name: "", module_name: "",
ident: "rec", ident: "rec",
suffixed: 0,
}, },
), ),
"field", "field",

View file

@ -3,6 +3,7 @@ RecordAccess(
Var { Var {
module_name: "One.Two", module_name: "One.Two",
ident: "rec", ident: "rec",
suffixed: 0,
}, },
), ),
"field", "field",

View file

@ -2,5 +2,6 @@ ParensAround(
Var { Var {
module_name: "", module_name: "",
ident: "whee", ident: "whee",
suffixed: 0,
}, },
) )

View file

@ -26,6 +26,7 @@ When(
value: @24-25 Var { value: @24-25 Var {
module_name: "", module_name: "",
ident: "n", ident: "n",
suffixed: 0,
}, },
guard: None, guard: None,
}, },

View file

@ -2,6 +2,7 @@ When(
@5-11 Var { @5-11 Var {
module_name: "", module_name: "",
ident: "myList", ident: "myList",
suffixed: 0,
}, },
[ [
WhenBranch { WhenBranch {

View file

@ -13,6 +13,7 @@ When(
@17-19 Var { @17-19 Var {
module_name: "", module_name: "",
ident: "rx", ident: "rx",
suffixed: 0,
}, },
], ],
Space, Space,
@ -67,10 +68,12 @@ When(
@65-75 Var { @65-75 Var {
module_name: "Bool", module_name: "Bool",
ident: "false", ident: "false",
suffixed: 0,
}, },
@76-78 Var { @76-78 Var {
module_name: "", module_name: "",
ident: "ry", ident: "ry",
suffixed: 0,
}, },
], ],
Space, Space,

View file

@ -13,6 +13,7 @@ BinOps(
@7-16 Var { @7-16 Var {
module_name: "Bool", module_name: "Bool",
ident: "true", ident: "true",
suffixed: 0,
}, },
@22-23 Num( @22-23 Num(
"1", "1",

View file

@ -1,4 +1,5 @@
Var { Var {
module_name: "", module_name: "",
ident: "inf", ident: "inf",
suffixed: 0,
} }

View file

@ -4,6 +4,7 @@ RecordAccess(
Var { Var {
module_name: "One.Two", module_name: "One.Two",
ident: "rec", ident: "rec",
suffixed: 0,
}, },
"abc", "abc",
), ),

View file

@ -1,4 +1,5 @@
Var { Var {
module_name: "One.Two", module_name: "One.Two",
ident: "whee", ident: "whee",
suffixed: 0,
} }

View file

@ -2,6 +2,7 @@ RecordUpdate {
update: @2-13 Var { update: @2-13 Var {
module_name: "Foo.Bar", module_name: "Foo.Bar",
ident: "baz", ident: "baz",
suffixed: 0,
}, },
fields: [ fields: [
@16-20 RequiredValue( @16-20 RequiredValue(

View file

@ -9,6 +9,7 @@ Record(
@8-17 Var { @8-17 Var {
module_name: "Bool", module_name: "Bool",
ident: "true", ident: "true",
suffixed: 0,
}, },
@23-24 Num( @23-24 Num(
"1", "1",

View file

@ -100,6 +100,7 @@ Full {
@105-116 Var { @105-116 Var {
module_name: "Stdout", module_name: "Stdout",
ident: "line", ident: "line",
suffixed: 0,
}, },
[ [
@117-124 Str( @117-124 Str(

View file

@ -4,6 +4,7 @@ BinOps(
@0-1 Var { @0-1 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
@1-2 Minus, @1-2 Minus,
), ),
@ -11,5 +12,6 @@ BinOps(
@3-4 Var { @3-4 Var {
module_name: "", module_name: "",
ident: "y", ident: "y",
suffixed: 0,
}, },
) )

View file

@ -4,6 +4,7 @@ BinOps(
@0-1 Var { @0-1 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
@2-3 Minus, @2-3 Minus,
), ),

View file

@ -1,6 +1,5 @@
Suffixed(
Var { Var {
module_name: "Stdout", module_name: "Stdout",
ident: "line", ident: "line",
}, suffixed: 3,
) }

View file

@ -1 +1 @@
Stdout.line! Stdout.line!!!

View file

@ -1,6 +1,5 @@
# valid as a single line # valid as a single line
A.x! "Foo" [] A.x! "Foo" []
# valid as a multi-line, with increased ident # valid as a multi-line, with increased ident
B.y! B.y!
"Bar" "Bar"

View file

@ -9,35 +9,26 @@ Defs {
], ],
space_before: [ space_before: [
Slice(start = 0, length = 1), Slice(start = 0, length = 1),
Slice(start = 1, length = 3), Slice(start = 1, length = 0),
], ],
space_after: [ space_after: [
Slice(start = 1, length = 0), Slice(start = 1, length = 0),
Slice(start = 4, length = 0), Slice(start = 1, length = 0),
], ],
spaces: [ spaces: [
LineComment( LineComment(
" valid as a single line", " valid as a single line",
), ),
Newline,
Newline,
LineComment(
" valid as a multi-line, with increased ident",
),
], ],
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Stmt(
@25-29 RecordDestructure(
[],
),
@25-44 Apply( @25-44 Apply(
@25-29 Suffixed( @25-29 Var {
Var {
module_name: "A", module_name: "A",
ident: "x", ident: "x",
suffixed: 1,
}, },
),
[ [
@33-38 Str( @33-38 Str(
PlainLine( PlainLine(
@ -51,17 +42,14 @@ Defs {
Space, Space,
), ),
), ),
Body( Stmt(
@92-96 RecordDestructure( @92-131 SpaceBefore(
[], Apply(
), @92-96 Var {
@92-131 Apply(
@92-96 Suffixed(
Var {
module_name: "B", module_name: "B",
ident: "y", ident: "y",
suffixed: 1,
}, },
),
[ [
@106-111 SpaceBefore( @106-111 SpaceBefore(
Str( Str(
@ -86,6 +74,7 @@ Defs {
@126-127 Var { @126-127 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
@128-129 Plus, @128-129 Plus,
), ),
@ -93,6 +82,7 @@ Defs {
@130-131 Var { @130-131 Var {
module_name: "", module_name: "",
ident: "y", ident: "y",
suffixed: 0,
}, },
), ),
), ),
@ -103,6 +93,14 @@ Defs {
], ],
Space, Space,
), ),
[
Newline,
Newline,
LineComment(
" valid as a multi-line, with increased ident",
),
],
),
), ),
], ],
} }

View file

@ -1,23 +1,22 @@
Apply( Apply(
@0-4 Suffixed( @0-4 Var {
Var {
module_name: "", module_name: "",
ident: "foo", ident: "foo",
suffixed: 1,
}, },
),
[ [
@9-17 ParensAround( @9-17 ParensAround(
Apply( Apply(
@9-13 Suffixed( @9-13 Var {
Var {
module_name: "", module_name: "",
ident: "bar", ident: "bar",
suffixed: 1,
}, },
),
[ [
@14-17 Var { @14-17 Var {
module_name: "", module_name: "",
ident: "baz", ident: "baz",
suffixed: 0,
}, },
], ],
Space, Space,
@ -28,11 +27,13 @@ Apply(
@22-26 Var { @22-26 Var {
module_name: "", module_name: "",
ident: "blah", ident: "blah",
suffixed: 0,
}, },
[ [
@27-32 Var { @27-32 Var {
module_name: "", module_name: "",
ident: "stuff", ident: "stuff",
suffixed: 0,
}, },
], ],
Space, Space,

View file

@ -0,0 +1,12 @@
app ""
packages {
cli: "",
}
imports []
provides [main] to cli
main =
"jq --version"
|> Cmd.new
|> Cmd.status
|> Task.mapErr! UnableToCheckJQVersion

View file

@ -0,0 +1,165 @@
Full {
header: Module {
comments: [],
header: App(
AppHeader {
before_name: [],
name: @4-6 PlainLine(
"",
),
packages: Some(
KeywordItem {
keyword: Spaces {
before: [
Newline,
],
item: PackagesKeyword,
after: [],
},
item: Collection {
items: [
@30-37 SpaceBefore(
PackageEntry {
shorthand: "cli",
spaces_after_shorthand: [],
package_name: @35-37 PackageName(
"",
),
},
[
Newline,
],
),
],
final_comments: [
Newline,
],
},
},
),
imports: Some(
KeywordItem {
keyword: Spaces {
before: [
Newline,
],
item: ImportsKeyword,
after: [],
},
item: [],
},
),
provides: ProvidesTo {
provides_keyword: Spaces {
before: [
Newline,
],
item: ProvidesKeyword,
after: [],
},
entries: [
@74-78 ExposedName(
"main",
),
],
types: None,
to_keyword: Spaces {
before: [],
item: ToKeyword,
after: [],
},
to: @83-86 ExistingPackage(
"cli",
),
},
},
),
},
module_defs: Defs {
tags: [
Index(2147483648),
],
regions: [
@88-202,
],
space_before: [
Slice(start = 0, length = 2),
],
space_after: [
Slice(start = 2, length = 0),
],
spaces: [
Newline,
Newline,
],
type_defs: [],
value_defs: [
Body(
@88-92 Identifier(
"main",
),
@100-202 SpaceBefore(
BinOps(
[
(
@100-114 SpaceAfter(
Str(
PlainLine(
"jq --version",
),
),
[
Newline,
],
),
@123-125 Pizza,
),
(
@126-133 SpaceAfter(
Var {
module_name: "Cmd",
ident: "new",
suffixed: 0,
},
[
Newline,
],
),
@142-144 Pizza,
),
(
@145-155 SpaceAfter(
Var {
module_name: "Cmd",
ident: "status",
suffixed: 0,
},
[
Newline,
],
),
@164-166 Pizza,
),
],
@167-202 Apply(
@167-179 Var {
module_name: "Task",
ident: "mapErr",
suffixed: 1,
},
[
@180-202 Tag(
"UnableToCheckJQVersion",
),
],
Space,
),
),
[
Newline,
],
),
),
],
},
}

View file

@ -0,0 +1,12 @@
app ""
packages {
cli: "",
}
imports []
provides [main] to cli
main =
"jq --version"
|> Cmd.new
|> Cmd.status
|> Task.mapErr! UnableToCheckJQVersion

View file

@ -40,6 +40,7 @@ Defs(
Var { Var {
module_name: "", module_name: "",
ident: "abc", ident: "abc",
suffixed: 0,
}, },
"0", "0",
), ),

View file

@ -105,6 +105,7 @@ Defs(
@38-39 Var { @38-39 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
), ),
}, },
@ -115,6 +116,7 @@ Defs(
@41-42 Var { @41-42 Var {
module_name: "", module_name: "",
ident: "f", ident: "f",
suffixed: 0,
}, },
[ [
@43-49 Tuple( @43-49 Tuple(

View file

@ -121,6 +121,7 @@ Defs(
@40-41 Var { @40-41 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
), ),
}, },
@ -131,6 +132,7 @@ Defs(
@43-44 Var { @43-44 Var {
module_name: "", module_name: "",
ident: "f", ident: "f",
suffixed: 0,
}, },
[ [
@45-51 Tuple( @45-51 Tuple(

View file

@ -15,6 +15,7 @@ SpaceBefore(
@30-31 Var { @30-31 Var {
module_name: "", module_name: "",
ident: "y", ident: "y",
suffixed: 0,
}, },
), ),
), ),
@ -32,6 +33,7 @@ SpaceBefore(
Var { Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
[ [
Newline, Newline,

View file

@ -2,6 +2,7 @@ When(
@5-6 Var { @5-6 Var {
module_name: "", module_name: "",
ident: "x", ident: "x",
suffixed: 0,
}, },
[ [
WhenBranch { WhenBranch {

View file

@ -2,6 +2,7 @@ UnaryOp(
@1-4 Var { @1-4 Var {
module_name: "", module_name: "",
ident: "foo", ident: "foo",
suffixed: 0,
}, },
@0-1 Negate, @0-1 Negate,
) )

Some files were not shown because too many files have changed in this diff Show more