Commit graph

7 commits

Author SHA1 Message Date
Bruno BELANYI f7c8413e3c evalexpr: introduce single op_kind enum
This will allow making the precendence climbing cleaner
2020-11-02 16:13:33 +01:00
Bruno BELANYI 32d17134cd evalexpr: parse: parse operand more correctly
I noted that the `right_prec` and `next_prec` functions taking a
character only work because prefix operators come after infix operators
in the table. We should compare the *actual* operator kind, which would
probably need a single operator enum to make sure there are no
collisions.
2020-11-02 15:48:30 +01:00
Bruno BELANYI b5912f508e evalexpr: parse: improve precedence climbing
The previous version of the algorithm did not take into account the fact
that the main loop should only run while we have postfix or infix
operators. This happened to work because of the small amount of
operators used in the grammar.

The previous version also had prefix operators hard-coded in the operand
parsing function.
2020-11-02 15:48:30 +01:00
Bruno BELANYI 88b7f50a3a evalexpr: parse: use single 'ops' table 2020-11-02 15:48:30 +01:00
Bruno BELANYI 9a6da7b19a evalexpr: parse: add precedence climbing parser 2020-11-02 15:48:29 +01:00
Bruno BELANYI ad56ea521a evalexpr: parse: rename recursive parsing function 2020-11-02 15:48:29 +01:00
Bruno BELANYI a92e39dbec evalexpr: initial recursive descent parser 2020-10-28 15:40:57 +01:00