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

Pass operator to Pratt parsing functions #514

Closed
wants to merge 8 commits into from

Conversation

stefnotch
Copy link
Contributor

@stefnotch stefnotch commented Aug 28, 2023

Deprecated in favor of #515

Fix #507
I'm not sure if this implementation is ideal, so I'll appreciate any and all feedback.
Things that could definitely still be done

  • An additional test, where this feature is actually being used to get a span.
  • Benchmarking, if useful.

Pinging @Zij-IT : I'd love to get some feedback on this.

@zesterer
Copy link
Owner

@Zij-IT Any chance you'd have a free moment to take a look at this?

@Zij-IT
Copy link
Contributor

Zij-IT commented Aug 28, 2023

@Zij-IT Any chance you'd have a free moment to take a look at this?

I’ll give it a look this weekend (:

Edit: For some reason I thought it was Friday 🤦‍♂️ I'll give it a look in the next couple days

Copy link
Contributor

@Zij-IT Zij-IT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I love the work, and I think you did a great job. @zesterer has a similar PR that also moves us closer to the API using Fn as opposed to the current API which uses fn, and also allows us to use multiple combinations of functions, such as the one you would prefer, and also one that has a total span.

I'm curious what you would think of his variation, and if you feel there are any items missing in that implementation? If you haven't seen it, you can find it here #515

@@ -15,7 +15,7 @@ exclude = [
build = "build.rs"

[features]
default = ["std", "spill-stack"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this gets fixed in a following commit, but tagging just in case :)

where
I: Input<'a>,
E: ParserExtra<'a, I>,
InfixOps: Parser<'a, I, InfixOpsOut, E>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason this trait bound has to disappear? It was originally added with the idea that it makes no sense to construct a Parser which cannot parse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't have to disappear, but it does have to change a bit. At first I didn't figure out how to change it, so I haphazardly deleted it.

>,
>
where
I: Input<'a>,
E: ParserExtra<'a, I>,
PrefixOps: Parser<'a, I, PrefixOpsOut, E>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason this trait bound has to disappear? It was originally added with the idea that it makes no sense to construct a Parser which cannot parse.

Comment on lines -255 to +276
type InfixBuilder<E> = fn(lhs: E, rhs: E) -> E;
type InfixBuilder<Op, O> = fn(op: Op, children: [O; 2]) -> O;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not particularly a fan of this, although I understand why it has to happen. That aside, E I think should have become Expr if a name change was necessary.

Comment on lines -259 to +280
type PostfixBuilder<E> = fn(rhs: E) -> E;
type PostfixBuilder<Op, O> = fn(op: Op, child: O) -> O;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the points that I was unsure about. I think I would prefer and find it more natural for PostfixBuilder to be fn(O, Op) -> O because the op follows the expression when parsing.

@stefnotch
Copy link
Contributor Author

Oh sweet, zesterer might have built an even more general version. I'll check it out and am very happy with closing this in favour of a better solution!

As long as I end up being able to use an excellent parser combinator library, I'm very satisfied.

@stefnotch stefnotch marked this pull request as draft September 23, 2023 12:20
@stefnotch
Copy link
Contributor Author

Deprecated in favor of #515

@stefnotch stefnotch closed this Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request] Pratt parsing with spans
3 participants