-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add the generalized Pratt parsing example #277
base: hkmc2
Are you sure you want to change the base?
Conversation
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.
Looks like the test outputs are not up to date.
Co-authored-by: Lionel Parreaux <[email protected]>
Co-authored-by: Lionel Parreaux <[email protected]>
Co-authored-by: Lionel Parreaux <[email protected]>
Co-authored-by: Lionel Parreaux <[email protected]>
|
||
module Iter with ... | ||
|
||
fun derive(iterable, makeNext) = Iterable of () => |
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.
The name is quite confusing. Why not
fun derive(iterable, makeNext) = Iterable of () => | |
fun adaptIterator(iterable, makeNext) = Iterable of () => |
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.
Also why does it require all callers to wrap things in an obfuscating () =>
?
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.
I guess you're referring to the second parameter. This function takes the old iterator and produces a function that is going to be used as the next
method on the new iterator. That's why it's called makeNext
.
In summary, the function derive
does the following things:
- takes an
Iterable
, - creates an iterator by calling its
Symbol.iterator
, - passed the iterator to
makeNext
, and - uses the produced function as the
next
method on the new iterator.
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.
(I didn't use the Commit suggestion feature to make the changes because the references below also needs to be updated.)
No description provided.