-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Node pattern compiler #105
Conversation
b0eb31b
to
7637762
Compare
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.
Didn't dive into compiling, the rest looks very readable and elegant 👏
a.is_a?(Range) ? a : INT_TO_RANGE[a] | ||
end | ||
|
||
INT_TO_RANGE = Hash.new { |h, k| h[k] = k..k } |
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.
Is this a memory optimization technique? Why?
How does it work?
INT_TO_RANGE[1] === INT_TO_RANGE[1] # => false
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.
Yeah, not sure it's that useful. INT_TO_RANGE[42] # => 42..42
. I wanted to avoid returning new Ranges all the time, or having to memoize it per node, but I might do that in the end (in the constructor, coz they are frozen).
33bddc4
to
f011935
Compare
I have a proof of concept for multiple length union #79 (e.g. |
fa4bcbb
to
0e41a76
Compare
More than a year of compiler classes on a single PR @marcandre! 🤯 |
5055a2c
to
8b9c1b0
Compare
8b9c1b0
to
12fff67
Compare
12fff67
to
151a089
Compare
Merged 🎉 . To be released tomorrow. |
This PR is a complete rewrite of the
NodePattern
compilation.It aims to be 100% compatible, and also:
It's a big PR... I wrote a hacker's guide that should help explaining the main concepts.
Anyone interested in reviewing this? Thanks to @MaxLap for reviewing an initial draft 👍