Skip to content

Commit 415c3fc

Browse files
committed
parser: Change lambda syntax - use expression_list / statement_block instead of statement / expression_list
1 parent ae8c755 commit 415c3fc

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

fusion/core/parser.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ local pattern = re.compile([[
149149
return <- {| {:type: {'return' / 'yield'} :} ws expression_list? |}
150150
151151
lambda <- {| {:type: '' -> 'lambda' :}
152-
'\' ws lambda_args? ws is_self '>' ws (statement / expression_list / r)
152+
'\' ws lambda_args? ws is_self '>' ws (expression_list / statement_block /
153+
r)
153154
|}
154155
lambda_args <- {| lambda_arg (ws ',' ws lambda_arg)* |}
155156
lambda_arg <- {| {:name: name / '...' :} |}

spec/in/functions.fuse

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,19 @@ abcd.ef()=> {
4646

4747
}
4848

49+
a[b]()-> {
50+
51+
}
52+
53+
-- lambdas
54+
4955
x = \-> {
5056
return y;
5157
};
5258

53-
y = \-> z;
54-
55-
a[b]()-> {
59+
a = \-> x();
5660

57-
}
61+
y = \-> z;
5862

5963
-- arguments for functions --
6064

spec/out/source/functions.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,19 @@ function x()
3434
end
3535
function abcd.ef(self)
3636

37+
end
38+
a[b] = function()
39+
3740
end
3841
x = (function()
3942
return y
4043
end)
44+
a = (function()
45+
return x()
46+
end)
4147
y = (function()
4248
return z
4349
end)
44-
a[b] = function()
45-
46-
end
4750
function a(b, c, d, ...)
4851
if not d then
4952
d = 5

0 commit comments

Comments
 (0)