ohm icon indicating copy to clipboard operation
ohm copied to clipboard

Allow a semantics to be passed an input string OR a matchResult.

Open pdubroy opened this issue 9 years ago • 1 comments

Since a semantics instance is always associated with a particular, concrete grammar, we could support a shorthand that avoids calling g.match:

var g = ohm.grammar('Arithmetic { ... }');
s = g.semantics().addOperation('eval()', { ... });
s('1 + 2').eval();

If the input fails to match, I guess it would have to throw an exception.

pdubroy avatar May 20 '16 14:05 pdubroy

I guess that makes sense without the object matching now.

mroeder avatar May 20 '16 16:05 mroeder

Don't think we need this — closing.

pdubroy avatar Nov 07 '22 08:11 pdubroy