/* OMeta/JS now supports memoization for parameterized rules -- all you have to do is invoke your grammar's memoizeParameterizedRules method, as shown below. This even works for left-recursive rules! In order to keep the semantics sensible, I have limited this memoization to immutable arguments, i.e., booleans, numbers, and strings. If you don't like this restriction, it's easy to eliminate it. Just look at the implementation of the memoizeParameterizedRules method in ometa-base.js. (You can make your own variant of this method that doesn't restrict memoization to immutable arguments.) -- Alex */ ometa M { add :x :y = {alert("adding " + x + " and " + y)} -> (x + y), start = add(1, 2) } M.memoizeParameterizedRules() M.matchAll("", "start") ometa M { lrListOf :x = lrListOf(x):xs exactly(x):x -> [xs, x] | exactly(x), start = lrListOf('a'):as lrListOf('b'):bs -> [as, bs] } M.memoizeParameterizedRules() M.matchAll("aaaabbb", "start") ometa Fib { fib 0 -> 1, fib 1 -> 1, fib :n = fib(n - 1):x fib(n - 2):y -> (x + y) } Fib.memoizeParameterizedRules() Fib.match(30, "fib")