-
Notifications
You must be signed in to change notification settings - Fork 3
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
Parser v2? #2
Comments
Had an idea: Writing to the code-segment could be done via a routine that has the current code-segment address in the |
I would like to have a fast path for numbers that avoids the full expression parser, but we can't know if a number is alone or part of an expression ahead of time as we must look for the operator that follows. There are two approaches to this we could follow:
|
The nightmare of eZ80's (#12) prefix splurge means looking at a potential replacement instruction parser. When I began writing the instruction parser one idea I toyed with was a prefix-based list where the first byte/nybble specifies how many chars are shared with the previous entry, and the instructions are all listed alphabetically, dictionary like. I couldn't be sure it would save enough space, so I went with the tree but I need to make a working version of the list to see if it would help with eZ80 encoding. |
After a couple of months, the results are in:
The new instruction parser is marginally larger (there's still room for optimisation) but, save for yet-unseen bugs, is also faster! I didn't expect this, but I'll take the win after all that work; this will make adding new ISAs much easier on everybody |
ISA parser v2 has been merged greatly simplifying the way ISAs are written. |
It has occurred to me that another method of parsing would be to use a straight jump table from ASCII code to routine.
Since the order of tokens would no longer be enforced by code order (i.e. a value must follow a unary operator), there would instead be a "mode" variable that would describe the context for each routine arrived at. For example, if an operator is encountered but the mode says we're not in an expression, then we throw an error.
There are a number of cons:
However there are some pros:
The text was updated successfully, but these errors were encountered: