YJDoc2 / 8086-Emulator

An Intel 8086 Emulator created in Rust.
Apache License 2.0
332 stars 49 forks source link

Overhaul the lexer parse and interpreter architecture to a better scheme #6

Open YJDoc2 opened 1 year ago

YJDoc2 commented 1 year ago

Currently the overall architecture of this is acceptable, but pretty hideous. The choices were made for various different (not necessarily correct) reasons at the time when this was written, but needs a fixing to some better choices now.

This is horrible for many reasons :

Currently the two strategies are :

Even though second option is desirable, it is equally tricky, so first shifting to custom lexer, than a custom parser separately might be a better way.

Either way, we should make the initial parser generate enum instead of text again and remove "interpreter parser", and remove print parser as well.

Tracking:


Just noticed that the 8086 manual also include hex codes for instructions, if we can use them, we can actually store instructions in the memory and remove that barrier.

ADIthaker commented 1 year ago

I would love to work on this issue, can you send me some resources so I can learn the relevant parts of compiler design for this project.

YJDoc2 commented 1 year ago

Hey, Thanks a lot for your interest. https://craftinginterpreters.com/ is my go to suggestion for learning about compilers.

Do you have any preference for approach 1 or 2?

I have a basic lexer written for another project, which I can share in a gist, and you can adapt it for this. A good idea might be to start with printer interpreter, and convert it from lalrpop to hand-written stuff. Its pretty small and pretty eacy. They we can think about converting the rest.

What do you think?

ADIthaker commented 1 year ago

I think we can implement strat 1 first and then we can think of removing lalrpop completely. Starting with the print parser sounds good to me, will help me understand this project piece by piece better.

YJDoc2 commented 1 year ago

Great! So how do you want to proceed? Do you need any help?

YJDoc2 commented 1 year ago

FYI, ADIthaker will not be proceeding with this due to some personal issues.

Any reader who is interested can comment and take up parts :+1: