bobertlo / gmars

Go implementation of CoreWar MARS simulator
MIT License
3 stars 1 forks source link

compiler: equ macro expansion needs to be done before parsing #80

Open bobertlo opened 4 days ago

bobertlo commented 4 days ago

Problem:

I made the assumption that equ values would only be used to store expressions, but they may hold more syntax.

Example from "vm5" by Michal Janeczek:

d01 equ spl 0,1
d02 equ spl 0,#1
d03 equ spl -1,1
d04 equ spl -1,#1
d05 equ spl 0,@1
d06 equ spl -1,@1
for 4
y for 6
for 4
for CURLINE<MAXLENGTH
d&y
rof
rof
rof
rof

Solution

Probably use preprocesser to make a first pass of the lex stream for equ tokens, then use those values to preprocess the token stream on a second run of the lexer.