-
Notifications
You must be signed in to change notification settings - Fork 34
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
Improve parsing even further #153
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
This permits `use foo::grammar::*`
The old code was kind of specific to `$ . F` where `.` is a mode. This is going to allow us to accommodate new modes more easily.
We now support optional lists.
We are going to want to make recursive modes.
this will better support the new gated parsing mode
We don't need this anymore.
This will make it easier to support fixed point parsing.
This helps resolve some annoying ambiguities while keeping the ones I think we want.
and add a test
It is sometimes useful to see EXACTLY what is going on
behavior is still broken
We are going to rework the way that variables are given precedence to use explicit rejection instead.
When one variant is tagged as `#[variable]`, we now automatically reject variable names from other variants. This means we can use `#[precedence]` just to encode true *precedence* (i.e., of operators). This was important since there was a conflict where variables wanted to be the same *precedence* as other identifiers in a logical sense.
We are going to need access to it when we recurse. Besides, the code looks cleaner this way!
This makes us panic safe, but it also just reads much more nicely.
Are we in Left position, right position, etc. (see docs) This will be used to guide parsing of variants so that we can properly handle recursion.
We used to also consider precedence, but we are moving away from that approach. Remove some tests that no longer test a relevant edge case.
We are going to start enforcing the invariant that an expression with priority N can only directly things of higher priority. In that case for something like this: ``` enum Expr { Id(Id), Literal(Literal), #[precedence(1, left)] Add(Expr, Expr), #[precedence(2, left)] Mul(Expr, Expr), } ``` you want Id/Literal to be max priority so they can be embedded into anything.
@bors r+ |
I guess we didn't enable bors yet. :) |
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.
Parsing now supports:
Foo<>
struct Foo where [] {
but can just writestruct Foo {
Expr = Expr + Expr
and things like that.also adds a custom testing framework (
parser-torture-tests
) as well as an example language (formality-eg
). The formality language is incomplete.