On 2021-Jun-20, at 7:38 PM, ben via cctech wrote:
On 2021-06-20 8:13 p.m., Toby Thain via cctech wrote:
Tried the Shunting Yard algorithm? But watch out,
it was invented by a
quiche eater...
The problem needs backtracking to generate correct code. Stack or muilti-register
machines don't have this problem with temporaries.
Ben.
The parser generates a tree of the algebraic expression, the tree is representative of the
evaluation order of the expression, earlier evals lower in the tree, the node at the top
is the last evaluated. Then walk the tree from the bottom up to generate code.
I think code to do this (efficient compiler code generation) has been done like a
gazillion-billion times since 1960.