I would like to add a new high-precedence binary operator to the parser, and I was wondering if somebody can point me to an example if there’s one.
My (possibly-inadvisable) use case is I want to build a templating language that is compatible with Twig / Liquid / Jinja / Nunjucks, and they all use the
| character to signify filters, as in:
array | batch(3)
So far Acorn is working splendidly to spare me from re-implementing an expression parser, and baking this operator would let me use Acorn exclusively.
(Of course, the
| operator already exists in ECMAScript, but I’d replace it to something else prior to parsing.)
Edit: One place I think I can start from is the commit that adds the exponentiation operator?