ometa RPN <: Parser { sign = '+' -> true | '-' -> false | -> true, nonzero_digit = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9', digits = nonzero_digit:firstDigit digit*:digits -> parseInt([firstDigit].concat(digits).join('')), number = '0' -> 0 | sign:isPos digits:digits -> (isPos ? digits : -digits), numberTok = token(#number), binop = "+" -> (function(x, y) { return x + y; }) | "-" -> (function(x, y) { return x - y; }) | "*" -> (function(x, y) { return x * y; }) | "/" -> (function(x, y) { return x / y; }), expr = token(#number):n -> n | binop:opfn expr:e1 expr:e2 -> opfn(e1, e2) } RPN.matchAll('123', 'expr') // just thought I'd give you a little push... -Alex