Give operators precedence using the shunting-yard algorithm
commit5e566825e556605750065d15e9395834766411d9
authorPetr Tesarik <petr@tesarici.cz>
Mon, 15 Oct 2012 16:38:57 +0000 (15 18:38 +0200)
committerPetr Tesarik <petr@tesarici.cz>
Mon, 15 Oct 2012 16:38:57 +0000 (15 18:38 +0200)
tree5048039174b379740a27114752731973eb23a18a
parent3b7446f6b33ae04d7213f82a5540caa6706eba58
Give operators precedence using the shunting-yard algorithm

I adopted the C language operator precedence, with all the controversy
it may cause with regards to the bitshift operators. Please note that
I even kept the precedence of exclusive OR over inclusive OR (for
example Perl treats them both with same precedence).

Note that two pseudo-operators are added:

 - ABO_LPAREN: used only during parsing
 - ABO_RPAREN: never even exists as an atom; it is used to stop stack
               reduction at the nearest left parenthesis

I could use ABO_OR instead of ABO_RPAREN, but it would make the code
hard to maintain if I want to add another operator with lower precedence
than OR (e.g. the ?: operator).

I'm using incomplete atom_bin structures for the operator stack. This
means that I have to check whether atom1 and atom2 exists when I free
the atom.
libhed/expr.c