pest icon indicating copy to clipboard operation
pest copied to clipboard

PrecClimber prefix/suffix support

Open CraftSpider opened this issue 4 years ago • 0 comments

It would be nice if PrecClimber, or a variant of it, could have support for prefix/suffix operators. Currently it requires copying over the code and implementing it yourself, which while possible, increases the chance for bugs and the difficulty on the library user.

Possible API for a new climber:

  • Add a new operator type, Infix, Prefix and Suffix or similar
  • Add prefix and postfix closure parameters to climb
  • Prefix doesn't expect an shs
  • Postfix doesn't expect an rhs

With this new climber, one could easily parse a syntax roughly like

expr = {
    prefix_ops* ~ target ~ suffix_ops* ~ (infix_op ~ prefix_ops* ~ target ~ suffix_ops*)*
}

CraftSpider avatar Jul 09 '21 18:07 CraftSpider