kschiess / parslet

A small PEG based parser library. See the Hacking page in the Wiki as well.
kschiess.github.com/parslet
MIT License
809 stars 95 forks source link

Precedences in`infix_expression` #207

Open schuetzm opened 4 years ago

schuetzm commented 4 years ago

It seems currently the precedences in infix_expression need to be > 0; when you use 0 for an operator, it fails to parse it correctly. As far as I can tell this is caused by the default value of current_prec = 1 in https://github.com/kschiess/parslet/blob/master/lib/parslet/atoms/infix.rb#L51. This could be set to 0, or even -Float::INFINITY, to support even negative precedences (which can come in handy when you want to add a low precedence operator and don't want to adjust all the existing precedences).