Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 of 4 tasks
bobertlo opened this issue Nov 20, 2024 · 0 comments
Open
2 of 4 tasks

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

bobertlo opened this issue Nov 20, 2024 · 0 comments

Comments

@bobertlo
Copy link
Owner

bobertlo commented Nov 20, 2024

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.

  • create lexer interface
  • Extract tokens from file with lexer
  • Return new implementation that wraps lexer and substitutes tokens with patterns in-stream
  • Remove equ handling from compiler, leave FOR handling (for now)
@bobertlo bobertlo changed the title compiler: equ needs to be done before parsing compiler: equ macro expansion needs to be done before parsing Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant