plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
46223cc
— Peter John
2023-04-28T00:00:05+05:30
new spec
Generated files not shown: src/parser.c
- grammar.js +52 -48
- package.json +2 -6
- queries/tags.scm +5 -5
- sample.palm +168 -0
- spec.gleam +193 -0
- src/grammar.json +390 -240
- src/node-types.json +222 -171
- test/corpus/type.txt +0 -115
- test/corpus/types.txt +85 -0
grammar.js
CHANGED
|
@@ -9,7 +9,7 @@ module.exports = grammar({
|
|
|
9
9
|
externals: ($) => [$.quoted_content],
|
|
10
10
|
rules: {
|
|
11
11
|
source_file: ($) =>
|
|
12
|
-
seq($.module, repeat($.import), repeat(choice($.
|
|
12
|
+
seq($.module, repeat($.import), repeat(choice($.struct, $.enum, $.function))),
|
|
13
13
|
|
|
14
14
|
module: ($) => seq("module", field("module", $.module_name)),
|
|
15
15
|
|
|
@@ -41,34 +41,47 @@ module.exports = grammar({
|
|
|
41
41
|
|
|
42
42
|
/* Declarations */
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
struct: ($) =>
|
|
45
45
|
seq(
|
|
46
46
|
"type",
|
|
47
47
|
field("name", $.type_identifier),
|
|
48
|
-
field("generics", optional($.
|
|
48
|
+
field("generics", optional($.generics)),
|
|
49
|
+
field("fields", seq("(", repeat($.field), ")")),
|
|
50
|
+
),
|
|
51
|
+
|
|
52
|
+
enum: ($) =>
|
|
53
|
+
seq(
|
|
54
|
+
"type",
|
|
55
|
+
field("name", $.type_identifier),
|
|
56
|
+
field("generics", optional($.generics)),
|
|
57
|
+
field("fields", seq(
|
|
58
|
+
"{",
|
|
59
|
+
repeat(
|
|
60
|
+
seq(
|
|
61
|
+
field("name", $.type_identifier),
|
|
62
|
+
optional(seq(
|
|
63
|
+
"(",
|
|
49
|
-
|
|
64
|
+
choice(
|
|
65
|
+
series_of($.identifier, ","),
|
|
50
|
-
|
|
66
|
+
series_of($.field, ","),
|
|
51
|
-
field("union", seq("=", optional("|"), sep1($.union, "|")))
|
|
52
|
-
|
|
67
|
+
),
|
|
68
|
+
")"),
|
|
69
|
+
),
|
|
70
|
+
),
|
|
71
|
+
),
|
|
72
|
+
"}"
|
|
73
|
+
))
|
|
53
74
|
),
|
|
54
75
|
|
|
55
76
|
function: ($) =>
|
|
56
77
|
seq(
|
|
57
78
|
"fn",
|
|
58
79
|
field("name", $.identifier),
|
|
59
|
-
field("params", seq("(", optional(
|
|
80
|
+
field("params", seq("(", optional(series_of($.field, ",")), ")")),
|
|
60
|
-
|
|
81
|
+
field("return", $.return_type),
|
|
61
82
|
field("body", seq("{", $._statement_seq, "}"))
|
|
62
83
|
),
|
|
63
84
|
|
|
64
|
-
/* Shared AST nodes */
|
|
65
|
-
|
|
66
|
-
// param: $ => seq(
|
|
67
|
-
// field('name', $.variable_name),
|
|
68
|
-
// ':',
|
|
69
|
-
// field('type', $.type)
|
|
70
|
-
// ),
|
|
71
|
-
|
|
72
85
|
/* Expressions */
|
|
73
86
|
|
|
74
87
|
_statement_seq: ($) => repeat1($._statement),
|
|
@@ -98,8 +111,6 @@ module.exports = grammar({
|
|
|
98
111
|
$.integer,
|
|
99
112
|
$.float,
|
|
100
113
|
$.identifier,
|
|
101
|
-
$.todo,
|
|
102
|
-
$.panic,
|
|
103
114
|
// $.anonymous_function,
|
|
104
115
|
$.expression_group,
|
|
105
116
|
// $.case,
|
|
@@ -136,29 +147,32 @@ module.exports = grammar({
|
|
|
136
147
|
_pattern_binary_expression: ($) =>
|
|
137
148
|
binaryExpr(prec.left, 1, "<>", $._pattern_expression),
|
|
138
149
|
|
|
139
|
-
todo: ($) =>
|
|
140
|
-
seq("todo", optional(seq("(", field("message", $.string), ")"))),
|
|
141
|
-
panic: (_$) => seq("panic"),
|
|
142
|
-
|
|
143
150
|
/* Types */
|
|
151
|
+
field: ($) =>
|
|
152
|
+
seq(field("name", $.identifier), ":", field("type", $._type)),
|
|
153
|
+
|
|
144
|
-
|
|
154
|
+
function_type: ($) =>
|
|
145
155
|
seq(
|
|
156
|
+
"fn",
|
|
146
|
-
field("
|
|
157
|
+
optional(field("parameter_types", $.function_parameter_types)),
|
|
147
|
-
|
|
158
|
+
optional($.return_type),
|
|
148
159
|
),
|
|
160
|
+
function_parameter_types: ($) =>
|
|
161
|
+
seq("(", optional(series_of($._type, ",")), ")"),
|
|
149
162
|
|
|
150
|
-
record: ($) => seq(seq("(", commaSep1($.type_field), ")")),
|
|
151
|
-
|
|
152
|
-
|
|
163
|
+
type: ($) =>
|
|
153
164
|
seq(
|
|
154
165
|
field("name", $.type_identifier),
|
|
155
|
-
optional(
|
|
166
|
+
optional(field("arguments", $.type_arguments))
|
|
156
167
|
),
|
|
168
|
+
type_arguments: ($) =>
|
|
169
|
+
seq("(", optional(series_of($.type_argument, ",")), ")"),
|
|
170
|
+
type_argument: ($) => $._type,
|
|
157
171
|
|
|
158
|
-
type_field: ($) =>
|
|
159
|
-
|
|
172
|
+
return_type: ($) => seq("->", field("return_type", $._type)),
|
|
160
173
|
|
|
161
|
-
|
|
174
|
+
generics: ($) => seq("(", series_of($.generic, ","), ")"),
|
|
175
|
+
generic: ($) => /[a-z][a-z]*/,
|
|
162
176
|
|
|
163
177
|
/* Literals */
|
|
164
178
|
float: ($) => /-?[0-9_]+\.[0-9_]*(e-?[0-9_]+)?/,
|
|
@@ -179,31 +193,21 @@ module.exports = grammar({
|
|
|
179
193
|
// identifier: ($) => $._name,
|
|
180
194
|
identifier: ($) => /[a-zA-Z_][a-zA-Z_0-9]*/,
|
|
181
195
|
type_identifier: ($) => $._upname,
|
|
196
|
+
remote_type_identifier: ($) =>
|
|
197
|
+
seq(field("module", $.identifier), ".", field("name", $.type_identifier)),
|
|
182
|
-
_type_annotation: ($) => seq(":", field("type", $.
|
|
198
|
+
_type_annotation: ($) => seq(":", field("type", $._type)),
|
|
199
|
+
_type: ($) =>
|
|
200
|
+
choice($.type, $.generic, $.function_type),
|
|
183
201
|
_discard_name: ($) => /_[_0-9a-z]*/,
|
|
184
202
|
_name: ($) => /[_a-z][_0-9a-z]*/,
|
|
185
203
|
_upname: ($) => /[A-Z][0-9a-zA-Z]*/,
|
|
186
204
|
},
|
|
187
205
|
});
|
|
188
206
|
|
|
189
|
-
function commaSep1(rule) {
|
|
190
|
-
return sep1(rule, ",");
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function pipeSep1(rule) {
|
|
194
|
-
return sep1(rule, "|");
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function sep1(rule, separator) {
|
|
198
|
-
return seq(rule, repeat(seq(separator, rule)));
|
|
199
|
-
}
|
|
200
|
-
|
|
201
207
|
function series_of(rule, separator) {
|
|
202
208
|
return seq(rule, repeat(seq(separator, rule)), optional(separator));
|
|
203
209
|
}
|
|
204
210
|
|
|
205
|
-
// A binary expression with a left-hand side, infix operator, and then right-hand-side
|
|
206
|
-
// https://github.com/elixir-lang/tree-sitter-elixir/blob/de20391afe5cb03ef1e8a8e43167e7b58cc52869/grammar.js#L850-L859
|
|
207
211
|
function binaryExpr(assoc, precedence, operator, expr) {
|
|
208
212
|
return assoc(
|
|
209
213
|
precedence,
|
package.json
CHANGED
|
@@ -4,13 +4,9 @@
|
|
|
4
4
|
"description": "A tree-sitter grammar for the Palm programming language",
|
|
5
5
|
"main": "bindings/node",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "tree-sitter test",
|
|
8
7
|
"install": "node-gyp rebuild",
|
|
9
|
-
"generate": "tree-sitter generate",
|
|
10
|
-
"parse": "tree-sitter parse",
|
|
11
|
-
"build-wasm": "tree-sitter build-wasm",
|
|
12
|
-
"playground": "tree-sitter playground",
|
|
13
|
-
"format": "prettier --write grammar.js"
|
|
8
|
+
"format": "prettier --write grammar.js",
|
|
9
|
+
"test": "tree-sitter generate && tree-sitter test"
|
|
14
10
|
},
|
|
15
11
|
"author": "pyrossh",
|
|
16
12
|
"license": "MIT",
|
queries/tags.scm
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
; Modules
|
|
2
2
|
(module) @name @reference.module
|
|
3
3
|
(import alias: (identifier) @name) @reference.module
|
|
4
|
-
(remote_type_identifier
|
|
4
|
+
; (remote_type_identifier
|
|
5
|
-
|
|
5
|
+
; module: (identifier) @name) @reference.module
|
|
6
|
-
((field_access
|
|
6
|
+
; ((field_access
|
|
7
|
-
|
|
7
|
+
; record: (identifier) @name)
|
|
8
|
-
|
|
8
|
+
; (#is-not? local)) @reference.module
|
|
9
9
|
|
|
10
10
|
; Functions
|
|
11
11
|
(function
|
sample.palm
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
module palm
|
|
2
|
+
|
|
3
|
+
pub type Cat = struct(
|
|
4
|
+
firstName: String,
|
|
5
|
+
middleName: String,
|
|
6
|
+
lastName: String,
|
|
7
|
+
age: Int
|
|
8
|
+
cb: |Int| -> Int
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
pub decrement = |c: Cat| -> Cat {
|
|
12
|
+
println("decrementing")
|
|
13
|
+
Cat(...c, age: c.age + 1)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
pub fn have_birthday(person: Person) -> Person {
|
|
17
|
+
Person(..person, age: person.age + 1, is_happy: True)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
pub have_birthday = |person: Person| -> Person {
|
|
21
|
+
Person(..person, age: person.age + 1, is_happy: True)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
pub fn main {
|
|
25
|
+
const cat = Cat(name: "Felix", cuteness: 9001, age: 5)
|
|
26
|
+
cat
|
|
27
|
+
|> increment()
|
|
28
|
+
|> increment()
|
|
29
|
+
|> increment()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
isSingleton(b : Bool) -> Type =
|
|
34
|
+
| True = Int
|
|
35
|
+
| False = List(Int)
|
|
36
|
+
|
|
37
|
+
-- module palm/list
|
|
38
|
+
|
|
39
|
+
type List(a)(
|
|
40
|
+
items: []a
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
pub fn new(l: ...a) -> List(a) {
|
|
44
|
+
List(items: l, size: l.size)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
pub fn head(l: List(a)) -> a {
|
|
48
|
+
when {
|
|
49
|
+
l.size == 0 -> panic("accessing head of empty list")
|
|
50
|
+
_ -> l[0]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
pub fn tail(l: List(a)) -> a {
|
|
55
|
+
when {
|
|
56
|
+
l.size == 0 -> []
|
|
57
|
+
l.size == 1 -> []
|
|
58
|
+
_ -> new(l[1:l.size])
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
pub fn is_empty(l: List(a)) -> Bool {
|
|
63
|
+
l.size == 0
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
pub fn contains(l: List(a), elem: a) -> Bool {
|
|
67
|
+
when l {
|
|
68
|
+
is_empty(l) -> False
|
|
69
|
+
head(l) == elem -> True
|
|
70
|
+
_ -> contains(tail(l), elem)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
pub fn each(l: List(a), f: fn (a)) {
|
|
75
|
+
if !is_empty(l) {
|
|
76
|
+
head(l) |> f()
|
|
77
|
+
tail(l) |> each(f)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
pub type Iterator(element)(
|
|
82
|
+
continuation: fn() -> Action(element)
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
type Action(element) {
|
|
86
|
+
Stop
|
|
87
|
+
Continue(element, fn() -> Action(element))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
pub type Step(element, accumulator) {
|
|
91
|
+
Next(element: element, accumulator: accumulator)
|
|
92
|
+
Done
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
InfiniteIteror = Iterator(Bool)(
|
|
96
|
+
continuation: fn () -> Action(Bool) {
|
|
97
|
+
True
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
pub fn while(cond: Iterator, cb: fn()) {
|
|
103
|
+
when cond().next() {
|
|
104
|
+
cb()
|
|
105
|
+
while(cond, cb)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
items
|
|
111
|
+
|> list.each(|| println(item.name) })
|
|
112
|
+
|> list.map(|| Person(...item, name: "123") })
|
|
113
|
+
|
|
114
|
+
filter(l: List(a), f: (a) -> Bool, acc: List(a) = new()) -> List(a) =
|
|
115
|
+
| is_empty(l) -> acc
|
|
116
|
+
| f(head(l)) ->
|
|
117
|
+
acc |> add(head(l))
|
|
118
|
+
filter(tail(l), f, acc)
|
|
119
|
+
| _ ->
|
|
120
|
+
filter(tail(l), f, acc)
|
|
121
|
+
|
|
122
|
+
fn map_res(res: Response) -> Result(String, String) {
|
|
123
|
+
case (x = res.status()) {
|
|
124
|
+
x >= 500 -> Error("failed")
|
|
125
|
+
_ -> Ok("success")
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
handler(request: Request(t)) -> Response(String) =
|
|
130
|
+
body = bit_builder.from_string("Hello, world!")
|
|
131
|
+
response.new(200)
|
|
132
|
+
|> response.prepend_header("made-with", "Gleam")
|
|
133
|
+
|> response.set_body(body)
|
|
134
|
+
|
|
135
|
+
fn main(args: List(String)) -> Result(Int, String) {
|
|
136
|
+
println "Sum of x + y = "
|
|
137
|
+
println addMe(10 25)
|
|
138
|
+
|
|
139
|
+
list.new(1, 2, 3, 4, 5)
|
|
140
|
+
|> list.filter(|x| -> x > 5)
|
|
141
|
+
|> list.map(|x| -> x * 2)
|
|
142
|
+
|> list.each(|x| -> prinln(x))
|
|
143
|
+
|> list.is_empty()
|
|
144
|
+
|
|
145
|
+
let res = request.new()
|
|
146
|
+
|> request.set_method(Get)
|
|
147
|
+
|> request.set_host("test-api.service.hmrc.gov.uk")
|
|
148
|
+
|> request.set_path("/hello/world")
|
|
149
|
+
|> request.prepend_header("accept", "application/vnd.hmrc.1.0+json")
|
|
150
|
+
|> request.fetch()
|
|
151
|
+
|
|
152
|
+
res
|
|
153
|
+
|> map_res
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
fn add(x: Int, y: Int) -> Int {
|
|
158
|
+
x + y
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
multiply(x: Int, y: Int) -> Int =
|
|
162
|
+
x * y
|
|
163
|
+
|
|
164
|
+
twice(f: (t) -> t, x: t) -> t =
|
|
165
|
+
f(f(x))
|
|
166
|
+
|
|
167
|
+
add_one(x: Int) -> Int =
|
|
168
|
+
x + 1
|
spec.gleam
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import gleam/io
|
|
2
|
+
import gleam/bool
|
|
3
|
+
import gleam/string
|
|
4
|
+
import gleam/list
|
|
5
|
+
import gleam/http/response.{Request, Response}
|
|
6
|
+
import gleam/bit_builder.{BitBuilder}
|
|
7
|
+
|
|
8
|
+
pub fn main() {
|
|
9
|
+
io.print("hi")
|
|
10
|
+
False
|
|
11
|
+
|> bool.nand(False)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
pub type Result(value, reason) {
|
|
15
|
+
Ok(value)
|
|
16
|
+
Error(reason)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
pub fn fib(x: Int) -> Int {
|
|
20
|
+
when x {
|
|
21
|
+
0..1 -> 1
|
|
22
|
+
_ -> fib(x - 1) + fib(x - 2)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
when x > 5 {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
pub fn handler(request: Request) -> Response {
|
|
30
|
+
let body = bit_builder.from_string("Hello, world!")
|
|
31
|
+
|
|
32
|
+
response.new(200)
|
|
33
|
+
|> response.prepend_header("made-with", "Gleam")
|
|
34
|
+
|> response.set_body(body)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
pub fn main() {
|
|
38
|
+
let res =
|
|
39
|
+
request.new()
|
|
40
|
+
|> request.set_method(Get)
|
|
41
|
+
|> request.set_host("test-api.service.hmrc.gov.uk")
|
|
42
|
+
|> request.set_path("/hello/world")
|
|
43
|
+
|> request.prepend_header("accept", "application/vnd.hmrc.1.0+json")
|
|
44
|
+
|> request.fetch()
|
|
45
|
+
|
|
46
|
+
case res {
|
|
47
|
+
Ok(b) -> {
|
|
48
|
+
let data = json.parse(b)
|
|
49
|
+
response.new(200)
|
|
50
|
+
|> response.set_body(json.stringify(data))
|
|
51
|
+
}
|
|
52
|
+
Error(_) -> {
|
|
53
|
+
response.new(500)
|
|
54
|
+
|> response.set_body("Could not find data")
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
pub fn all(results: List(Result(a, e))) -> Result(List(a), e) {
|
|
60
|
+
list.try_map(results, fn(x) { x })
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
pub fn add(x: Int, y: Int) -> Int {
|
|
64
|
+
x + y
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
pub fn multiply(x: Int, y: Int) -> Int {
|
|
68
|
+
x * y
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/// This function takes a function as an argument
|
|
72
|
+
pub fn twice(f: fn(t) -> t, x: t) -> t {
|
|
73
|
+
f(f(x))
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
pub fn add_one(x: Int) -> Int {
|
|
77
|
+
x + 1
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
pub fn add_two(x: Int) -> Int {
|
|
81
|
+
twice(add_one, x)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
pub const start_year = 2101
|
|
85
|
+
|
|
86
|
+
pub const end_year = 2111
|
|
87
|
+
|
|
88
|
+
pub fn is_before(year: Int) -> Bool {
|
|
89
|
+
year < start_year
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
pub fn is_during(year: Int) -> Bool {
|
|
93
|
+
start_year <= year && year <= end_year
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
pub fn describe(year: Int) -> String {
|
|
97
|
+
case year {
|
|
98
|
+
year if year < start_year -> "Before"
|
|
99
|
+
year if year > end_year -> "After"
|
|
100
|
+
_ -> "During"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
pub const name: String = "Gleam"
|
|
105
|
+
|
|
106
|
+
pub const size: Int = 100
|
|
107
|
+
|
|
108
|
+
pub type Headers =
|
|
109
|
+
List(#(String, String))
|
|
110
|
+
|
|
111
|
+
pub fn main() {
|
|
112
|
+
let string = "123"
|
|
113
|
+
string
|
|
114
|
+
|> string_builder.from_string
|
|
115
|
+
|> string_builder.reverse
|
|
116
|
+
|> string_builder.to_string
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
pub external fn random_float() -> Float =
|
|
120
|
+
"rand" "uniform"
|
|
121
|
+
|
|
122
|
+
// Elixir modules start with `Elixir.`
|
|
123
|
+
pub external fn inspect(a) -> a =
|
|
124
|
+
"Elixir.IO" "inspect"
|
|
125
|
+
|
|
126
|
+
pub external type Queue(a)
|
|
127
|
+
|
|
128
|
+
pub external fn new() -> Queue(a) =
|
|
129
|
+
"queue" "new"
|
|
130
|
+
|
|
131
|
+
pub external fn length(Queue(a)) -> Int =
|
|
132
|
+
"queue" "len"
|
|
133
|
+
|
|
134
|
+
pub external fn push(Queue(a), a) -> Queue(a) =
|
|
135
|
+
"queue" "in"
|
|
136
|
+
|
|
137
|
+
fn favourite_number() -> Int {
|
|
138
|
+
// The type annotations says this returns an Int, but we don't need
|
|
139
|
+
// to implement it yet.
|
|
140
|
+
todo
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
pub fn main() {
|
|
144
|
+
favourite_number() * 2
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
fn more_usage() {
|
|
148
|
+
list.new(1, 2, 3)
|
|
149
|
+
|> list.contains(any: 2)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
pub fn get_name(user: User) {
|
|
153
|
+
case user {
|
|
154
|
+
LoggedIn(name) -> {
|
|
155
|
+
let a = 1.2
|
|
156
|
+
let b = 4.5
|
|
157
|
+
let c = n * factorial(n - 1)
|
|
158
|
+
name
|
|
159
|
+
}
|
|
160
|
+
Guest -> "Guest user"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
pub type Result(p, q) {
|
|
165
|
+
Ok(p)
|
|
166
|
+
Error(q)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// pub type Cat(
|
|
170
|
+
// name: String,
|
|
171
|
+
// cuteness: Int,
|
|
172
|
+
// age: Int
|
|
173
|
+
// )
|
|
174
|
+
|
|
175
|
+
pub fn make_api_call(r: String) -> Result(String, String) {
|
|
176
|
+
make_request(r) |> response.map()
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
pub fn map(res: Response) -> Result(String, String) {
|
|
180
|
+
| res.status() >= 500 -> Error("failed")
|
|
181
|
+
| _ -> Ok("success")
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
pub fn getColorHex(c: String) -> Int {
|
|
185
|
+
when c {
|
|
186
|
+
"red" -> 0xff0000
|
|
187
|
+
"blue" -> 0xff0123
|
|
188
|
+
"green" -> 0xff0123
|
|
189
|
+
"black" -> 0x000000
|
|
190
|
+
"white" -> 0xffffff
|
|
191
|
+
"violet" -> 0x0f0f23
|
|
192
|
+
}
|
|
193
|
+
}
|
src/grammar.json
CHANGED
|
@@ -22,7 +22,11 @@
|
|
|
22
22
|
"members": [
|
|
23
23
|
{
|
|
24
24
|
"type": "SYMBOL",
|
|
25
|
+
"name": "struct"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "SYMBOL",
|
|
25
|
-
"name": "
|
|
29
|
+
"name": "enum"
|
|
26
30
|
},
|
|
27
31
|
{
|
|
28
32
|
"type": "SYMBOL",
|
|
@@ -281,7 +285,7 @@
|
|
|
281
285
|
}
|
|
282
286
|
]
|
|
283
287
|
},
|
|
284
|
-
"
|
|
288
|
+
"struct": {
|
|
285
289
|
"type": "SEQ",
|
|
286
290
|
"members": [
|
|
287
291
|
{
|
|
@@ -304,7 +308,7 @@
|
|
|
304
308
|
"members": [
|
|
305
309
|
{
|
|
306
310
|
"type": "SYMBOL",
|
|
307
|
-
"name": "
|
|
311
|
+
"name": "generics"
|
|
308
312
|
},
|
|
309
313
|
{
|
|
310
314
|
"type": "BLANK"
|
|
@@ -313,67 +317,194 @@
|
|
|
313
317
|
}
|
|
314
318
|
},
|
|
315
319
|
{
|
|
320
|
+
"type": "FIELD",
|
|
321
|
+
"name": "fields",
|
|
322
|
+
"content": {
|
|
323
|
+
"type": "SEQ",
|
|
324
|
+
"members": [
|
|
325
|
+
{
|
|
326
|
+
"type": "STRING",
|
|
327
|
+
"value": "("
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
"type": "REPEAT",
|
|
331
|
+
"content": {
|
|
332
|
+
"type": "SYMBOL",
|
|
333
|
+
"name": "field"
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"type": "STRING",
|
|
338
|
+
"value": ")"
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
]
|
|
344
|
+
},
|
|
345
|
+
"enum": {
|
|
346
|
+
"type": "SEQ",
|
|
347
|
+
"members": [
|
|
348
|
+
{
|
|
349
|
+
"type": "STRING",
|
|
350
|
+
"value": "type"
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"type": "FIELD",
|
|
354
|
+
"name": "name",
|
|
355
|
+
"content": {
|
|
356
|
+
"type": "SYMBOL",
|
|
357
|
+
"name": "type_identifier"
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"type": "FIELD",
|
|
362
|
+
"name": "generics",
|
|
363
|
+
"content": {
|
|
316
|
-
|
|
364
|
+
"type": "CHOICE",
|
|
317
|
-
|
|
365
|
+
"members": [
|
|
318
|
-
|
|
366
|
+
{
|
|
319
|
-
"type": "FIELD",
|
|
320
|
-
"name": "record",
|
|
321
|
-
"content": {
|
|
322
367
|
"type": "SYMBOL",
|
|
323
|
-
"name": "
|
|
368
|
+
"name": "generics"
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
"type": "BLANK"
|
|
324
372
|
}
|
|
373
|
+
]
|
|
374
|
+
}
|
|
325
|
-
|
|
375
|
+
},
|
|
326
|
-
|
|
376
|
+
{
|
|
327
|
-
|
|
377
|
+
"type": "FIELD",
|
|
328
|
-
|
|
378
|
+
"name": "fields",
|
|
329
|
-
|
|
379
|
+
"content": {
|
|
330
|
-
|
|
380
|
+
"type": "SEQ",
|
|
331
|
-
|
|
381
|
+
"members": [
|
|
332
|
-
|
|
382
|
+
{
|
|
333
|
-
|
|
383
|
+
"type": "STRING",
|
|
334
|
-
|
|
384
|
+
"value": "{"
|
|
335
|
-
|
|
385
|
+
},
|
|
336
|
-
|
|
386
|
+
{
|
|
337
|
-
|
|
387
|
+
"type": "REPEAT",
|
|
388
|
+
"content": {
|
|
389
|
+
"type": "SEQ",
|
|
338
|
-
|
|
390
|
+
"members": [
|
|
339
|
-
|
|
391
|
+
{
|
|
340
|
-
"type": "STRING",
|
|
341
|
-
"value": "|"
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
"type": "BLANK"
|
|
345
|
-
}
|
|
346
|
-
]
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
|
|
392
|
+
"type": "FIELD",
|
|
393
|
+
"name": "name",
|
|
350
|
-
|
|
394
|
+
"content": {
|
|
351
|
-
{
|
|
352
395
|
"type": "SYMBOL",
|
|
353
|
-
"name": "
|
|
396
|
+
"name": "type_identifier"
|
|
397
|
+
}
|
|
354
|
-
|
|
398
|
+
},
|
|
355
|
-
|
|
399
|
+
{
|
|
356
|
-
|
|
400
|
+
"type": "CHOICE",
|
|
357
|
-
|
|
401
|
+
"members": [
|
|
402
|
+
{
|
|
358
403
|
"type": "SEQ",
|
|
359
404
|
"members": [
|
|
360
405
|
{
|
|
361
406
|
"type": "STRING",
|
|
362
|
-
"value": "
|
|
407
|
+
"value": "("
|
|
363
408
|
},
|
|
364
409
|
{
|
|
410
|
+
"type": "CHOICE",
|
|
411
|
+
"members": [
|
|
412
|
+
{
|
|
413
|
+
"type": "SEQ",
|
|
414
|
+
"members": [
|
|
415
|
+
{
|
|
365
|
-
|
|
416
|
+
"type": "SYMBOL",
|
|
417
|
+
"name": "identifier"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"type": "REPEAT",
|
|
421
|
+
"content": {
|
|
422
|
+
"type": "SEQ",
|
|
423
|
+
"members": [
|
|
424
|
+
{
|
|
425
|
+
"type": "STRING",
|
|
426
|
+
"value": ","
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"type": "SYMBOL",
|
|
430
|
+
"name": "identifier"
|
|
431
|
+
}
|
|
432
|
+
]
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
"type": "CHOICE",
|
|
437
|
+
"members": [
|
|
438
|
+
{
|
|
439
|
+
"type": "STRING",
|
|
440
|
+
"value": ","
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"type": "BLANK"
|
|
444
|
+
}
|
|
445
|
+
]
|
|
446
|
+
}
|
|
447
|
+
]
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"type": "SEQ",
|
|
451
|
+
"members": [
|
|
452
|
+
{
|
|
453
|
+
"type": "SYMBOL",
|
|
366
|
-
|
|
454
|
+
"name": "field"
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
"type": "REPEAT",
|
|
458
|
+
"content": {
|
|
459
|
+
"type": "SEQ",
|
|
460
|
+
"members": [
|
|
461
|
+
{
|
|
462
|
+
"type": "STRING",
|
|
463
|
+
"value": ","
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
"type": "SYMBOL",
|
|
467
|
+
"name": "field"
|
|
468
|
+
}
|
|
469
|
+
]
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"type": "CHOICE",
|
|
474
|
+
"members": [
|
|
475
|
+
{
|
|
476
|
+
"type": "STRING",
|
|
477
|
+
"value": ","
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
"type": "BLANK"
|
|
481
|
+
}
|
|
482
|
+
]
|
|
483
|
+
}
|
|
484
|
+
]
|
|
485
|
+
}
|
|
486
|
+
]
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"type": "STRING",
|
|
490
|
+
"value": ")"
|
|
367
491
|
}
|
|
368
492
|
]
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
"type": "BLANK"
|
|
369
496
|
}
|
|
497
|
+
]
|
|
370
|
-
|
|
498
|
+
}
|
|
371
|
-
|
|
499
|
+
]
|
|
372
|
-
|
|
500
|
+
}
|
|
501
|
+
},
|
|
373
|
-
|
|
502
|
+
{
|
|
503
|
+
"type": "STRING",
|
|
504
|
+
"value": "}"
|
|
374
505
|
}
|
|
506
|
+
]
|
|
375
|
-
|
|
507
|
+
}
|
|
376
|
-
]
|
|
377
508
|
}
|
|
378
509
|
]
|
|
379
510
|
},
|
|
@@ -410,7 +541,7 @@
|
|
|
410
541
|
"members": [
|
|
411
542
|
{
|
|
412
543
|
"type": "SYMBOL",
|
|
413
|
-
"name": "
|
|
544
|
+
"name": "field"
|
|
414
545
|
},
|
|
415
546
|
{
|
|
416
547
|
"type": "REPEAT",
|
|
@@ -423,10 +554,22 @@
|
|
|
423
554
|
},
|
|
424
555
|
{
|
|
425
556
|
"type": "SYMBOL",
|
|
426
|
-
"name": "
|
|
557
|
+
"name": "field"
|
|
427
558
|
}
|
|
428
559
|
]
|
|
429
560
|
}
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"type": "CHOICE",
|
|
564
|
+
"members": [
|
|
565
|
+
{
|
|
566
|
+
"type": "STRING",
|
|
567
|
+
"value": ","
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
"type": "BLANK"
|
|
571
|
+
}
|
|
572
|
+
]
|
|
430
573
|
}
|
|
431
574
|
]
|
|
432
575
|
},
|
|
@@ -443,37 +586,12 @@
|
|
|
443
586
|
}
|
|
444
587
|
},
|
|
445
588
|
{
|
|
446
|
-
"type": "CHOICE",
|
|
447
|
-
"members": [
|
|
448
|
-
{
|
|
449
|
-
"type": "SEQ",
|
|
450
|
-
"members": [
|
|
451
|
-
{
|
|
452
|
-
"type": "STRING",
|
|
453
|
-
"value": "->"
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
|
|
589
|
+
"type": "FIELD",
|
|
457
|
-
|
|
590
|
+
"name": "return",
|
|
458
|
-
|
|
591
|
+
"content": {
|
|
459
|
-
"type": "CHOICE",
|
|
460
|
-
"members": [
|
|
461
|
-
{
|
|
462
|
-
|
|
592
|
+
"type": "SYMBOL",
|
|
463
|
-
|
|
593
|
+
"name": "return_type"
|
|
464
|
-
},
|
|
465
|
-
{
|
|
466
|
-
"type": "BLANK"
|
|
467
|
-
|
|
594
|
+
}
|
|
468
|
-
]
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
]
|
|
472
|
-
},
|
|
473
|
-
{
|
|
474
|
-
"type": "BLANK"
|
|
475
|
-
}
|
|
476
|
-
]
|
|
477
595
|
},
|
|
478
596
|
{
|
|
479
597
|
"type": "FIELD",
|
|
@@ -1050,14 +1168,6 @@
|
|
|
1050
1168
|
"type": "SYMBOL",
|
|
1051
1169
|
"name": "identifier"
|
|
1052
1170
|
},
|
|
1053
|
-
{
|
|
1054
|
-
"type": "SYMBOL",
|
|
1055
|
-
"name": "todo"
|
|
1056
|
-
},
|
|
1057
|
-
{
|
|
1058
|
-
"type": "SYMBOL",
|
|
1059
|
-
"name": "panic"
|
|
1060
|
-
},
|
|
1061
1171
|
{
|
|
1062
1172
|
"type": "SYMBOL",
|
|
1063
1173
|
"name": "expression_group"
|
|
@@ -1241,132 +1351,84 @@
|
|
|
1241
1351
|
]
|
|
1242
1352
|
}
|
|
1243
1353
|
},
|
|
1244
|
-
"
|
|
1354
|
+
"field": {
|
|
1355
|
+
"type": "SEQ",
|
|
1356
|
+
"members": [
|
|
1357
|
+
{
|
|
1358
|
+
"type": "FIELD",
|
|
1359
|
+
"name": "name",
|
|
1360
|
+
"content": {
|
|
1361
|
+
"type": "SYMBOL",
|
|
1362
|
+
"name": "identifier"
|
|
1363
|
+
}
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
"type": "STRING",
|
|
1367
|
+
"value": ":"
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
"type": "FIELD",
|
|
1371
|
+
"name": "type",
|
|
1372
|
+
"content": {
|
|
1373
|
+
"type": "SYMBOL",
|
|
1374
|
+
"name": "_type"
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
]
|
|
1378
|
+
},
|
|
1379
|
+
"function_type": {
|
|
1245
1380
|
"type": "SEQ",
|
|
1246
1381
|
"members": [
|
|
1247
1382
|
{
|
|
1248
1383
|
"type": "STRING",
|
|
1249
|
-
"value": "
|
|
1384
|
+
"value": "fn"
|
|
1250
1385
|
},
|
|
1251
1386
|
{
|
|
1252
1387
|
"type": "CHOICE",
|
|
1253
1388
|
"members": [
|
|
1254
1389
|
{
|
|
1255
|
-
"type": "SEQ",
|
|
1256
|
-
"members": [
|
|
1257
|
-
{
|
|
1258
|
-
"type": "STRING",
|
|
1259
|
-
"value": "("
|
|
1260
|
-
},
|
|
1261
|
-
{
|
|
1262
|
-
|
|
1390
|
+
"type": "FIELD",
|
|
1263
|
-
|
|
1391
|
+
"name": "parameter_types",
|
|
1264
|
-
|
|
1392
|
+
"content": {
|
|
1265
|
-
|
|
1393
|
+
"type": "SYMBOL",
|
|
1266
|
-
|
|
1394
|
+
"name": "function_parameter_types"
|
|
1267
|
-
|
|
1395
|
+
}
|
|
1268
|
-
},
|
|
1269
|
-
{
|
|
1270
|
-
"type": "STRING",
|
|
1271
|
-
"value": ")"
|
|
1272
|
-
}
|
|
1273
|
-
]
|
|
1274
1396
|
},
|
|
1275
1397
|
{
|
|
1276
1398
|
"type": "BLANK"
|
|
1277
1399
|
}
|
|
1278
1400
|
]
|
|
1279
|
-
}
|
|
1280
|
-
]
|
|
1281
|
-
|
|
1401
|
+
},
|
|
1282
|
-
"panic": {
|
|
1283
|
-
"type": "SEQ",
|
|
1284
|
-
"members": [
|
|
1285
1402
|
{
|
|
1286
|
-
"type": "
|
|
1403
|
+
"type": "CHOICE",
|
|
1404
|
+
"members": [
|
|
1405
|
+
{
|
|
1406
|
+
"type": "SYMBOL",
|
|
1407
|
+
"name": "return_type"
|
|
1408
|
+
},
|
|
1409
|
+
{
|
|
1287
|
-
|
|
1410
|
+
"type": "BLANK"
|
|
1411
|
+
}
|
|
1412
|
+
]
|
|
1288
1413
|
}
|
|
1289
1414
|
]
|
|
1290
1415
|
},
|
|
1291
|
-
"
|
|
1416
|
+
"function_parameter_types": {
|
|
1292
1417
|
"type": "SEQ",
|
|
1293
1418
|
"members": [
|
|
1294
1419
|
{
|
|
1295
|
-
"type": "FIELD",
|
|
1296
|
-
"name": "name",
|
|
1297
|
-
"content": {
|
|
1298
|
-
|
|
1420
|
+
"type": "STRING",
|
|
1299
|
-
|
|
1421
|
+
"value": "("
|
|
1300
|
-
}
|
|
1301
1422
|
},
|
|
1302
1423
|
{
|
|
1303
|
-
"type": "FIELD",
|
|
1304
|
-
"name": "generics",
|
|
1305
|
-
"content": {
|
|
1306
|
-
|
|
1424
|
+
"type": "CHOICE",
|
|
1307
|
-
"members": [
|
|
1308
|
-
{
|
|
1309
|
-
"type": "SEQ",
|
|
1310
|
-
"members": [
|
|
1311
|
-
{
|
|
1312
|
-
"type": "STRING",
|
|
1313
|
-
"value": "("
|
|
1314
|
-
},
|
|
1315
|
-
{
|
|
1316
|
-
"type": "SEQ",
|
|
1317
|
-
"members": [
|
|
1318
|
-
{
|
|
1319
|
-
"type": "SYMBOL",
|
|
1320
|
-
"name": "identifier"
|
|
1321
|
-
},
|
|
1322
|
-
{
|
|
1323
|
-
"type": "REPEAT",
|
|
1324
|
-
"content": {
|
|
1325
|
-
"type": "SEQ",
|
|
1326
|
-
"members": [
|
|
1327
|
-
{
|
|
1328
|
-
"type": "STRING",
|
|
1329
|
-
"value": ","
|
|
1330
|
-
},
|
|
1331
|
-
{
|
|
1332
|
-
"type": "SYMBOL",
|
|
1333
|
-
"name": "identifier"
|
|
1334
|
-
}
|
|
1335
|
-
]
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
]
|
|
1339
|
-
},
|
|
1340
|
-
{
|
|
1341
|
-
"type": "STRING",
|
|
1342
|
-
"value": ")"
|
|
1343
|
-
}
|
|
1344
|
-
]
|
|
1345
|
-
},
|
|
1346
|
-
{
|
|
1347
|
-
"type": "BLANK"
|
|
1348
|
-
}
|
|
1349
|
-
]
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
]
|
|
1353
|
-
},
|
|
1354
|
-
"record": {
|
|
1355
|
-
"type": "SEQ",
|
|
1356
|
-
"members": [
|
|
1357
|
-
{
|
|
1358
|
-
"type": "SEQ",
|
|
1359
1425
|
"members": [
|
|
1360
|
-
{
|
|
1361
|
-
"type": "STRING",
|
|
1362
|
-
"value": "("
|
|
1363
|
-
},
|
|
1364
1426
|
{
|
|
1365
1427
|
"type": "SEQ",
|
|
1366
1428
|
"members": [
|
|
1367
1429
|
{
|
|
1368
1430
|
"type": "SYMBOL",
|
|
1369
|
-
"name": "
|
|
1431
|
+
"name": "_type"
|
|
1370
1432
|
},
|
|
1371
1433
|
{
|
|
1372
1434
|
"type": "REPEAT",
|
|
@@ -1379,22 +1441,37 @@
|
|
|
1379
1441
|
},
|
|
1380
1442
|
{
|
|
1381
1443
|
"type": "SYMBOL",
|
|
1382
|
-
"name": "
|
|
1444
|
+
"name": "_type"
|
|
1383
1445
|
}
|
|
1384
1446
|
]
|
|
1385
1447
|
}
|
|
1448
|
+
},
|
|
1449
|
+
{
|
|
1450
|
+
"type": "CHOICE",
|
|
1451
|
+
"members": [
|
|
1452
|
+
{
|
|
1453
|
+
"type": "STRING",
|
|
1454
|
+
"value": ","
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
"type": "BLANK"
|
|
1458
|
+
}
|
|
1459
|
+
]
|
|
1386
1460
|
}
|
|
1387
1461
|
]
|
|
1388
1462
|
},
|
|
1389
1463
|
{
|
|
1390
|
-
"type": "
|
|
1464
|
+
"type": "BLANK"
|
|
1391
|
-
"value": ")"
|
|
1392
1465
|
}
|
|
1393
1466
|
]
|
|
1467
|
+
},
|
|
1468
|
+
{
|
|
1469
|
+
"type": "STRING",
|
|
1470
|
+
"value": ")"
|
|
1394
1471
|
}
|
|
1395
1472
|
]
|
|
1396
1473
|
},
|
|
1397
|
-
"
|
|
1474
|
+
"type": {
|
|
1398
1475
|
"type": "SEQ",
|
|
1399
1476
|
"members": [
|
|
1400
1477
|
{
|
|
@@ -1405,6 +1482,31 @@
|
|
|
1405
1482
|
"name": "type_identifier"
|
|
1406
1483
|
}
|
|
1407
1484
|
},
|
|
1485
|
+
{
|
|
1486
|
+
"type": "CHOICE",
|
|
1487
|
+
"members": [
|
|
1488
|
+
{
|
|
1489
|
+
"type": "FIELD",
|
|
1490
|
+
"name": "arguments",
|
|
1491
|
+
"content": {
|
|
1492
|
+
"type": "SYMBOL",
|
|
1493
|
+
"name": "type_arguments"
|
|
1494
|
+
}
|
|
1495
|
+
},
|
|
1496
|
+
{
|
|
1497
|
+
"type": "BLANK"
|
|
1498
|
+
}
|
|
1499
|
+
]
|
|
1500
|
+
}
|
|
1501
|
+
]
|
|
1502
|
+
},
|
|
1503
|
+
"type_arguments": {
|
|
1504
|
+
"type": "SEQ",
|
|
1505
|
+
"members": [
|
|
1506
|
+
{
|
|
1507
|
+
"type": "STRING",
|
|
1508
|
+
"value": "("
|
|
1509
|
+
},
|
|
1408
1510
|
{
|
|
1409
1511
|
"type": "CHOICE",
|
|
1410
1512
|
"members": [
|
|
@@ -1412,46 +1514,36 @@
|
|
|
1412
1514
|
"type": "SEQ",
|
|
1413
1515
|
"members": [
|
|
1414
1516
|
{
|
|
1517
|
+
"type": "SYMBOL",
|
|
1518
|
+
"name": "type_argument"
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
"type": "REPEAT",
|
|
1522
|
+
"content": {
|
|
1523
|
+
"type": "SEQ",
|
|
1524
|
+
"members": [
|
|
1525
|
+
{
|
|
1415
|
-
|
|
1526
|
+
"type": "STRING",
|
|
1416
|
-
|
|
1527
|
+
"value": ","
|
|
1528
|
+
},
|
|
1529
|
+
{
|
|
1530
|
+
"type": "SYMBOL",
|
|
1531
|
+
"name": "type_argument"
|
|
1532
|
+
}
|
|
1533
|
+
]
|
|
1534
|
+
}
|
|
1417
1535
|
},
|
|
1418
1536
|
{
|
|
1419
1537
|
"type": "CHOICE",
|
|
1420
1538
|
"members": [
|
|
1421
1539
|
{
|
|
1422
|
-
"type": "
|
|
1540
|
+
"type": "STRING",
|
|
1423
|
-
"
|
|
1541
|
+
"value": ","
|
|
1424
1542
|
},
|
|
1425
1543
|
{
|
|
1426
|
-
"type": "SEQ",
|
|
1427
|
-
"members": [
|
|
1428
|
-
{
|
|
1429
|
-
"type": "SYMBOL",
|
|
1430
|
-
"name": "type_field"
|
|
1431
|
-
},
|
|
1432
|
-
{
|
|
1433
|
-
"type": "REPEAT",
|
|
1434
|
-
"content": {
|
|
1435
|
-
"type": "SEQ",
|
|
1436
|
-
"members": [
|
|
1437
|
-
{
|
|
1438
|
-
|
|
1544
|
+
"type": "BLANK"
|
|
1439
|
-
"value": ","
|
|
1440
|
-
},
|
|
1441
|
-
{
|
|
1442
|
-
"type": "SYMBOL",
|
|
1443
|
-
"name": "type_field"
|
|
1444
|
-
}
|
|
1445
|
-
]
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
|
-
]
|
|
1449
1545
|
}
|
|
1450
1546
|
]
|
|
1451
|
-
},
|
|
1452
|
-
{
|
|
1453
|
-
"type": "STRING",
|
|
1454
|
-
"value": ")"
|
|
1455
1547
|
}
|
|
1456
1548
|
]
|
|
1457
1549
|
},
|
|
@@ -1459,35 +1551,35 @@
|
|
|
1459
1551
|
"type": "BLANK"
|
|
1460
1552
|
}
|
|
1461
1553
|
]
|
|
1554
|
+
},
|
|
1555
|
+
{
|
|
1556
|
+
"type": "STRING",
|
|
1557
|
+
"value": ")"
|
|
1462
1558
|
}
|
|
1463
1559
|
]
|
|
1464
1560
|
},
|
|
1465
|
-
"
|
|
1561
|
+
"type_argument": {
|
|
1562
|
+
"type": "SYMBOL",
|
|
1563
|
+
"name": "_type"
|
|
1564
|
+
},
|
|
1565
|
+
"return_type": {
|
|
1466
1566
|
"type": "SEQ",
|
|
1467
1567
|
"members": [
|
|
1468
|
-
{
|
|
1469
|
-
"type": "FIELD",
|
|
1470
|
-
"name": "name",
|
|
1471
|
-
"content": {
|
|
1472
|
-
"type": "SYMBOL",
|
|
1473
|
-
"name": "identifier"
|
|
1474
|
-
}
|
|
1475
|
-
},
|
|
1476
1568
|
{
|
|
1477
1569
|
"type": "STRING",
|
|
1478
|
-
"value": "
|
|
1570
|
+
"value": "->"
|
|
1479
1571
|
},
|
|
1480
1572
|
{
|
|
1481
1573
|
"type": "FIELD",
|
|
1482
|
-
"name": "
|
|
1574
|
+
"name": "return_type",
|
|
1483
1575
|
"content": {
|
|
1484
1576
|
"type": "SYMBOL",
|
|
1485
|
-
"name": "
|
|
1577
|
+
"name": "_type"
|
|
1486
1578
|
}
|
|
1487
1579
|
}
|
|
1488
1580
|
]
|
|
1489
1581
|
},
|
|
1490
|
-
"
|
|
1582
|
+
"generics": {
|
|
1491
1583
|
"type": "SEQ",
|
|
1492
1584
|
"members": [
|
|
1493
1585
|
{
|
|
@@ -1499,7 +1591,7 @@
|
|
|
1499
1591
|
"members": [
|
|
1500
1592
|
{
|
|
1501
1593
|
"type": "SYMBOL",
|
|
1502
|
-
"name": "
|
|
1594
|
+
"name": "generic"
|
|
1503
1595
|
},
|
|
1504
1596
|
{
|
|
1505
1597
|
"type": "REPEAT",
|
|
@@ -1512,10 +1604,22 @@
|
|
|
1512
1604
|
},
|
|
1513
1605
|
{
|
|
1514
1606
|
"type": "SYMBOL",
|
|
1515
|
-
"name": "
|
|
1607
|
+
"name": "generic"
|
|
1516
1608
|
}
|
|
1517
1609
|
]
|
|
1518
1610
|
}
|
|
1611
|
+
},
|
|
1612
|
+
{
|
|
1613
|
+
"type": "CHOICE",
|
|
1614
|
+
"members": [
|
|
1615
|
+
{
|
|
1616
|
+
"type": "STRING",
|
|
1617
|
+
"value": ","
|
|
1618
|
+
},
|
|
1619
|
+
{
|
|
1620
|
+
"type": "BLANK"
|
|
1621
|
+
}
|
|
1622
|
+
]
|
|
1519
1623
|
}
|
|
1520
1624
|
]
|
|
1521
1625
|
},
|
|
@@ -1525,6 +1629,10 @@
|
|
|
1525
1629
|
}
|
|
1526
1630
|
]
|
|
1527
1631
|
},
|
|
1632
|
+
"generic": {
|
|
1633
|
+
"type": "PATTERN",
|
|
1634
|
+
"value": "[a-z][a-z]*"
|
|
1635
|
+
},
|
|
1528
1636
|
"float": {
|
|
1529
1637
|
"type": "PATTERN",
|
|
1530
1638
|
"value": "-?[0-9_]+\\.[0-9_]*(e-?[0-9_]+)?"
|
|
@@ -1652,6 +1760,31 @@
|
|
|
1652
1760
|
"type": "SYMBOL",
|
|
1653
1761
|
"name": "_upname"
|
|
1654
1762
|
},
|
|
1763
|
+
"remote_type_identifier": {
|
|
1764
|
+
"type": "SEQ",
|
|
1765
|
+
"members": [
|
|
1766
|
+
{
|
|
1767
|
+
"type": "FIELD",
|
|
1768
|
+
"name": "module",
|
|
1769
|
+
"content": {
|
|
1770
|
+
"type": "SYMBOL",
|
|
1771
|
+
"name": "identifier"
|
|
1772
|
+
}
|
|
1773
|
+
},
|
|
1774
|
+
{
|
|
1775
|
+
"type": "STRING",
|
|
1776
|
+
"value": "."
|
|
1777
|
+
},
|
|
1778
|
+
{
|
|
1779
|
+
"type": "FIELD",
|
|
1780
|
+
"name": "name",
|
|
1781
|
+
"content": {
|
|
1782
|
+
"type": "SYMBOL",
|
|
1783
|
+
"name": "type_identifier"
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
]
|
|
1787
|
+
},
|
|
1655
1788
|
"_type_annotation": {
|
|
1656
1789
|
"type": "SEQ",
|
|
1657
1790
|
"members": [
|
|
@@ -1664,11 +1797,28 @@
|
|
|
1664
1797
|
"name": "type",
|
|
1665
1798
|
"content": {
|
|
1666
1799
|
"type": "SYMBOL",
|
|
1667
|
-
"name": "
|
|
1800
|
+
"name": "_type"
|
|
1668
1801
|
}
|
|
1669
1802
|
}
|
|
1670
1803
|
]
|
|
1671
1804
|
},
|
|
1805
|
+
"_type": {
|
|
1806
|
+
"type": "CHOICE",
|
|
1807
|
+
"members": [
|
|
1808
|
+
{
|
|
1809
|
+
"type": "SYMBOL",
|
|
1810
|
+
"name": "type"
|
|
1811
|
+
},
|
|
1812
|
+
{
|
|
1813
|
+
"type": "SYMBOL",
|
|
1814
|
+
"name": "generic"
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
"type": "SYMBOL",
|
|
1818
|
+
"name": "function_type"
|
|
1819
|
+
}
|
|
1820
|
+
]
|
|
1821
|
+
},
|
|
1672
1822
|
"_discard_name": {
|
|
1673
1823
|
"type": "PATTERN",
|
|
1674
1824
|
"value": "_[_0-9a-z]*"
|
src/node-types.json
CHANGED
|
@@ -31,17 +31,9 @@
|
|
|
31
31
|
"type": "negation",
|
|
32
32
|
"named": true
|
|
33
33
|
},
|
|
34
|
-
{
|
|
35
|
-
"type": "panic",
|
|
36
|
-
"named": true
|
|
37
|
-
},
|
|
38
34
|
{
|
|
39
35
|
"type": "string",
|
|
40
36
|
"named": true
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"type": "todo",
|
|
44
|
-
"named": true
|
|
45
37
|
}
|
|
46
38
|
]
|
|
47
39
|
},
|
|
@@ -140,15 +132,71 @@
|
|
|
140
132
|
"named": true
|
|
141
133
|
},
|
|
142
134
|
{
|
|
143
|
-
"type": "
|
|
135
|
+
"type": "string",
|
|
144
136
|
"named": true
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"type": "enum",
|
|
144
|
+
"named": true,
|
|
145
|
+
"fields": {
|
|
146
|
+
"fields": {
|
|
147
|
+
"multiple": true,
|
|
148
|
+
"required": true,
|
|
149
|
+
"types": [
|
|
150
|
+
{
|
|
151
|
+
"type": "(",
|
|
152
|
+
"named": false
|
|
145
153
|
},
|
|
146
154
|
{
|
|
155
|
+
"type": ")",
|
|
156
|
+
"named": false
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"type": ",",
|
|
160
|
+
"named": false
|
|
161
|
+
},
|
|
162
|
+
{
|
|
147
|
-
"type": "
|
|
163
|
+
"type": "field",
|
|
164
|
+
"named": true
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"type": "identifier",
|
|
148
168
|
"named": true
|
|
149
169
|
},
|
|
150
170
|
{
|
|
171
|
+
"type": "type_identifier",
|
|
172
|
+
"named": true
|
|
173
|
+
},
|
|
174
|
+
{
|
|
151
|
-
"type": "
|
|
175
|
+
"type": "{",
|
|
176
|
+
"named": false
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"type": "}",
|
|
180
|
+
"named": false
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
"generics": {
|
|
185
|
+
"multiple": false,
|
|
186
|
+
"required": false,
|
|
187
|
+
"types": [
|
|
188
|
+
{
|
|
189
|
+
"type": "generics",
|
|
190
|
+
"named": true
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
"name": {
|
|
195
|
+
"multiple": true,
|
|
196
|
+
"required": true,
|
|
197
|
+
"types": [
|
|
198
|
+
{
|
|
199
|
+
"type": "type_identifier",
|
|
152
200
|
"named": true
|
|
153
201
|
}
|
|
154
202
|
]
|
|
@@ -191,21 +239,47 @@
|
|
|
191
239
|
"type": "negation",
|
|
192
240
|
"named": true
|
|
193
241
|
},
|
|
194
|
-
{
|
|
195
|
-
"type": "panic",
|
|
196
|
-
"named": true
|
|
197
|
-
},
|
|
198
242
|
{
|
|
199
243
|
"type": "string",
|
|
200
244
|
"named": true
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
"type": "todo",
|
|
204
|
-
"named": true
|
|
205
245
|
}
|
|
206
246
|
]
|
|
207
247
|
}
|
|
208
248
|
},
|
|
249
|
+
{
|
|
250
|
+
"type": "field",
|
|
251
|
+
"named": true,
|
|
252
|
+
"fields": {
|
|
253
|
+
"name": {
|
|
254
|
+
"multiple": false,
|
|
255
|
+
"required": true,
|
|
256
|
+
"types": [
|
|
257
|
+
{
|
|
258
|
+
"type": "identifier",
|
|
259
|
+
"named": true
|
|
260
|
+
}
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
"type": {
|
|
264
|
+
"multiple": false,
|
|
265
|
+
"required": true,
|
|
266
|
+
"types": [
|
|
267
|
+
{
|
|
268
|
+
"type": "function_type",
|
|
269
|
+
"named": true
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"type": "generic",
|
|
273
|
+
"named": true
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"type": "type",
|
|
277
|
+
"named": true
|
|
278
|
+
}
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
},
|
|
209
283
|
{
|
|
210
284
|
"type": "function",
|
|
211
285
|
"named": true,
|
|
@@ -242,18 +316,10 @@
|
|
|
242
316
|
"type": "negation",
|
|
243
317
|
"named": true
|
|
244
318
|
},
|
|
245
|
-
{
|
|
246
|
-
"type": "panic",
|
|
247
|
-
"named": true
|
|
248
|
-
},
|
|
249
319
|
{
|
|
250
320
|
"type": "string",
|
|
251
321
|
"named": true
|
|
252
322
|
},
|
|
253
|
-
{
|
|
254
|
-
"type": "todo",
|
|
255
|
-
"named": true
|
|
256
|
-
},
|
|
257
323
|
{
|
|
258
324
|
"type": "{",
|
|
259
325
|
"named": false
|
|
@@ -291,14 +357,14 @@
|
|
|
291
357
|
"named": false
|
|
292
358
|
},
|
|
293
359
|
{
|
|
294
|
-
"type": "
|
|
360
|
+
"type": "field",
|
|
295
361
|
"named": true
|
|
296
362
|
}
|
|
297
363
|
]
|
|
298
364
|
},
|
|
299
|
-
"
|
|
365
|
+
"return": {
|
|
300
366
|
"multiple": false,
|
|
301
|
-
"required":
|
|
367
|
+
"required": true,
|
|
302
368
|
"types": [
|
|
303
369
|
{
|
|
304
370
|
"type": "return_type",
|
|
@@ -309,7 +375,56 @@
|
|
|
309
375
|
}
|
|
310
376
|
},
|
|
311
377
|
{
|
|
378
|
+
"type": "function_parameter_types",
|
|
379
|
+
"named": true,
|
|
380
|
+
"fields": {},
|
|
381
|
+
"children": {
|
|
382
|
+
"multiple": true,
|
|
383
|
+
"required": false,
|
|
384
|
+
"types": [
|
|
385
|
+
{
|
|
386
|
+
"type": "function_type",
|
|
387
|
+
"named": true
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"type": "generic",
|
|
391
|
+
"named": true
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"type": "type",
|
|
395
|
+
"named": true
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"type": "function_type",
|
|
402
|
+
"named": true,
|
|
403
|
+
"fields": {
|
|
404
|
+
"parameter_types": {
|
|
405
|
+
"multiple": false,
|
|
406
|
+
"required": false,
|
|
407
|
+
"types": [
|
|
408
|
+
{
|
|
409
|
+
"type": "function_parameter_types",
|
|
410
|
+
"named": true
|
|
411
|
+
}
|
|
412
|
+
]
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
"children": {
|
|
416
|
+
"multiple": false,
|
|
417
|
+
"required": false,
|
|
418
|
+
"types": [
|
|
419
|
+
{
|
|
420
|
+
"type": "return_type",
|
|
421
|
+
"named": true
|
|
422
|
+
}
|
|
423
|
+
]
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
{
|
|
312
|
-
"type": "
|
|
427
|
+
"type": "generics",
|
|
313
428
|
"named": true,
|
|
314
429
|
"fields": {},
|
|
315
430
|
"children": {
|
|
@@ -317,7 +432,7 @@
|
|
|
317
432
|
"required": true,
|
|
318
433
|
"types": [
|
|
319
434
|
{
|
|
320
|
-
"type": "
|
|
435
|
+
"type": "generic",
|
|
321
436
|
"named": true
|
|
322
437
|
}
|
|
323
438
|
]
|
|
@@ -413,7 +528,15 @@
|
|
|
413
528
|
"required": false,
|
|
414
529
|
"types": [
|
|
415
530
|
{
|
|
531
|
+
"type": "function_type",
|
|
532
|
+
"named": true
|
|
533
|
+
},
|
|
534
|
+
{
|
|
416
|
-
"type": "
|
|
535
|
+
"type": "generic",
|
|
536
|
+
"named": true
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
"type": "type",
|
|
417
540
|
"named": true
|
|
418
541
|
}
|
|
419
542
|
]
|
|
@@ -446,17 +569,9 @@
|
|
|
446
569
|
"type": "negation",
|
|
447
570
|
"named": true
|
|
448
571
|
},
|
|
449
|
-
{
|
|
450
|
-
"type": "panic",
|
|
451
|
-
"named": true
|
|
452
|
-
},
|
|
453
572
|
{
|
|
454
573
|
"type": "string",
|
|
455
574
|
"named": true
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
"type": "todo",
|
|
459
|
-
"named": true
|
|
460
575
|
}
|
|
461
576
|
]
|
|
462
577
|
}
|
|
@@ -511,37 +626,9 @@
|
|
|
511
626
|
"type": "negation",
|
|
512
627
|
"named": true
|
|
513
628
|
},
|
|
514
|
-
{
|
|
515
|
-
"type": "panic",
|
|
516
|
-
"named": true
|
|
517
|
-
},
|
|
518
629
|
{
|
|
519
630
|
"type": "string",
|
|
520
631
|
"named": true
|
|
521
|
-
},
|
|
522
|
-
{
|
|
523
|
-
"type": "todo",
|
|
524
|
-
"named": true
|
|
525
|
-
}
|
|
526
|
-
]
|
|
527
|
-
}
|
|
528
|
-
},
|
|
529
|
-
{
|
|
530
|
-
"type": "panic",
|
|
531
|
-
"named": true,
|
|
532
|
-
"fields": {}
|
|
533
|
-
},
|
|
534
|
-
{
|
|
535
|
-
"type": "record",
|
|
536
|
-
"named": true,
|
|
537
|
-
"fields": {},
|
|
538
|
-
"children": {
|
|
539
|
-
"multiple": true,
|
|
540
|
-
"required": true,
|
|
541
|
-
"types": [
|
|
542
|
-
{
|
|
543
|
-
"type": "type_field",
|
|
544
|
-
"named": true
|
|
545
632
|
}
|
|
546
633
|
]
|
|
547
634
|
}
|
|
@@ -550,34 +637,20 @@
|
|
|
550
637
|
"type": "return_type",
|
|
551
638
|
"named": true,
|
|
552
639
|
"fields": {
|
|
553
|
-
"
|
|
640
|
+
"return_type": {
|
|
554
|
-
"multiple":
|
|
641
|
+
"multiple": false,
|
|
555
|
-
"required":
|
|
642
|
+
"required": true,
|
|
556
643
|
"types": [
|
|
557
644
|
{
|
|
558
|
-
"type": "
|
|
645
|
+
"type": "function_type",
|
|
559
|
-
"named":
|
|
646
|
+
"named": true
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
"type": ")",
|
|
563
|
-
"named": false
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
"type": ",",
|
|
567
|
-
"named": false
|
|
568
647
|
},
|
|
569
648
|
{
|
|
570
|
-
"type": "
|
|
649
|
+
"type": "generic",
|
|
571
650
|
"named": true
|
|
572
|
-
}
|
|
573
|
-
]
|
|
574
|
-
|
|
651
|
+
},
|
|
575
|
-
"name": {
|
|
576
|
-
"multiple": false,
|
|
577
|
-
"required": true,
|
|
578
|
-
"types": [
|
|
579
652
|
{
|
|
580
|
-
"type": "
|
|
653
|
+
"type": "type",
|
|
581
654
|
"named": true
|
|
582
655
|
}
|
|
583
656
|
]
|
|
@@ -592,6 +665,10 @@
|
|
|
592
665
|
"multiple": true,
|
|
593
666
|
"required": true,
|
|
594
667
|
"types": [
|
|
668
|
+
{
|
|
669
|
+
"type": "enum",
|
|
670
|
+
"named": true
|
|
671
|
+
},
|
|
595
672
|
{
|
|
596
673
|
"type": "function",
|
|
597
674
|
"named": true
|
|
@@ -605,7 +682,7 @@
|
|
|
605
682
|
"named": true
|
|
606
683
|
},
|
|
607
684
|
{
|
|
608
|
-
"type": "
|
|
685
|
+
"type": "struct",
|
|
609
686
|
"named": true
|
|
610
687
|
}
|
|
611
688
|
]
|
|
@@ -631,31 +708,33 @@
|
|
|
631
708
|
}
|
|
632
709
|
},
|
|
633
710
|
{
|
|
634
|
-
"type": "
|
|
711
|
+
"type": "struct",
|
|
635
712
|
"named": true,
|
|
636
713
|
"fields": {
|
|
637
|
-
"
|
|
714
|
+
"fields": {
|
|
638
|
-
"multiple":
|
|
715
|
+
"multiple": true,
|
|
639
|
-
"required":
|
|
716
|
+
"required": true,
|
|
640
717
|
"types": [
|
|
641
718
|
{
|
|
719
|
+
"type": "(",
|
|
720
|
+
"named": false
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
"type": ")",
|
|
724
|
+
"named": false
|
|
725
|
+
},
|
|
726
|
+
{
|
|
642
|
-
"type": "
|
|
727
|
+
"type": "field",
|
|
643
728
|
"named": true
|
|
644
729
|
}
|
|
645
730
|
]
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
|
|
731
|
+
},
|
|
649
|
-
{
|
|
650
|
-
"type": "type",
|
|
651
|
-
"named": true,
|
|
652
|
-
"fields": {
|
|
653
732
|
"generics": {
|
|
654
733
|
"multiple": false,
|
|
655
734
|
"required": false,
|
|
656
735
|
"types": [
|
|
657
736
|
{
|
|
658
|
-
"type": "
|
|
737
|
+
"type": "generics",
|
|
659
738
|
"named": true
|
|
660
739
|
}
|
|
661
740
|
]
|
|
@@ -669,57 +748,29 @@
|
|
|
669
748
|
"named": true
|
|
670
749
|
}
|
|
671
750
|
]
|
|
672
|
-
},
|
|
673
|
-
"record": {
|
|
674
|
-
"multiple": false,
|
|
675
|
-
"required": false,
|
|
676
|
-
"types": [
|
|
677
|
-
{
|
|
678
|
-
"type": "record",
|
|
679
|
-
"named": true
|
|
680
|
-
}
|
|
681
|
-
]
|
|
682
|
-
},
|
|
683
|
-
"union": {
|
|
684
|
-
"multiple": true,
|
|
685
|
-
"required": false,
|
|
686
|
-
"types": [
|
|
687
|
-
{
|
|
688
|
-
"type": "=",
|
|
689
|
-
"named": false
|
|
690
|
-
},
|
|
691
|
-
{
|
|
692
|
-
"type": "union",
|
|
693
|
-
"named": true
|
|
694
|
-
},
|
|
695
|
-
{
|
|
696
|
-
"type": "|",
|
|
697
|
-
"named": false
|
|
698
|
-
}
|
|
699
|
-
]
|
|
700
751
|
}
|
|
701
752
|
}
|
|
702
753
|
},
|
|
703
754
|
{
|
|
704
|
-
"type": "
|
|
755
|
+
"type": "type",
|
|
705
756
|
"named": true,
|
|
706
757
|
"fields": {
|
|
707
|
-
"
|
|
758
|
+
"arguments": {
|
|
708
759
|
"multiple": false,
|
|
709
|
-
"required":
|
|
760
|
+
"required": false,
|
|
710
761
|
"types": [
|
|
711
762
|
{
|
|
712
|
-
"type": "
|
|
763
|
+
"type": "type_arguments",
|
|
713
764
|
"named": true
|
|
714
765
|
}
|
|
715
766
|
]
|
|
716
767
|
},
|
|
717
|
-
"
|
|
768
|
+
"name": {
|
|
718
769
|
"multiple": false,
|
|
719
770
|
"required": true,
|
|
720
771
|
"types": [
|
|
721
772
|
{
|
|
722
|
-
"type": "
|
|
773
|
+
"type": "type_identifier",
|
|
723
774
|
"named": true
|
|
724
775
|
}
|
|
725
776
|
]
|
|
@@ -727,40 +778,48 @@
|
|
|
727
778
|
}
|
|
728
779
|
},
|
|
729
780
|
{
|
|
730
|
-
"type": "
|
|
781
|
+
"type": "type_argument",
|
|
731
782
|
"named": true,
|
|
732
|
-
"fields": {}
|
|
783
|
+
"fields": {},
|
|
784
|
+
"children": {
|
|
785
|
+
"multiple": false,
|
|
786
|
+
"required": true,
|
|
787
|
+
"types": [
|
|
788
|
+
{
|
|
789
|
+
"type": "function_type",
|
|
790
|
+
"named": true
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
"type": "generic",
|
|
794
|
+
"named": true
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
"type": "type",
|
|
798
|
+
"named": true
|
|
799
|
+
}
|
|
800
|
+
]
|
|
801
|
+
}
|
|
733
802
|
},
|
|
734
803
|
{
|
|
735
|
-
"type": "
|
|
804
|
+
"type": "type_arguments",
|
|
736
805
|
"named": true,
|
|
737
|
-
"fields": {
|
|
806
|
+
"fields": {},
|
|
738
|
-
"name": {
|
|
739
|
-
"multiple": false,
|
|
740
|
-
"required": true,
|
|
741
|
-
"types": [
|
|
742
|
-
{
|
|
743
|
-
"type": "type_identifier",
|
|
744
|
-
"named": true
|
|
745
|
-
}
|
|
746
|
-
]
|
|
747
|
-
}
|
|
748
|
-
},
|
|
749
807
|
"children": {
|
|
750
808
|
"multiple": true,
|
|
751
809
|
"required": false,
|
|
752
810
|
"types": [
|
|
753
811
|
{
|
|
754
|
-
"type": "identifier",
|
|
755
|
-
"named": true
|
|
756
|
-
},
|
|
757
|
-
{
|
|
758
|
-
"type": "
|
|
812
|
+
"type": "type_argument",
|
|
759
813
|
"named": true
|
|
760
814
|
}
|
|
761
815
|
]
|
|
762
816
|
}
|
|
763
817
|
},
|
|
818
|
+
{
|
|
819
|
+
"type": "type_identifier",
|
|
820
|
+
"named": true,
|
|
821
|
+
"fields": {}
|
|
822
|
+
},
|
|
764
823
|
{
|
|
765
824
|
"type": "unqualified_import",
|
|
766
825
|
"named": true,
|
|
@@ -914,6 +973,10 @@
|
|
|
914
973
|
"type": "fn",
|
|
915
974
|
"named": false
|
|
916
975
|
},
|
|
976
|
+
{
|
|
977
|
+
"type": "generic",
|
|
978
|
+
"named": true
|
|
979
|
+
},
|
|
917
980
|
{
|
|
918
981
|
"type": "identifier",
|
|
919
982
|
"named": true
|
|
@@ -930,18 +993,10 @@
|
|
|
930
993
|
"type": "module",
|
|
931
994
|
"named": false
|
|
932
995
|
},
|
|
933
|
-
{
|
|
934
|
-
"type": "panic",
|
|
935
|
-
"named": false
|
|
936
|
-
},
|
|
937
996
|
{
|
|
938
997
|
"type": "quoted_content",
|
|
939
998
|
"named": true
|
|
940
999
|
},
|
|
941
|
-
{
|
|
942
|
-
"type": "todo",
|
|
943
|
-
"named": false
|
|
944
|
-
},
|
|
945
1000
|
{
|
|
946
1001
|
"type": "type",
|
|
947
1002
|
"named": false
|
|
@@ -950,10 +1005,6 @@
|
|
|
950
1005
|
"type": "{",
|
|
951
1006
|
"named": false
|
|
952
1007
|
},
|
|
953
|
-
{
|
|
954
|
-
"type": "|",
|
|
955
|
-
"named": false
|
|
956
|
-
},
|
|
957
1008
|
{
|
|
958
1009
|
"type": "|>",
|
|
959
1010
|
"named": false
|
test/corpus/type.txt
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
================================================================================
|
|
2
|
-
Type - Simple
|
|
3
|
-
================================================================================
|
|
4
|
-
|
|
5
|
-
module palm
|
|
6
|
-
|
|
7
|
-
type User = Guest | LoggedIn(name: String, session_id: String)
|
|
8
|
-
|
|
9
|
-
type Cat(
|
|
10
|
-
firstName: String,
|
|
11
|
-
middleName: String,
|
|
12
|
-
lastName: String,
|
|
13
|
-
age: Int
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
--------------------------------------------------------------------------------
|
|
17
|
-
|
|
18
|
-
(source_file
|
|
19
|
-
(module
|
|
20
|
-
(module_name))
|
|
21
|
-
(type
|
|
22
|
-
(type_identifier)
|
|
23
|
-
(union
|
|
24
|
-
(type_identifier))
|
|
25
|
-
(union
|
|
26
|
-
(type_identifier)
|
|
27
|
-
(type_field
|
|
28
|
-
(identifier)
|
|
29
|
-
(identifier))
|
|
30
|
-
(type_field
|
|
31
|
-
(identifier)
|
|
32
|
-
(identifier))))
|
|
33
|
-
(type
|
|
34
|
-
(type_identifier)
|
|
35
|
-
(record
|
|
36
|
-
(type_field
|
|
37
|
-
(identifier)
|
|
38
|
-
(identifier))
|
|
39
|
-
(type_field
|
|
40
|
-
(identifier)
|
|
41
|
-
(identifier))
|
|
42
|
-
(type_field
|
|
43
|
-
(identifier)
|
|
44
|
-
(identifier))
|
|
45
|
-
(type_field
|
|
46
|
-
(identifier)
|
|
47
|
-
(identifier)))))
|
|
48
|
-
|
|
49
|
-
================================================================================
|
|
50
|
-
Type - Generic
|
|
51
|
-
================================================================================
|
|
52
|
-
|
|
53
|
-
module palm
|
|
54
|
-
|
|
55
|
-
type User(a) = Guest | LoggedIn(name: a, age: Int)
|
|
56
|
-
|
|
57
|
-
type Option(a) = Some(a) | None
|
|
58
|
-
|
|
59
|
-
type Result(a, b) = Ok(a) | Error(b)
|
|
60
|
-
|
|
61
|
-
type Cat(a)(
|
|
62
|
-
name: a,
|
|
63
|
-
age: Int
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
--------------------------------------------------------------------------------
|
|
67
|
-
|
|
68
|
-
(source_file
|
|
69
|
-
(module
|
|
70
|
-
(module_name))
|
|
71
|
-
(type
|
|
72
|
-
(type_identifier)
|
|
73
|
-
(generic_list
|
|
74
|
-
(identifier))
|
|
75
|
-
(union
|
|
76
|
-
(type_identifier))
|
|
77
|
-
(union
|
|
78
|
-
(type_identifier)
|
|
79
|
-
(type_field
|
|
80
|
-
(identifier)
|
|
81
|
-
(identifier))
|
|
82
|
-
(type_field
|
|
83
|
-
(identifier)
|
|
84
|
-
(identifier))))
|
|
85
|
-
(type
|
|
86
|
-
(type_identifier)
|
|
87
|
-
(generic_list
|
|
88
|
-
(identifier))
|
|
89
|
-
(union
|
|
90
|
-
(type_identifier)
|
|
91
|
-
(identifier))
|
|
92
|
-
(union
|
|
93
|
-
(type_identifier)))
|
|
94
|
-
(type
|
|
95
|
-
(type_identifier)
|
|
96
|
-
(generic_list
|
|
97
|
-
(identifier)
|
|
98
|
-
(identifier))
|
|
99
|
-
(union
|
|
100
|
-
(type_identifier)
|
|
101
|
-
(identifier))
|
|
102
|
-
(union
|
|
103
|
-
(type_identifier)
|
|
104
|
-
(identifier)))
|
|
105
|
-
(type
|
|
106
|
-
(type_identifier)
|
|
107
|
-
(generic_list
|
|
108
|
-
(identifier))
|
|
109
|
-
(record
|
|
110
|
-
(type_field
|
|
111
|
-
(identifier)
|
|
112
|
-
(identifier))
|
|
113
|
-
(type_field
|
|
114
|
-
(identifier)
|
|
115
|
-
(identifier)))))
|
test/corpus/types.txt
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
================================================================================
|
|
2
|
+
Types
|
|
3
|
+
================================================================================
|
|
4
|
+
|
|
5
|
+
module palm
|
|
6
|
+
|
|
7
|
+
type User(a) {
|
|
8
|
+
Guest
|
|
9
|
+
LoggedIn(name: a, age: Int)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type Result(a, b) {
|
|
13
|
+
Ok(a)
|
|
14
|
+
Error(b)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Cat(a)(
|
|
18
|
+
firstName: String
|
|
19
|
+
middleName: String
|
|
20
|
+
lastName: String
|
|
21
|
+
age: Int
|
|
22
|
+
shape: a
|
|
23
|
+
call: fn (String) -> String
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
--------------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
(source_file
|
|
29
|
+
(module
|
|
30
|
+
(module_name))
|
|
31
|
+
(enum
|
|
32
|
+
(type_identifier)
|
|
33
|
+
(generics
|
|
34
|
+
(generic))
|
|
35
|
+
(type_identifier)
|
|
36
|
+
(type_identifier)
|
|
37
|
+
(field
|
|
38
|
+
(identifier)
|
|
39
|
+
(generic))
|
|
40
|
+
(field
|
|
41
|
+
(identifier)
|
|
42
|
+
(type
|
|
43
|
+
(type_identifier))))
|
|
44
|
+
(enum
|
|
45
|
+
(type_identifier)
|
|
46
|
+
(generics
|
|
47
|
+
(generic)
|
|
48
|
+
(generic))
|
|
49
|
+
(type_identifier)
|
|
50
|
+
(identifier)
|
|
51
|
+
(type_identifier)
|
|
52
|
+
(identifier))
|
|
53
|
+
(struct
|
|
54
|
+
(type_identifier)
|
|
55
|
+
(generics
|
|
56
|
+
(generic))
|
|
57
|
+
(field
|
|
58
|
+
(identifier)
|
|
59
|
+
(type
|
|
60
|
+
(type_identifier)))
|
|
61
|
+
(field
|
|
62
|
+
(identifier)
|
|
63
|
+
(type
|
|
64
|
+
(type_identifier)))
|
|
65
|
+
(field
|
|
66
|
+
(identifier)
|
|
67
|
+
(type
|
|
68
|
+
(type_identifier)))
|
|
69
|
+
(field
|
|
70
|
+
(identifier)
|
|
71
|
+
(type
|
|
72
|
+
(type_identifier)))
|
|
73
|
+
(field
|
|
74
|
+
(identifier)
|
|
75
|
+
(generic))
|
|
76
|
+
(field
|
|
77
|
+
(identifier)
|
|
78
|
+
(function_type
|
|
79
|
+
(function_parameter_types
|
|
80
|
+
(type
|
|
81
|
+
(type_identifier)))
|
|
82
|
+
(return_type
|
|
83
|
+
(type
|
|
84
|
+
(type_identifier)))))))
|
|
85
|
+
|