// first, let's see what functions and function calls look like BSJSParser.matchAll("function(x) { foo(); return x + 1 }", "srcElem") // now we know enough to extend our JS with a BCPL-inspired valof expression oldBSJSParser = BSJSParser ometa newBSJSParser <: oldBSJSParser { isKeyword :x = ?(x == 'valof') | super(`isKeyword, x), expr = "valof" "{" valofBody:r "}" -> r | super(`expr), valofBody = notLast(`srcElem)*:ss expr:r sc -> { ss.push([`return, r]) [`call, [`func, [], [`begin].concat(ss)]] } } newBSJSParser.matchAll("f = function(x) { return valof { x++; x * x } }", "srcElem")