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::RecordBuilder(a) => Expr::RecordBuilder(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::Tag(a) => Expr::Tag(a),
Expr::OpaqueRef(a) => Expr::OpaqueRef(a),

View file

@ -289,6 +289,7 @@ pub enum Expr<'a> {
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`
ident: &'a str,
suffixed: u8, // how many `!` suffixes, for example `doTheThing!!` executes a Task that returns a Task
},
Underscore(&'a str),
@ -1395,11 +1396,13 @@ impl<'a> Expr<'a> {
pub const REPL_OPAQUE_FUNCTION: Self = Expr::Var {
module_name: "",
ident: "<function>",
suffixed: 0,
};
pub const REPL_RUNTIME_CRASH: Self = Expr::Var {
module_name: "",
ident: "*",
suffixed: 0,
};
pub fn loc_ref(&'a self, region: Region) -> Loc<&'a Self> {

View file

@ -42,7 +42,7 @@ pub enum Ident<'a> {
Access {
module_name: &'a str,
parts: &'a [Accessor<'a>],
suffixed: bool,
suffixed: u8,
},
/// `.foo { foo: 42 }` or `.1 (1, 2, 3)`
AccessorFunction(Accessor<'a>),
@ -192,7 +192,7 @@ pub fn parse_ident<'a>(
match chomp_identifier_chain(arena, state.bytes(), state.pos()) {
Ok((width, ident)) => {
let state = advance_state!(state, width as usize)?;
let mut state = advance_state!(state, width as usize)?;
if let Ident::Access {
module_name, parts, ..
} = 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 {
module_name,
parts,
suffixed: true,
suffixed,
};
return Ok((MadeProgress, new_ident, state.advance(1)));
}
return Ok((MadeProgress, new_ident, state));
}
Ok((MadeProgress, ident, state))
@ -534,7 +533,7 @@ fn chomp_identifier_chain<'a>(
let ident = Ident::Access {
module_name,
parts: parts.into_bump_slice(),
suffixed: false,
suffixed: 0,
};
Ok((chomped as u32, ident))
@ -570,7 +569,7 @@ fn chomp_identifier_chain<'a>(
let ident = Ident::Access {
module_name: "",
parts: arena.alloc([Accessor::RecordField(value)]),
suffixed: false,
suffixed: 0,
};
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();
// Return early with the suffixed statement
if let Pattern::Stmt(_) = pattern.value {
if let Pattern::BangSuffixed(_,_) = pattern.value {
return Ok((MadeProgress, pattern, pattern_state));
}
@ -397,14 +397,14 @@ fn loc_ident_pattern_help<'a>(
parts,
suffixed,
..
} if suffixed => {
} if suffixed > 0 => {
if module_name.is_empty() && parts.len() == 1 {
if let Accessor::RecordField(var) = &parts[0] {
return Ok((
MadeProgress,
Loc {
region: loc_ident.region,
value: Pattern::Stmt(var),
value: Pattern::BangSuffixed(var, suffixed),
},
state,
));
@ -416,7 +416,7 @@ fn loc_ident_pattern_help<'a>(
MadeProgress,
Loc {
region: loc_ident.region,
value: Pattern::Stmt(arena.alloc(format!("{}.{}", module_name, var))),
value: Pattern::BangSuffixed(arena.alloc(format!("{}.{}", module_name, var)), suffixed),
},
state,
));

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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