-
Notifications
You must be signed in to change notification settings - Fork 6
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
New parser (pest) #45
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sbillig
force-pushed
the
pest-parser
branch
3 times, most recently
from
June 21, 2024 03:43
cdafe8a
to
045421e
Compare
Y-Nak
approved these changes
Jun 30, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean and neat! Awesome work!
Thanks for the cleanup hints. I have some followup work in mind, but I'll open a new PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This replaces the old parser with a pest-derived parser. It currently implements all text-format functionality required for the tests to pass, meaning that there may be syntax that the old parser supported that the new one doesn't (I'm not sure if there is, actually). The goal is to extend this parser to support some new functionality required for sonatina to be a useful evm backend ("objects", contract constructor functions, etc), but that'll happen in future PRs.
Some minimal error checking is performed (duplicate values definitions, referring to undefined identifiers, etc).
I also made some minor syntax changes:
1
, instead of-1
Note that there are a couple small changes to the optimization passes, to make them work with alias values, though I made no attempt to ensure they function correctly in all situations involving alias values, just the particular situations that arose during testing. (I haven't thought about a more general solution to this problem, but perhaps we could discuss this.) The parser introduces an alias when a value is used before it's defined (in the textual form of the program, not the actual execution flow of course). For example:
In this case, the name
v1
will first be marked as undefined, and given a new value id with a dummy value, sayValue(5)
. When the definition ofv1
is reached, we create a new value id for the definition, sayValue(6)
, associate the namev1
withValue(6)
, and changeValue(5)
to be an alias ofValue(6)
. (Note that unlike in the old parser, the name "v1" isn't guaranteed to be associated withir::Value(0)
)TODO:
filecheck fork with regex change and failure print fix(I'll do this later)