mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-03 06:02:54 +00:00
New app header syntax
Implements the new app header syntax as discussed in Zulip [1].
app [main] {
cli: platform "../platform/main.roc",
json: "../json/main.roc"
}
Old headers still parse and are automatically upgraded to the new
syntax by the formatter.
[1] 418444862
This commit is contained in:
parent
057a18573a
commit
8dedd9f03c
90 changed files with 1044 additions and 1056 deletions
|
|
@ -170,7 +170,9 @@ impl<'a> Input<'a> {
|
|||
.parse(arena, state.clone(), min_indent)
|
||||
.map_err(|(_, fail)| SyntaxError::Header(fail))?;
|
||||
|
||||
let module_defs = parse_module_defs(arena, state, Defs::default()).unwrap();
|
||||
let (header, defs) = header.upgrade_header_imports(arena);
|
||||
|
||||
let module_defs = parse_module_defs(arena, state, defs).unwrap();
|
||||
|
||||
Ok(Output::Full {
|
||||
header,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Header(Imports(ListEnd(@87), @65))
|
||||
Header(Exposes(ListEnd(@11), @4))
|
||||
|
|
@ -1,4 +1 @@
|
|||
app "test-missing-comma"
|
||||
packages { pf: "platform/main.roc" }
|
||||
imports [pf.Task Base64]
|
||||
provides [main, @Foo] to pf
|
||||
app [main, @Foo] { pf: platform "platform/main.roc" }
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
app "test-app" packages {} imports [] provides [] to blah
|
||||
app [] {}
|
||||
|
|
|
|||
|
|
@ -2,47 +2,12 @@ Module {
|
|||
comments: [],
|
||||
header: App(
|
||||
AppHeader {
|
||||
before_name: [],
|
||||
name: @4-14 PlainLine(
|
||||
"test-app",
|
||||
),
|
||||
packages: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [],
|
||||
item: PackagesKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [],
|
||||
},
|
||||
),
|
||||
imports: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [],
|
||||
item: ImportsKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [],
|
||||
},
|
||||
),
|
||||
provides: ProvidesTo {
|
||||
provides_keyword: Spaces {
|
||||
before: [],
|
||||
item: ProvidesKeyword,
|
||||
after: [],
|
||||
},
|
||||
entries: [],
|
||||
types: None,
|
||||
to_keyword: Spaces {
|
||||
before: [],
|
||||
item: ToKeyword,
|
||||
after: [],
|
||||
},
|
||||
to: @53-57 ExistingPackage(
|
||||
"blah",
|
||||
),
|
||||
},
|
||||
before_provides: [],
|
||||
provides: [],
|
||||
before_packages: [],
|
||||
packages: @14-26 [],
|
||||
old_imports: None,
|
||||
old_provides_to_new_package: None,
|
||||
},
|
||||
),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1 @@
|
|||
app "quicksort"
|
||||
packages { pf: "./platform" }
|
||||
imports [foo.Bar.Baz]
|
||||
provides [quicksort] to pf
|
||||
app [quicksort] { pf: platform "./platform" }
|
||||
|
|
|
|||
|
|
@ -2,73 +2,27 @@ Module {
|
|||
comments: [],
|
||||
header: App(
|
||||
AppHeader {
|
||||
before_name: [],
|
||||
name: @4-15 PlainLine(
|
||||
"quicksort",
|
||||
),
|
||||
packages: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: PackagesKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@31-47 PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [],
|
||||
package_name: @35-47 PackageName(
|
||||
"./platform",
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
imports: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ImportsKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@64-75 Package(
|
||||
"foo",
|
||||
ModuleName(
|
||||
"Bar.Baz",
|
||||
),
|
||||
[],
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
provides: ProvidesTo {
|
||||
provides_keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ProvidesKeyword,
|
||||
after: [],
|
||||
},
|
||||
entries: [
|
||||
@93-102 ExposedName(
|
||||
"quicksort",
|
||||
),
|
||||
],
|
||||
types: None,
|
||||
to_keyword: Spaces {
|
||||
before: [],
|
||||
item: ToKeyword,
|
||||
after: [],
|
||||
},
|
||||
to: @108-110 ExistingPackage(
|
||||
"pf",
|
||||
before_provides: [],
|
||||
provides: [
|
||||
@6-15 ExposedName(
|
||||
"quicksort",
|
||||
),
|
||||
},
|
||||
],
|
||||
before_packages: [],
|
||||
packages: @18-47 [
|
||||
@20-45 PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [],
|
||||
platform_marker: Some(
|
||||
[],
|
||||
),
|
||||
package_name: @33-45 PackageName(
|
||||
"./platform",
|
||||
),
|
||||
},
|
||||
],
|
||||
old_imports: None,
|
||||
old_provides_to_new_package: None,
|
||||
},
|
||||
),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1 @@
|
|||
app "quicksort"
|
||||
packages { pf: "./platform" }
|
||||
imports [ foo.Bar.Baz ]
|
||||
provides [ quicksort ] to pf
|
||||
app [ quicksort ] { pf: platform "./platform" }
|
||||
|
|
|
|||
|
|
@ -1,8 +1 @@
|
|||
app "quicksort"
|
||||
packages { pf: "./platform" }
|
||||
imports [foo.Bar.{
|
||||
Baz,
|
||||
FortyTwo,
|
||||
# I'm a happy comment
|
||||
}]
|
||||
provides [quicksort] to pf
|
||||
app [quicksort] { pf: platform "./platform" }
|
||||
|
|
|
|||
|
|
@ -2,98 +2,27 @@ Module {
|
|||
comments: [],
|
||||
header: App(
|
||||
AppHeader {
|
||||
before_name: [],
|
||||
name: @4-15 PlainLine(
|
||||
"quicksort",
|
||||
),
|
||||
packages: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: PackagesKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@31-47 PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [],
|
||||
package_name: @35-47 PackageName(
|
||||
"./platform",
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
imports: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ImportsKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@65-141 Package(
|
||||
"foo",
|
||||
ModuleName(
|
||||
"Bar",
|
||||
),
|
||||
Collection {
|
||||
items: [
|
||||
@83-86 SpaceBefore(
|
||||
ExposedName(
|
||||
"Baz",
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
@96-104 SpaceBefore(
|
||||
ExposedName(
|
||||
"FortyTwo",
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
final_comments: [
|
||||
Newline,
|
||||
LineComment(
|
||||
" I'm a happy comment",
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
provides: ProvidesTo {
|
||||
provides_keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ProvidesKeyword,
|
||||
after: [],
|
||||
},
|
||||
entries: [
|
||||
@159-168 ExposedName(
|
||||
"quicksort",
|
||||
),
|
||||
],
|
||||
types: None,
|
||||
to_keyword: Spaces {
|
||||
before: [],
|
||||
item: ToKeyword,
|
||||
after: [],
|
||||
},
|
||||
to: @175-177 ExistingPackage(
|
||||
"pf",
|
||||
before_provides: [],
|
||||
provides: [
|
||||
@6-15 ExposedName(
|
||||
"quicksort",
|
||||
),
|
||||
},
|
||||
],
|
||||
before_packages: [],
|
||||
packages: @19-49 [
|
||||
@21-46 PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [],
|
||||
platform_marker: Some(
|
||||
[],
|
||||
),
|
||||
package_name: @34-46 PackageName(
|
||||
"./platform",
|
||||
),
|
||||
},
|
||||
],
|
||||
old_imports: None,
|
||||
old_provides_to_new_package: None,
|
||||
},
|
||||
),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1 @@
|
|||
app "quicksort"
|
||||
packages { pf: "./platform", }
|
||||
imports [ foo.Bar.{
|
||||
Baz,
|
||||
FortyTwo,
|
||||
# I'm a happy comment
|
||||
} ]
|
||||
provides [ quicksort, ] to pf
|
||||
app [ quicksort, ] { pf: platform "./platform", }
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
app "test-app" provides [] to "./blah"
|
||||
app [] {}
|
||||
|
|
|
|||
|
|
@ -2,31 +2,12 @@ Module {
|
|||
comments: [],
|
||||
header: App(
|
||||
AppHeader {
|
||||
before_name: [],
|
||||
name: @4-14 PlainLine(
|
||||
"test-app",
|
||||
),
|
||||
packages: None,
|
||||
imports: None,
|
||||
provides: ProvidesTo {
|
||||
provides_keyword: Spaces {
|
||||
before: [],
|
||||
item: ProvidesKeyword,
|
||||
after: [],
|
||||
},
|
||||
entries: [],
|
||||
types: None,
|
||||
to_keyword: Spaces {
|
||||
before: [],
|
||||
item: ToKeyword,
|
||||
after: [],
|
||||
},
|
||||
to: @30-38 NewPackage(
|
||||
PackageName(
|
||||
"./blah",
|
||||
),
|
||||
),
|
||||
},
|
||||
before_provides: [],
|
||||
provides: [],
|
||||
before_packages: [],
|
||||
packages: @7-9 [],
|
||||
old_imports: None,
|
||||
old_provides_to_new_package: None,
|
||||
},
|
||||
),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
app "test-app" provides [] to "./blah"
|
||||
app [] {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
app "hello"
|
||||
packages {
|
||||
pf:
|
||||
app [main] {
|
||||
pf:
|
||||
"https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
|
||||
}
|
||||
imports [pf.Stdout]
|
||||
provides [main] to pf
|
||||
}
|
||||
|
||||
main =
|
||||
Stdout.line "I'm a Roc application!"
|
||||
|
|
|
|||
|
|
@ -3,80 +3,32 @@ Full {
|
|||
comments: [],
|
||||
header: App(
|
||||
AppHeader {
|
||||
before_name: [],
|
||||
name: @4-11 PlainLine(
|
||||
"hello",
|
||||
),
|
||||
packages: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
before_provides: [],
|
||||
provides: [
|
||||
@5-9 ExposedName(
|
||||
"main",
|
||||
),
|
||||
],
|
||||
before_packages: [],
|
||||
packages: @11-134 [
|
||||
@13-132 SpaceAfter(
|
||||
PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [
|
||||
Newline,
|
||||
],
|
||||
item: PackagesKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@27-146 SpaceAfter(
|
||||
PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [
|
||||
Newline,
|
||||
],
|
||||
package_name: @31-146 PackageName(
|
||||
"https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
|
||||
),
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
platform_marker: None,
|
||||
package_name: @17-132 PackageName(
|
||||
"https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
imports: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ImportsKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@162-171 Package(
|
||||
"pf",
|
||||
ModuleName(
|
||||
"Stdout",
|
||||
),
|
||||
[],
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
provides: ProvidesTo {
|
||||
provides_keyword: Spaces {
|
||||
before: [
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
item: ProvidesKeyword,
|
||||
after: [],
|
||||
},
|
||||
entries: [
|
||||
@187-191 ExposedName(
|
||||
"main",
|
||||
),
|
||||
],
|
||||
types: None,
|
||||
to_keyword: Spaces {
|
||||
before: [],
|
||||
item: ToKeyword,
|
||||
after: [],
|
||||
},
|
||||
to: @196-198 ExistingPackage(
|
||||
"pf",
|
||||
),
|
||||
},
|
||||
],
|
||||
old_imports: None,
|
||||
old_provides_to_new_package: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
|
|
@ -85,7 +37,7 @@ Full {
|
|||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@200-247,
|
||||
@136-183,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 2),
|
||||
|
|
@ -100,17 +52,17 @@ Full {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@200-204 Identifier {
|
||||
@136-140 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@211-247 SpaceBefore(
|
||||
@147-183 SpaceBefore(
|
||||
Apply(
|
||||
@211-222 Var {
|
||||
@147-158 Var {
|
||||
module_name: "Stdout",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@223-247 Str(
|
||||
@159-183 Str(
|
||||
PlainLine(
|
||||
"I'm a Roc application!",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
app "hello"
|
||||
packages { pf:
|
||||
app [main] { pf:
|
||||
"https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br"
|
||||
}
|
||||
imports [pf.Stdout]
|
||||
provides [main] to pf
|
||||
|
||||
main =
|
||||
Stdout.line "I'm a Roc application!"
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ Module {
|
|||
@59-71 PackageEntry {
|
||||
shorthand: "foo",
|
||||
spaces_after_shorthand: [],
|
||||
platform_marker: None,
|
||||
package_name: @64-71 PackageName(
|
||||
"./foo",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ Module {
|
|||
@87-99 PackageEntry {
|
||||
shorthand: "foo",
|
||||
spaces_after_shorthand: [],
|
||||
platform_marker: None,
|
||||
package_name: @92-99 PackageName(
|
||||
"./foo",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
app [main] {
|
||||
cli: platform "../basic-cli/platform/main.roc",
|
||||
}
|
||||
|
||||
import cli.Stdout
|
||||
|
||||
main =
|
||||
Stdout.line "hello"
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
Full {
|
||||
header: Module {
|
||||
comments: [],
|
||||
header: App(
|
||||
AppHeader {
|
||||
before_provides: [
|
||||
Newline,
|
||||
],
|
||||
provides: [
|
||||
@143-147 ExposedName(
|
||||
"main",
|
||||
),
|
||||
],
|
||||
before_packages: [
|
||||
Newline,
|
||||
],
|
||||
packages: @20-88 Collection {
|
||||
items: [
|
||||
@44-81 SpaceBefore(
|
||||
PackageEntry {
|
||||
shorthand: "cli",
|
||||
spaces_after_shorthand: [],
|
||||
platform_marker: Some(
|
||||
[],
|
||||
),
|
||||
package_name: @49-81 PackageName(
|
||||
"../basic-cli/platform/main.roc",
|
||||
),
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
final_comments: [
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
old_imports: None,
|
||||
old_provides_to_new_package: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
module_defs: Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
Index(2147483649),
|
||||
],
|
||||
regions: [
|
||||
@111-121,
|
||||
@157-187,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 3),
|
||||
Slice(start = 6, length = 2),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 3, length = 3),
|
||||
Slice(start = 8, length = 0),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
ModuleImport(
|
||||
ModuleImport {
|
||||
before_name: [],
|
||||
name: @111-121 ImportedModuleName {
|
||||
package: Some(
|
||||
"cli",
|
||||
),
|
||||
name: ModuleName(
|
||||
"Stdout",
|
||||
),
|
||||
},
|
||||
alias: None,
|
||||
exposed: None,
|
||||
},
|
||||
),
|
||||
Body(
|
||||
@157-161 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@168-187 SpaceBefore(
|
||||
Apply(
|
||||
@168-179 Var {
|
||||
module_name: "Stdout",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@180-187 Str(
|
||||
PlainLine(
|
||||
"hello",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
app "old-app-header"
|
||||
packages {
|
||||
cli: "../basic-cli/platform/main.roc",
|
||||
}
|
||||
imports [
|
||||
cli.Stdout,
|
||||
]
|
||||
provides [main] to cli
|
||||
|
||||
main =
|
||||
Stdout.line "hello"
|
||||
|
||||
|
|
@ -1,4 +1 @@
|
|||
app "test"
|
||||
packages { pf: "./platform" }
|
||||
imports [foo.Bar.Baz]
|
||||
provides [quicksort] { Flags, Model } to pf
|
||||
app [quicksort, Flags, Model] { pf: "./platform" }
|
||||
|
|
|
|||
|
|
@ -2,82 +2,31 @@ Module {
|
|||
comments: [],
|
||||
header: App(
|
||||
AppHeader {
|
||||
before_name: [],
|
||||
name: @4-10 PlainLine(
|
||||
"test",
|
||||
),
|
||||
packages: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: PackagesKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@26-42 PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [],
|
||||
package_name: @30-42 PackageName(
|
||||
"./platform",
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
imports: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ImportsKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@59-70 Package(
|
||||
"foo",
|
||||
ModuleName(
|
||||
"Bar.Baz",
|
||||
),
|
||||
[],
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
provides: ProvidesTo {
|
||||
provides_keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ProvidesKeyword,
|
||||
after: [],
|
||||
},
|
||||
entries: [
|
||||
@88-97 ExposedName(
|
||||
"quicksort",
|
||||
before_provides: [],
|
||||
provides: [
|
||||
@5-14 ExposedName(
|
||||
"quicksort",
|
||||
),
|
||||
@16-21 ExposedName(
|
||||
"Flags",
|
||||
),
|
||||
@23-28 ExposedName(
|
||||
"Model",
|
||||
),
|
||||
],
|
||||
before_packages: [],
|
||||
packages: @30-50 [
|
||||
@32-48 PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [],
|
||||
platform_marker: None,
|
||||
package_name: @36-48 PackageName(
|
||||
"./platform",
|
||||
),
|
||||
],
|
||||
types: Some(
|
||||
[
|
||||
@102-107 UppercaseIdent(
|
||||
"Flags",
|
||||
),
|
||||
@109-114 UppercaseIdent(
|
||||
"Model",
|
||||
),
|
||||
],
|
||||
),
|
||||
to_keyword: Spaces {
|
||||
before: [],
|
||||
item: ToKeyword,
|
||||
after: [],
|
||||
},
|
||||
to: @121-123 ExistingPackage(
|
||||
"pf",
|
||||
),
|
||||
},
|
||||
],
|
||||
old_imports: None,
|
||||
old_provides_to_new_package: None,
|
||||
},
|
||||
),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1 @@
|
|||
app "test"
|
||||
packages { pf: "./platform" }
|
||||
imports [ foo.Bar.Baz ]
|
||||
provides [ quicksort ] { Flags, Model, } to pf
|
||||
app [quicksort, Flags, Model] { pf: "./platform" }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
app "example"
|
||||
packages { pf: "path" }
|
||||
imports [pf.Stdout]
|
||||
provides [main] to pf
|
||||
app [main] { pf: platform "path" }
|
||||
|
||||
main = Stdout.line "Hello"
|
||||
|
|
|
|||
|
|
@ -3,73 +3,27 @@ Full {
|
|||
comments: [],
|
||||
header: App(
|
||||
AppHeader {
|
||||
before_name: [],
|
||||
name: @4-13 PlainLine(
|
||||
"example",
|
||||
),
|
||||
packages: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: PackagesKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@29-40 PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [],
|
||||
package_name: @34-40 PackageName(
|
||||
"path",
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
imports: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ImportsKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: [
|
||||
@57-66 Package(
|
||||
"pf",
|
||||
ModuleName(
|
||||
"Stdout",
|
||||
),
|
||||
[],
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
provides: ProvidesTo {
|
||||
provides_keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ProvidesKeyword,
|
||||
after: [],
|
||||
},
|
||||
entries: [
|
||||
@84-88 ExposedName(
|
||||
"main",
|
||||
),
|
||||
],
|
||||
types: None,
|
||||
to_keyword: Spaces {
|
||||
before: [],
|
||||
item: ToKeyword,
|
||||
after: [],
|
||||
},
|
||||
to: @94-96 ExistingPackage(
|
||||
"pf",
|
||||
before_provides: [],
|
||||
provides: [
|
||||
@6-10 ExposedName(
|
||||
"main",
|
||||
),
|
||||
},
|
||||
],
|
||||
before_packages: [],
|
||||
packages: @13-37 [
|
||||
@15-35 PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [],
|
||||
platform_marker: Some(
|
||||
[],
|
||||
),
|
||||
package_name: @29-35 PackageName(
|
||||
"path",
|
||||
),
|
||||
},
|
||||
],
|
||||
old_imports: None,
|
||||
old_provides_to_new_package: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
|
|
@ -78,7 +32,7 @@ Full {
|
|||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@98-124,
|
||||
@39-65,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 2),
|
||||
|
|
@ -93,16 +47,16 @@ Full {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@98-102 Identifier {
|
||||
@39-43 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@105-124 Apply(
|
||||
@105-116 Var {
|
||||
@46-65 Apply(
|
||||
@46-57 Var {
|
||||
module_name: "Stdout",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@117-124 Str(
|
||||
@58-65 Str(
|
||||
PlainLine(
|
||||
"Hello",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
app "example"
|
||||
packages { pf : "path" }
|
||||
imports [ pf.Stdout ]
|
||||
provides [ main ] to pf
|
||||
app [ main ] { pf : platform "path" }
|
||||
|
||||
main = Stdout.line "Hello"
|
||||
main = Stdout.line "Hello"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
app "desugar-bang"
|
||||
packages {
|
||||
cli: "../basic-cli/platform/main.roc",
|
||||
}
|
||||
imports [
|
||||
cli.Stdout,
|
||||
]
|
||||
provides [main] to cli
|
||||
app [main] {
|
||||
cli: "../basic-cli/platform/main.roc",
|
||||
}
|
||||
|
||||
import cli.Stdout
|
||||
|
||||
main =
|
||||
# is this a valid statement?
|
||||
|
|
|
|||
|
|
@ -3,120 +3,83 @@ Full {
|
|||
comments: [],
|
||||
header: App(
|
||||
AppHeader {
|
||||
before_name: [],
|
||||
name: @4-18 PlainLine(
|
||||
"desugar-bang",
|
||||
),
|
||||
packages: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: PackagesKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: Collection {
|
||||
items: [
|
||||
@42-79 SpaceBefore(
|
||||
PackageEntry {
|
||||
shorthand: "cli",
|
||||
spaces_after_shorthand: [],
|
||||
package_name: @47-79 PackageName(
|
||||
"../basic-cli/platform/main.roc",
|
||||
),
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
before_provides: [],
|
||||
provides: [
|
||||
@5-9 ExposedName(
|
||||
"main",
|
||||
),
|
||||
],
|
||||
before_packages: [],
|
||||
packages: @11-55 Collection {
|
||||
items: [
|
||||
@15-52 SpaceBefore(
|
||||
PackageEntry {
|
||||
shorthand: "cli",
|
||||
spaces_after_shorthand: [],
|
||||
platform_marker: None,
|
||||
package_name: @20-52 PackageName(
|
||||
"../basic-cli/platform/main.roc",
|
||||
),
|
||||
],
|
||||
final_comments: [
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
},
|
||||
),
|
||||
imports: Some(
|
||||
KeywordItem {
|
||||
keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ImportsKeyword,
|
||||
after: [],
|
||||
},
|
||||
item: Collection {
|
||||
items: [
|
||||
@109-119 SpaceBefore(
|
||||
Package(
|
||||
"cli",
|
||||
ModuleName(
|
||||
"Stdout",
|
||||
),
|
||||
[],
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
final_comments: [
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
},
|
||||
),
|
||||
provides: ProvidesTo {
|
||||
provides_keyword: Spaces {
|
||||
before: [
|
||||
Newline,
|
||||
],
|
||||
item: ProvidesKeyword,
|
||||
after: [],
|
||||
},
|
||||
entries: [
|
||||
@141-145 ExposedName(
|
||||
"main",
|
||||
),
|
||||
],
|
||||
types: None,
|
||||
to_keyword: Spaces {
|
||||
before: [],
|
||||
item: ToKeyword,
|
||||
after: [],
|
||||
},
|
||||
to: @150-153 ExistingPackage(
|
||||
"cli",
|
||||
),
|
||||
final_comments: [
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
old_imports: None,
|
||||
old_provides_to_new_package: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
module_defs: Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
Index(2147483649),
|
||||
],
|
||||
regions: [
|
||||
@155-299,
|
||||
@57-74,
|
||||
@76-220,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 2),
|
||||
Slice(start = 2, length = 2),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 2, length = 0),
|
||||
Slice(start = 4, length = 0),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
ModuleImport(
|
||||
ModuleImport {
|
||||
before_name: [],
|
||||
name: @64-74 ImportedModuleName {
|
||||
package: Some(
|
||||
"cli",
|
||||
),
|
||||
name: ModuleName(
|
||||
"Stdout",
|
||||
),
|
||||
},
|
||||
alias: None,
|
||||
exposed: None,
|
||||
},
|
||||
),
|
||||
Body(
|
||||
@155-159 Identifier {
|
||||
@76-80 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@199-299 SpaceBefore(
|
||||
@120-220 SpaceBefore(
|
||||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
|
|
@ -124,8 +87,8 @@ Full {
|
|||
Index(2147483649),
|
||||
],
|
||||
regions: [
|
||||
@199-211,
|
||||
@241-284,
|
||||
@120-132,
|
||||
@162-205,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
|
|
@ -139,18 +102,18 @@ Full {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Stmt(
|
||||
@199-211 BinOps(
|
||||
@120-132 BinOps(
|
||||
[
|
||||
(
|
||||
@199-204 Str(
|
||||
@120-125 Str(
|
||||
PlainLine(
|
||||
"Foo",
|
||||
),
|
||||
),
|
||||
@205-207 Pizza,
|
||||
@126-128 Pizza,
|
||||
),
|
||||
],
|
||||
@208-211 TaskAwaitBang(
|
||||
@129-132 TaskAwaitBang(
|
||||
Var {
|
||||
module_name: "A",
|
||||
ident: "x",
|
||||
|
|
@ -159,33 +122,33 @@ Full {
|
|||
),
|
||||
),
|
||||
Stmt(
|
||||
@241-284 SpaceBefore(
|
||||
@162-205 SpaceBefore(
|
||||
BinOps(
|
||||
[
|
||||
(
|
||||
@241-246 Str(
|
||||
@162-167 Str(
|
||||
PlainLine(
|
||||
"Bar",
|
||||
),
|
||||
),
|
||||
@247-249 Pizza,
|
||||
@168-170 Pizza,
|
||||
),
|
||||
],
|
||||
@250-284 Apply(
|
||||
@250-253 TaskAwaitBang(
|
||||
@171-205 Apply(
|
||||
@171-174 TaskAwaitBang(
|
||||
Var {
|
||||
module_name: "B",
|
||||
ident: "y",
|
||||
},
|
||||
),
|
||||
[
|
||||
@264-284 SpaceBefore(
|
||||
@185-205 SpaceBefore(
|
||||
Record(
|
||||
[
|
||||
@266-282 RequiredValue(
|
||||
@266-272 "config",
|
||||
@187-203 RequiredValue(
|
||||
@187-193 "config",
|
||||
[],
|
||||
@274-282 Str(
|
||||
@195-203 Str(
|
||||
PlainLine(
|
||||
"config",
|
||||
),
|
||||
|
|
@ -212,14 +175,14 @@ Full {
|
|||
),
|
||||
],
|
||||
},
|
||||
@290-299 SpaceBefore(
|
||||
@211-220 SpaceBefore(
|
||||
Apply(
|
||||
@290-293 Var {
|
||||
@211-214 Var {
|
||||
module_name: "C",
|
||||
ident: "z",
|
||||
},
|
||||
[
|
||||
@294-299 Str(
|
||||
@215-220 Str(
|
||||
PlainLine(
|
||||
"Bar",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
app "desugar-bang"
|
||||
packages {
|
||||
cli: "../basic-cli/platform/main.roc",
|
||||
}
|
||||
imports [
|
||||
cli.Stdout,
|
||||
]
|
||||
provides [main] to cli
|
||||
app [main] {
|
||||
cli: "../basic-cli/platform/main.roc",
|
||||
}
|
||||
|
||||
import cli.Stdout
|
||||
|
||||
main =
|
||||
# is this a valid statement?
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
app ""
|
||||
packages {
|
||||
cli: "",
|
||||
}
|
||||
imports []
|
||||
provides [main] to cli
|
||||
app [main] {
|
||||
cli: platform "",
|
||||
}
|
||||
|
||||
main =
|
||||
"jq --version"
|
||||
|
|
|
|||
|
|
@ -3,75 +3,41 @@ Full {
|
|||
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,
|
||||
],
|
||||
before_provides: [
|
||||
Newline,
|
||||
],
|
||||
provides: [
|
||||
@74-78 ExposedName(
|
||||
"main",
|
||||
),
|
||||
],
|
||||
before_packages: [
|
||||
Newline,
|
||||
],
|
||||
packages: @6-44 Collection {
|
||||
items: [
|
||||
@30-37 SpaceBefore(
|
||||
PackageEntry {
|
||||
shorthand: "cli",
|
||||
spaces_after_shorthand: [],
|
||||
platform_marker: Some(
|
||||
[],
|
||||
),
|
||||
],
|
||||
final_comments: [
|
||||
package_name: @35-37 PackageName(
|
||||
"",
|
||||
),
|
||||
},
|
||||
[
|
||||
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",
|
||||
),
|
||||
final_comments: [
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
old_imports: None,
|
||||
old_provides_to_new_package: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4818,11 +4818,33 @@ mod test_fmt {
|
|||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_style_app_header_is_upgraded() {
|
||||
module_formats_to(
|
||||
indoc!(
|
||||
"
|
||||
app \"test\"
|
||||
packages {
|
||||
pf: \"platform/main.roc\"
|
||||
}
|
||||
provides [main] to pf
|
||||
"
|
||||
),
|
||||
indoc!(
|
||||
"
|
||||
app [main] {
|
||||
pf: platform \"platform/main.roc\",
|
||||
}
|
||||
"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn single_line_app() {
|
||||
module_formats_same(indoc!(
|
||||
r#"
|
||||
app "Foo" packages { pf: "platform/main.roc" } imports [] provides [main] to pf"#
|
||||
app [main] { pf: platform "platform/main.roc" }"#
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -5831,7 +5853,7 @@ mod test_fmt {
|
|||
module_formats_same(indoc!(
|
||||
r#"
|
||||
# hello world
|
||||
app "test" packages {} imports [] provides [] to "./platform"
|
||||
app [] { pf: platform "./platform" }
|
||||
"#
|
||||
));
|
||||
|
||||
|
|
|
|||
|
|
@ -300,6 +300,7 @@ mod test_snapshots {
|
|||
pass/dbg_multiline.expr,
|
||||
pass/def_without_newline.expr,
|
||||
pass/destructure_tag_assignment.expr,
|
||||
pass/docs.expr,
|
||||
pass/empty_app_header.header,
|
||||
pass/empty_module_header.header,
|
||||
pass/empty_hosted_header.header,
|
||||
|
|
@ -333,7 +334,6 @@ mod test_snapshots {
|
|||
pass/inline_import.expr,
|
||||
pass/inline_ingested_file.expr,
|
||||
pass/int_with_underscore.expr,
|
||||
pass/module_with_newline.header,
|
||||
pass/lambda_in_chain.expr,
|
||||
pass/lambda_indent.expr,
|
||||
pass/list_closing_indent_not_enough.expr,
|
||||
|
|
@ -349,6 +349,7 @@ mod test_snapshots {
|
|||
pass/mixed_docs.expr,
|
||||
pass/module_def_newline.moduledefs,
|
||||
pass/module_multiline_exposes.header,
|
||||
pass/module_with_newline.header,
|
||||
pass/multi_backpassing.expr,
|
||||
pass/multi_backpassing_in_def.moduledefs,
|
||||
pass/multi_backpassing_with_apply.expr,
|
||||
|
|
@ -386,9 +387,9 @@ mod test_snapshots {
|
|||
pass/nonempty_hosted_header.header,
|
||||
pass/nonempty_package_header.header,
|
||||
pass/nonempty_platform_header.header,
|
||||
pass/docs.expr,
|
||||
pass/not_multiline_string.expr,
|
||||
pass/number_literal_suffixes.expr,
|
||||
pass/old_app_header.full,
|
||||
pass/one_backpassing.expr,
|
||||
pass/one_char_string.expr,
|
||||
pass/one_def.expr,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue