Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lambda expressions in PEG.js

I have PEG grammar problem with lambda expressions, they work if I use syntax:

x:{y:{x+y}}(20)(30)

which is equivalent of

(function(x) { return function(y) { return x+y; }; })(20)(30);

but this don't work

f:{f(10)}(x:{x*x})

which is equivalent of:

(function(f) { return f(10); })(function(x) { return x*x; })

Is it possible to make that second function work with PEG.js?

like image 873
jcubic Avatar asked Jul 26 '26 11:07

jcubic


1 Answers

After some trial and error on the online grammar parser, I found that this works:

f:{f}(x:{x*x})(10)
like image 169
bfavaretto Avatar answered Jul 28 '26 00:07

bfavaretto