riff
riff copied to clipboard
Expression parsing cleanup
Most of the expression parsing logic was written during early stages of development. Long overdue for a refactor.
-
nud()
/led()
should return more useful information than some lexical token for calling functions to infer from. - Style-wise, the expression parsing should be modeled as a table of function pointers + other relevant metadata like operator precedence.
This work should also include the internal "expression stack" that's needed for constant folding/propagation. I believe this can also be used to create a set of specialized opcodes for variable assignment. Pushing the variable address on the stack can be avoided and inlined with some OP_SET
instruction in the same manner as OP_SIDXA
. Simple assignments (e.g. x = 1
) can be fully inlined to a mov
-style instruction.