mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Be more lenient with required indentation in collections
... and also remove a bunch of now-dead errors that can't be triggered.
This commit is contained in:
parent
9171799c67
commit
0da50a612d
22 changed files with 333 additions and 516 deletions
|
@ -293,7 +293,8 @@ impl<'a> Formattable for TypedIdent<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn fmt_package_name<'buf>(buf: &mut Buf<'buf>, name: PackageName, _indent: u16) {
|
||||
fn fmt_package_name<'buf>(buf: &mut Buf<'buf>, name: PackageName, indent: u16) {
|
||||
buf.indent(indent);
|
||||
buf.push('"');
|
||||
buf.push_str_allow_spaces(name.to_str());
|
||||
buf.push('"');
|
||||
|
|
|
@ -592,16 +592,19 @@ fn parse_problem() {
|
|||
"
|
||||
── UNFINISHED LIST ──────────────────────────────────── tmp/parse_problem/Main ─
|
||||
|
||||
I cannot find the end of this list:
|
||||
I am partway through started parsing a list, but I got stuck here:
|
||||
|
||||
3│ main = [
|
||||
^
|
||||
4│
|
||||
5│
|
||||
^
|
||||
|
||||
You could change it to something like [1, 2, 3] or even just [].
|
||||
Anything where there is an open and a close square bracket, and where
|
||||
the elements of the list are separated by commas.
|
||||
I was expecting to see a closing square bracket before this, so try
|
||||
adding a ] and see if that helps?
|
||||
|
||||
Note: I may be confused by indentation"
|
||||
Note: When I get stuck like this, it usually means that there is a
|
||||
missing parenthesis or bracket somewhere earlier. It could also be a
|
||||
stray keyword or operator."
|
||||
)
|
||||
),
|
||||
Ok(_) => unreachable!("we expect failure here"),
|
||||
|
|
|
@ -67,6 +67,24 @@ where
|
|||
)
|
||||
}
|
||||
|
||||
pub fn spaces_before_optional_after<'a, P, S, E>(parser: P) -> impl Parser<'a, Loc<S>, E>
|
||||
where
|
||||
S: 'a + Spaceable<'a>,
|
||||
P: 'a + Parser<'a, Loc<S>, E>,
|
||||
E: 'a + SpaceProblem,
|
||||
{
|
||||
parser::map_with_arena(
|
||||
and(
|
||||
spaces(),
|
||||
and(
|
||||
parser,
|
||||
one_of![backtrackable(spaces()), succeed!(&[] as &[_]),],
|
||||
),
|
||||
),
|
||||
spaces_around_help,
|
||||
)
|
||||
}
|
||||
|
||||
fn spaces_around_help<'a, S>(
|
||||
arena: &'a Bump,
|
||||
tuples: (
|
||||
|
@ -102,6 +120,26 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn spaces_before<'a, P, S, E>(parser: P) -> impl Parser<'a, Loc<S>, E>
|
||||
where
|
||||
S: 'a + Spaceable<'a>,
|
||||
P: 'a + Parser<'a, Loc<S>, E>,
|
||||
E: 'a + SpaceProblem,
|
||||
{
|
||||
parser::map_with_arena(
|
||||
and!(spaces(), parser),
|
||||
|arena: &'a Bump, (space_list, loc_expr): (&'a [CommentOrNewline<'a>], Loc<S>)| {
|
||||
if space_list.is_empty() {
|
||||
loc_expr
|
||||
} else {
|
||||
arena
|
||||
.alloc(loc_expr.value)
|
||||
.with_spaces_before(space_list, loc_expr.region)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn space0_before_e<'a, P, S, E>(
|
||||
parser: P,
|
||||
indent_problem: fn(Position) -> E,
|
||||
|
@ -331,7 +369,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
fn spaces<'a, E>() -> impl Parser<'a, &'a [CommentOrNewline<'a>], E>
|
||||
pub fn spaces<'a, E>() -> impl Parser<'a, &'a [CommentOrNewline<'a>], E>
|
||||
where
|
||||
E: 'a + SpaceProblem,
|
||||
{
|
||||
|
|
|
@ -81,7 +81,6 @@ fn loc_expr_in_parens_help<'a>() -> impl Parser<'a, Loc<Expr<'a>>, EInParens<'a>
|
|||
specialize_ref(EInParens::Expr, loc_expr(false)),
|
||||
word1(b',', EInParens::End),
|
||||
word1(b')', EInParens::End),
|
||||
EInParens::IndentEnd,
|
||||
Expr::SpaceBefore
|
||||
)),
|
||||
move |arena, state, _, loc_elements| {
|
||||
|
@ -2459,7 +2458,6 @@ fn list_literal_help<'a>() -> impl Parser<'a, Expr<'a>, EList<'a>> {
|
|||
specialize_ref(EList::Expr, loc_expr(false)),
|
||||
word1(b',', EList::End),
|
||||
word1(b']', EList::End),
|
||||
EList::IndentEnd,
|
||||
Expr::SpaceBefore
|
||||
),
|
||||
|arena, elements: Collection<'a, _>| {
|
||||
|
|
|
@ -239,7 +239,6 @@ fn provides_to<'a>() -> impl Parser<'a, ProvidesTo<'a>, EProvides<'a>> {
|
|||
exposes_entry(EProvides::Identifier),
|
||||
word1(b',', EProvides::ListEnd),
|
||||
word1(b']', EProvides::ListEnd),
|
||||
EProvides::IndentListEnd,
|
||||
Spaced::SpaceBefore
|
||||
),
|
||||
types: optional(backtrackable(provides_types())),
|
||||
|
@ -271,7 +270,6 @@ fn provides_exposed<'a>() -> impl Parser<
|
|||
exposes_entry(EProvides::Identifier),
|
||||
word1(b',', EProvides::ListEnd),
|
||||
word1(b']', EProvides::ListEnd),
|
||||
EProvides::IndentListEnd,
|
||||
Spaced::SpaceBefore
|
||||
),
|
||||
})
|
||||
|
@ -297,7 +295,6 @@ fn provides_types<'a>(
|
|||
provides_type_entry(EProvides::Identifier),
|
||||
word1(b',', EProvides::ListEnd),
|
||||
word1(b'}', EProvides::ListEnd),
|
||||
EProvides::IndentListEnd,
|
||||
Spaced::SpaceBefore
|
||||
)
|
||||
)
|
||||
|
@ -364,7 +361,6 @@ fn requires_rigids<'a>(
|
|||
),
|
||||
word1(b',', ERequires::ListEnd),
|
||||
word1(b'}', ERequires::ListEnd),
|
||||
ERequires::IndentListEnd,
|
||||
Spaced::SpaceBefore
|
||||
)
|
||||
}
|
||||
|
@ -402,7 +398,6 @@ fn exposes_values<'a>() -> impl Parser<
|
|||
exposes_entry(EExposes::Identifier),
|
||||
word1(b',', EExposes::ListEnd),
|
||||
word1(b']', EExposes::ListEnd),
|
||||
EExposes::IndentListEnd,
|
||||
Spaced::SpaceBefore
|
||||
)
|
||||
})
|
||||
|
@ -453,7 +448,6 @@ fn exposes_modules<'a>() -> impl Parser<
|
|||
exposes_module(EExposes::Identifier),
|
||||
word1(b',', EExposes::ListEnd),
|
||||
word1(b']', EExposes::ListEnd),
|
||||
EExposes::IndentListEnd,
|
||||
Spaced::SpaceBefore
|
||||
),
|
||||
})
|
||||
|
@ -491,7 +485,6 @@ fn packages<'a>() -> impl Parser<
|
|||
specialize(EPackages::PackageEntry, loc!(package_entry())),
|
||||
word1(b',', EPackages::ListEnd),
|
||||
word1(b'}', EPackages::ListEnd),
|
||||
EPackages::IndentListEnd,
|
||||
Spaced::SpaceBefore
|
||||
)
|
||||
})
|
||||
|
@ -529,7 +522,6 @@ fn generates_with<'a>() -> impl Parser<
|
|||
exposes_entry(EGeneratesWith::Identifier),
|
||||
word1(b',', EGeneratesWith::ListEnd),
|
||||
word1(b']', EGeneratesWith::ListEnd),
|
||||
EGeneratesWith::IndentListEnd,
|
||||
Spaced::SpaceBefore
|
||||
)
|
||||
})
|
||||
|
@ -553,7 +545,6 @@ fn imports<'a>() -> impl Parser<
|
|||
loc!(imports_entry()),
|
||||
word1(b',', EImports::ListEnd),
|
||||
word1(b']', EImports::ListEnd),
|
||||
EImports::IndentListEnd,
|
||||
Spaced::SpaceBefore
|
||||
)
|
||||
})
|
||||
|
@ -634,7 +625,6 @@ fn imports_entry<'a>() -> impl Parser<'a, Spaced<'a, ImportsEntry<'a>>, EImports
|
|||
exposes_entry(EImports::Identifier),
|
||||
word1(b',', EImports::SetEnd),
|
||||
word1(b'}', EImports::SetEnd),
|
||||
EImports::IndentSetEnd,
|
||||
Spaced::SpaceBefore
|
||||
)
|
||||
))
|
||||
|
|
|
@ -142,7 +142,6 @@ pub enum EProvides<'a> {
|
|||
IndentProvides(Position),
|
||||
IndentTo(Position),
|
||||
IndentListStart(Position),
|
||||
IndentListEnd(Position),
|
||||
IndentPackage(Position),
|
||||
ListStart(Position),
|
||||
ListEnd(Position),
|
||||
|
@ -157,7 +156,6 @@ pub enum EExposes {
|
|||
Open(Position),
|
||||
IndentExposes(Position),
|
||||
IndentListStart(Position),
|
||||
IndentListEnd(Position),
|
||||
ListStart(Position),
|
||||
ListEnd(Position),
|
||||
Identifier(Position),
|
||||
|
@ -170,7 +168,6 @@ pub enum ERequires<'a> {
|
|||
Open(Position),
|
||||
IndentRequires(Position),
|
||||
IndentListStart(Position),
|
||||
IndentListEnd(Position),
|
||||
ListStart(Position),
|
||||
ListEnd(Position),
|
||||
TypedIdent(ETypedIdent<'a>, Position),
|
||||
|
@ -234,7 +231,6 @@ pub enum EImports {
|
|||
ModuleName(Position),
|
||||
Space(BadInputError, Position),
|
||||
IndentSetStart(Position),
|
||||
IndentSetEnd(Position),
|
||||
SetStart(Position),
|
||||
SetEnd(Position),
|
||||
}
|
||||
|
@ -457,9 +453,6 @@ pub enum EInParens<'a> {
|
|||
|
||||
///
|
||||
Space(BadInputError, Position),
|
||||
///
|
||||
IndentOpen(Position),
|
||||
IndentEnd(Position),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -484,9 +477,6 @@ pub enum EList<'a> {
|
|||
Space(BadInputError, Position),
|
||||
|
||||
Expr(&'a EExpr<'a>, Position),
|
||||
|
||||
IndentOpen(Position),
|
||||
IndentEnd(Position),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -585,11 +575,6 @@ pub enum PRecord<'a> {
|
|||
Expr(&'a EExpr<'a>, Position),
|
||||
|
||||
Space(BadInputError, Position),
|
||||
|
||||
IndentOpen(Position),
|
||||
IndentColon(Position),
|
||||
IndentOptional(Position),
|
||||
IndentEnd(Position),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -601,9 +586,6 @@ pub enum PList<'a> {
|
|||
Pattern(&'a EPattern<'a>, Position),
|
||||
|
||||
Space(BadInputError, Position),
|
||||
|
||||
IndentOpen(Position),
|
||||
IndentEnd(Position),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -614,8 +596,6 @@ pub enum PInParens<'a> {
|
|||
Pattern(&'a EPattern<'a>, Position),
|
||||
|
||||
Space(BadInputError, Position),
|
||||
IndentOpen(Position),
|
||||
IndentEnd(Position),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -670,9 +650,6 @@ pub enum ETypeTagUnion<'a> {
|
|||
Type(&'a EType<'a>, Position),
|
||||
|
||||
Space(BadInputError, Position),
|
||||
|
||||
IndentOpen(Position),
|
||||
IndentEnd(Position),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -1318,29 +1295,20 @@ macro_rules! collection {
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! collection_trailing_sep_e {
|
||||
($opening_brace:expr, $elem:expr, $delimiter:expr, $closing_brace:expr, $indent_problem:expr, $space_before:expr) => {
|
||||
($opening_brace:expr, $elem:expr, $delimiter:expr, $closing_brace:expr, $space_before:expr) => {
|
||||
map_with_arena!(
|
||||
skip_first!(
|
||||
$opening_brace,
|
||||
and!(
|
||||
$crate::parser::reset_min_indent(and!(
|
||||
and!(
|
||||
space0_e($indent_problem),
|
||||
$crate::blankspace::spaces(),
|
||||
$crate::parser::trailing_sep_by0(
|
||||
$delimiter,
|
||||
$crate::blankspace::space0_before_optional_after(
|
||||
$elem,
|
||||
$indent_problem,
|
||||
$indent_problem
|
||||
)
|
||||
$crate::blankspace::spaces_before_optional_after($elem,)
|
||||
)
|
||||
),
|
||||
skip_second!(
|
||||
$crate::parser::reset_min_indent($crate::blankspace::space0_e(
|
||||
$indent_problem
|
||||
)),
|
||||
$closing_brace
|
||||
)
|
||||
)
|
||||
skip_second!($crate::blankspace::spaces(), $closing_brace)
|
||||
))
|
||||
),
|
||||
|arena: &'a bumpalo::Bump,
|
||||
((spaces, mut parsed_elems), mut final_comments): (
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::ast::{Has, Pattern, PatternAs, Spaceable};
|
||||
use crate::blankspace::{space0_before_e, space0_e};
|
||||
use crate::blankspace::{space0_e, spaces, spaces_before};
|
||||
use crate::ident::{lowercase_ident, parse_ident, Ident};
|
||||
use crate::keyword;
|
||||
use crate::parser::Progress::{self, *};
|
||||
|
@ -190,7 +190,6 @@ fn loc_pattern_in_parens_help<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, PInPare
|
|||
specialize_ref(PInParens::Pattern, loc_pattern_help()),
|
||||
word1(b',', PInParens::End),
|
||||
word1(b')', PInParens::End),
|
||||
PInParens::IndentOpen,
|
||||
Pattern::SpaceBefore
|
||||
)),
|
||||
move |_arena, state, _, loc_elements| {
|
||||
|
@ -263,7 +262,6 @@ fn list_pattern_help<'a>() -> impl Parser<'a, Pattern<'a>, PList<'a>> {
|
|||
list_element_pattern(),
|
||||
word1(b',', PList::End),
|
||||
word1(b']', PList::End),
|
||||
PList::IndentEnd,
|
||||
Pattern::SpaceBefore
|
||||
),
|
||||
Pattern::List
|
||||
|
@ -459,7 +457,6 @@ fn record_pattern_help<'a>() -> impl Parser<'a, Pattern<'a>, PRecord<'a>> {
|
|||
record_pattern_field(),
|
||||
word1(b',', PRecord::End),
|
||||
word1(b'}', PRecord::End),
|
||||
PRecord::IndentEnd,
|
||||
Pattern::SpaceBefore
|
||||
),
|
||||
Pattern::RecordDestructure
|
||||
|
@ -480,7 +477,7 @@ fn record_pattern_field<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, PRecord<'a>>
|
|||
.parse(arena, state, min_indent)?;
|
||||
debug_assert_eq!(progress, MadeProgress);
|
||||
|
||||
let (_, spaces, state) = space0_e(PRecord::IndentEnd).parse(arena, state, min_indent)?;
|
||||
let (_, spaces, state) = spaces().parse(arena, state, min_indent)?;
|
||||
|
||||
// Having a value is optional; both `{ email }` and `{ email: blah }` work.
|
||||
// (This is true in both literals and types.)
|
||||
|
@ -493,8 +490,8 @@ fn record_pattern_field<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, PRecord<'a>>
|
|||
match opt_loc_val {
|
||||
Some(First(_)) => {
|
||||
let val_parser = specialize_ref(PRecord::Pattern, loc_pattern_help());
|
||||
let (_, loc_val, state) = space0_before_e(val_parser, PRecord::IndentColon)
|
||||
.parse(arena, state, min_indent)?;
|
||||
let (_, loc_val, state) =
|
||||
spaces_before(val_parser).parse(arena, state, min_indent)?;
|
||||
|
||||
let Loc {
|
||||
value: label,
|
||||
|
@ -520,8 +517,8 @@ fn record_pattern_field<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, PRecord<'a>>
|
|||
Some(Second(_)) => {
|
||||
let val_parser = specialize_ref(PRecord::Expr, crate::expr::loc_expr(false));
|
||||
|
||||
let (_, loc_val, state) = space0_before_e(val_parser, PRecord::IndentColon)
|
||||
.parse(arena, state, min_indent)?;
|
||||
let (_, loc_val, state) =
|
||||
spaces_before(val_parser).parse(arena, state, min_indent)?;
|
||||
|
||||
let Loc {
|
||||
value: label,
|
||||
|
|
|
@ -43,7 +43,6 @@ fn tag_union_type<'a>(
|
|||
loc!(tag_type(false)),
|
||||
word1(b',', ETypeTagUnion::End),
|
||||
word1(b']', ETypeTagUnion::End),
|
||||
ETypeTagUnion::IndentEnd,
|
||||
Tag::SpaceBefore
|
||||
)
|
||||
.parse(arena, state, min_indent)?;
|
||||
|
@ -236,7 +235,6 @@ fn loc_type_in_parens<'a>(
|
|||
specialize_ref(ETypeInParens::Type, expression(true, false)),
|
||||
word1(b',', ETypeInParens::End),
|
||||
word1(b')', ETypeInParens::End),
|
||||
ETypeInParens::IndentEnd,
|
||||
TypeAnnotation::SpaceBefore
|
||||
),
|
||||
optional(allocated(specialize_ref(
|
||||
|
@ -376,7 +374,6 @@ fn record_type<'a>(
|
|||
loc!(record_type_field()),
|
||||
word1(b',', ETypeRecord::End),
|
||||
word1(b'}', ETypeRecord::End),
|
||||
ETypeRecord::IndentEnd,
|
||||
AssignedField::SpaceBefore
|
||||
),
|
||||
ext: optional(allocated(specialize_ref(
|
||||
|
@ -522,7 +519,6 @@ pub fn has_abilities<'a>() -> impl Parser<'a, Loc<HasAbilities<'a>>, EType<'a>>
|
|||
loc!(parse_has_ability()),
|
||||
word1(b',', EType::TEnd),
|
||||
word1(b']', EType::TEnd),
|
||||
EType::TIndentEnd,
|
||||
HasAbility::SpaceBefore
|
||||
),
|
||||
HasAbilities::Has
|
||||
|
@ -544,7 +540,6 @@ fn parse_has_ability<'a>() -> impl Parser<'a, HasAbility<'a>, EType<'a>> {
|
|||
specialize(|e: ERecord<'_>, _| e.into(), loc!(record_value_field())),
|
||||
word1(b',', ETypeAbilityImpl::End),
|
||||
word1(b'}', ETypeAbilityImpl::End),
|
||||
ETypeAbilityImpl::IndentEnd,
|
||||
AssignedField::SpaceBefore
|
||||
)
|
||||
),
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Expr(When(Pattern(List(End(@22), @15), @15), @0), @0)
|
|
@ -1 +1 @@
|
|||
Expr(Type(TRecord(IndentEnd(@5), @4), @4), @0)
|
||||
Expr(Type(TRecord(End(@16), @4), @4), @0)
|
|
@ -20,17 +20,17 @@ Defs(
|
|||
"my_list",
|
||||
),
|
||||
@10-26 List(
|
||||
Collection {
|
||||
items: [
|
||||
@16-17 SpaceBefore(
|
||||
Num(
|
||||
"0",
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
[
|
||||
@16-17 SpaceBefore(
|
||||
Num(
|
||||
"0",
|
||||
),
|
||||
@23-24 SpaceBefore(
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
@23-24 SpaceBefore(
|
||||
SpaceAfter(
|
||||
Num(
|
||||
"1",
|
||||
),
|
||||
|
@ -38,11 +38,11 @@ Defs(
|
|||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
final_comments: [
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
when [] is
|
||||
[1, 2, 3] -> ""
|
|
@ -0,0 +1,40 @@
|
|||
When(
|
||||
@5-7 List(
|
||||
[],
|
||||
),
|
||||
[
|
||||
WhenBranch {
|
||||
patterns: [
|
||||
@15-24 SpaceBefore(
|
||||
List(
|
||||
[
|
||||
@16-17 NumLiteral(
|
||||
"1",
|
||||
),
|
||||
@19-20 NumLiteral(
|
||||
"2",
|
||||
),
|
||||
@22-23 SpaceBefore(
|
||||
NumLiteral(
|
||||
"3",
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
value: @28-30 Str(
|
||||
PlainLine(
|
||||
"",
|
||||
),
|
||||
),
|
||||
guard: None,
|
||||
},
|
||||
],
|
||||
)
|
|
@ -0,0 +1,10 @@
|
|||
app "hello"
|
||||
packages {
|
||||
pf:
|
||||
"https://github.com/roc-lang/basic-cli/releases/download/0.1.3/5SXwdW7rH8QAOnD71IkHcFxCmBEPtFSLAIkclPEgjHQ.tar.br",
|
||||
}
|
||||
imports [pf.Stdout]
|
||||
provides [main] to pf
|
||||
|
||||
main =
|
||||
Stdout.line "I'm a Roc application!"
|
|
@ -0,0 +1,128 @@
|
|||
Full {
|
||||
header: Module {
|
||||
comments: [],
|
||||
header: App(
|
||||
AppHeader {
|
||||
before_name: [],
|
||||
name: @4-11 PlainLine(
|
||||
"hello",
|
||||
),
|
||||
packages: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: PackagesKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@27-145 SpaceAfter(
|
||||
PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [
|
||||
Newline,
|
||||
],
|
||||
package_name: @31-145 PackageName(
|
||||
"https://github.com/roc-lang/basic-cli/releases/download/0.1.3/5SXwdW7rH8QAOnD71IkHcFxCmBEPtFSLAIkclPEgjHQ.tar.br",
|
||||
),
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
imports: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ImportsKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@161-170 Package(
|
||||
"pf",
|
||||
ModuleName(
|
||||
"Stdout",
|
||||
),
|
||||
[],
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
provides: ProvidesTo {
|
||||
provides_keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ProvidesKeyword,
|
||||
after: [],
|
||||
},
|
||||
entries: [
|
||||
@186-190 ExposedName(
|
||||
"main",
|
||||
),
|
||||
],
|
||||
types: None,
|
||||
to_keyword: Spaces {
|
||||
before: [],
|
||||
item: ToKeyword,
|
||||
after: [],
|
||||
},
|
||||
to: @195-197 ExistingPackage(
|
||||
"pf",
|
||||
),
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
module_defs: Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@199-246,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 2),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 2, length = 0),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
Newline,
|
||||
],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@199-203 Identifier(
|
||||
"main",
|
||||
),
|
||||
@210-246 SpaceBefore(
|
||||
Apply(
|
||||
@210-221 Var {
|
||||
module_name: "Stdout",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@222-246 Str(
|
||||
PlainLine(
|
||||
"I'm a Roc application!",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
},
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
app "hello"
|
||||
packages { pf:
|
||||
"https://github.com/roc-lang/basic-cli/releases/download/0.1.3/5SXwdW7rH8QAOnD71IkHcFxCmBEPtFSLAIkclPEgjHQ.tar.br"
|
||||
}
|
||||
imports [pf.Stdout]
|
||||
provides [main] to pf
|
||||
|
||||
main =
|
||||
Stdout.line "I'm a Roc application!"
|
|
@ -33,9 +33,9 @@ Defs(
|
|||
},
|
||||
[
|
||||
@13-28 Record(
|
||||
Collection {
|
||||
items: [
|
||||
@17-26 SpaceBefore(
|
||||
[
|
||||
@17-26 SpaceBefore(
|
||||
SpaceAfter(
|
||||
RequiredValue(
|
||||
@17-20 "bar",
|
||||
[],
|
||||
|
@ -48,11 +48,11 @@ Defs(
|
|||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
final_comments: [
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
Space,
|
||||
|
|
|
@ -20,27 +20,27 @@ Defs(
|
|||
"a",
|
||||
),
|
||||
@4-17 List(
|
||||
Collection {
|
||||
items: [
|
||||
@8-9 SpaceBefore(
|
||||
Num(
|
||||
"1",
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
[
|
||||
@8-9 SpaceBefore(
|
||||
Num(
|
||||
"1",
|
||||
),
|
||||
@11-12 Num(
|
||||
"2",
|
||||
),
|
||||
@14-15 Num(
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
@11-12 Num(
|
||||
"2",
|
||||
),
|
||||
@14-15 SpaceAfter(
|
||||
Num(
|
||||
"3",
|
||||
),
|
||||
],
|
||||
final_comments: [
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -189,20 +189,19 @@ mod test_snapshots {
|
|||
fail/lambda_missing_indent.expr,
|
||||
fail/list_double_comma.expr,
|
||||
fail/list_pattern_not_terminated.expr,
|
||||
fail/list_pattern_weird_indent.expr,
|
||||
fail/list_pattern_weird_rest_pattern.expr,
|
||||
fail/list_without_end.expr,
|
||||
fail/multi_no_end.expr,
|
||||
fail/pattern_binds_keyword.expr,
|
||||
fail/pattern_in_parens_end.expr,
|
||||
fail/pattern_in_parens_end_comma.expr,
|
||||
fail/pattern_in_parens_end.expr,
|
||||
fail/pattern_in_parens_indent_open.expr,
|
||||
fail/pattern_in_parens_open.expr,
|
||||
fail/record_type_end.expr,
|
||||
fail/record_type_keyword_field_name.expr,
|
||||
fail/record_type_missing_comma.expr,
|
||||
fail/record_type_open.expr,
|
||||
fail/record_type_open_indent.expr,
|
||||
fail/record_type_open.expr,
|
||||
fail/record_type_tab.expr,
|
||||
fail/single_no_end.expr,
|
||||
fail/tab_crash.header,
|
||||
|
@ -271,13 +270,13 @@ mod test_snapshots {
|
|||
pass/empty_platform_header.header,
|
||||
pass/empty_record.expr,
|
||||
pass/empty_string.expr,
|
||||
pass/equals.expr,
|
||||
pass/equals_with_spaces.expr,
|
||||
pass/expect.expr,
|
||||
pass/equals.expr,
|
||||
pass/expect_fx.moduledefs,
|
||||
pass/expect.expr,
|
||||
pass/float_with_underscores.expr,
|
||||
pass/full_app_header.header,
|
||||
pass/full_app_header_trailing_commas.header,
|
||||
pass/full_app_header.header,
|
||||
pass/function_effect_types.header,
|
||||
pass/function_with_tuple_ext_type.expr,
|
||||
pass/function_with_tuple_type.expr,
|
||||
|
@ -291,6 +290,7 @@ mod test_snapshots {
|
|||
pass/list_closing_indent_not_enough.expr,
|
||||
pass/list_closing_same_indent_no_trailing_comma.expr,
|
||||
pass/list_closing_same_indent_with_trailing_comma.expr,
|
||||
pass/list_pattern_weird_indent.expr,
|
||||
pass/list_patterns.expr,
|
||||
pass/lowest_float.expr,
|
||||
pass/lowest_int.expr,
|
||||
|
@ -305,8 +305,8 @@ mod test_snapshots {
|
|||
pass/multi_char_string.expr,
|
||||
pass/multiline_string.expr,
|
||||
pass/multiline_tuple_with_comments.expr,
|
||||
pass/multiline_type_signature.expr,
|
||||
pass/multiline_type_signature_with_comment.expr,
|
||||
pass/multiline_type_signature.expr,
|
||||
pass/multiple_fields.expr,
|
||||
pass/multiple_operators.expr,
|
||||
pass/neg_inf_float.expr,
|
||||
|
@ -321,6 +321,7 @@ mod test_snapshots {
|
|||
pass/newline_and_spaces_before_less_than.expr,
|
||||
pass/newline_before_add.expr,
|
||||
pass/newline_before_sub.expr,
|
||||
pass/newline_in_packages.full,
|
||||
pass/newline_in_type_def.expr,
|
||||
pass/newline_inside_empty_list.expr,
|
||||
pass/newline_singleton_list.expr,
|
||||
|
@ -337,10 +338,10 @@ mod test_snapshots {
|
|||
pass/one_spaced_def.expr,
|
||||
pass/opaque_destructure_first_item_in_body.expr,
|
||||
pass/opaque_has_abilities.expr,
|
||||
pass/opaque_reference_expr.expr,
|
||||
pass/opaque_reference_expr_with_arguments.expr,
|
||||
pass/opaque_reference_pattern.expr,
|
||||
pass/opaque_reference_expr.expr,
|
||||
pass/opaque_reference_pattern_with_arguments.expr,
|
||||
pass/opaque_reference_pattern.expr,
|
||||
pass/opaque_simple.moduledefs,
|
||||
pass/opaque_with_type_arguments.moduledefs,
|
||||
pass/ops_with_newlines.expr,
|
||||
|
@ -388,8 +389,8 @@ mod test_snapshots {
|
|||
pass/three_arg_closure.expr,
|
||||
pass/tuple_access_after_record.expr,
|
||||
pass/tuple_accessor_function.expr,
|
||||
pass/tuple_type.expr,
|
||||
pass/tuple_type_ext.expr,
|
||||
pass/tuple_type.expr,
|
||||
pass/two_arg_closure.expr,
|
||||
pass/two_backpassing.expr,
|
||||
pass/two_branch_when.expr,
|
||||
|
@ -397,12 +398,12 @@ mod test_snapshots {
|
|||
pass/type_decl_with_underscore.expr,
|
||||
pass/type_signature_def.expr,
|
||||
pass/type_signature_function_def.expr,
|
||||
pass/unary_negation.expr,
|
||||
pass/unary_negation_access.expr, // Regression test for https://github.com/roc-lang/roc/issues/509
|
||||
pass/unary_negation_arg.expr,
|
||||
pass/unary_negation_with_parens.expr,
|
||||
pass/unary_not.expr,
|
||||
pass/unary_negation.expr,
|
||||
pass/unary_not_with_parens.expr,
|
||||
pass/unary_not.expr,
|
||||
pass/underscore_backpassing.expr,
|
||||
pass/underscore_in_assignment_pattern.expr,
|
||||
pass/var_else.expr,
|
||||
|
@ -413,10 +414,10 @@ mod test_snapshots {
|
|||
pass/var_when.expr,
|
||||
pass/when_if_guard.expr,
|
||||
pass/when_in_assignment.expr,
|
||||
pass/when_in_function.expr,
|
||||
pass/when_in_function_python_style_indent.expr,
|
||||
pass/when_in_parens.expr,
|
||||
pass/when_in_function.expr,
|
||||
pass/when_in_parens_indented.expr,
|
||||
pass/when_in_parens.expr,
|
||||
pass/when_with_alternative_patterns.expr,
|
||||
pass/when_with_function_application.expr,
|
||||
pass/when_with_negative_numbers.expr,
|
||||
|
@ -426,8 +427,8 @@ mod test_snapshots {
|
|||
pass/when_with_tuples.expr,
|
||||
pass/where_clause_function.expr,
|
||||
pass/where_clause_multiple_bound_abilities.expr,
|
||||
pass/where_clause_multiple_has.expr,
|
||||
pass/where_clause_multiple_has_across_newlines.expr,
|
||||
pass/where_clause_multiple_has.expr,
|
||||
pass/where_clause_non_function.expr,
|
||||
pass/where_clause_on_newline.expr,
|
||||
pass/zero_float.expr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue