RealKC/reqvm

Implement a preprocessor

RealKC opened this issue · 1 comments

In commit 8b189c2 I gave up on working on the assembler. This is something I still need to write and this issue stands to remind me of that.

Commit 4a506f0 removed all traces of the initial preprocessor, this is a good thing (code quality was low + wasn't half finished + it was commented out anyway).

Implementation notes:

  • if, and elif should share the expression parses, which should likely be implemented using the shunting-yard algorithm [1]

Specification notes:

  • the operators supported in (el)if should be specified
  • specify what happens when the preprocessor has to expand an empty macro in (1) (el)if expressions (should we follow CPP's example and expand them to 0?) and (2) in usual usages of the macros

Possible features that might be worth adding:

  • defining macros from the command line
  • textual inclusion of files for macros that appear in multiple files? (Although currently you can't link files... It would be nice for macros used across projects, I guess? Also could allow a model where despite working in different files they all get included by a single one.)

There are still bugs regarding codegen however, so this issue can wait for a bit longer.

[1] Shunting-yard algorithm on Wikipedia