Lambda expressions in PEG.js

224 views Asked by At

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?

1

There are 1 answers

2
bfavaretto On

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

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