OMeta Test

grammar

ometa Calc {
  digit    = super(#digit):d          -> d.digitValue(),
  number   = number:n digit:d         -> (n * 10 + d)
           | digit,
  addExpr  = addExpr:x '+' mulExpr:y  -> (x + y)
           | addExpr:x '-' mulExpr:y  -> (x - y)
           | mulExpr,
  mulExpr  = mulExpr:x '*' primExpr:y -> (x * y)
           | mulExpr:x '/' primExpr:y -> (x / y)
           | primExpr,
  primExpr = '(' expr:x ')'           -> x
           | number,
  expr     = addExpr
}

source

Calc.matchAll('6*(4+3)', 'expr')

answer