-
Notifications
You must be signed in to change notification settings - Fork 4
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
Implement Prism -> Sorbet translation for interpolated matches #298
Conversation
parser/prism/Translator.cc
Outdated
@@ -645,6 +645,16 @@ unique_ptr<parser::Node> Translator::translate(pm_node_t *node) { | |||
// Will only work for positive, 32-bit integers | |||
return make_unique<parser::Integer>(location, std::to_string(intNode->value.value)); | |||
} | |||
case PM_INTERPOLATED_MATCH_LAST_LINE_NODE: { // A test of the last read line with interpolation, |
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.
A test
? I don't quite get what this means.
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 it's really hard to summarize clearly.
I explain it better in the PR description of #288. Given that, do you have any suggestion for how to summarize it here?
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.
Thanks for the context, and WOW.
Maybe something like: An interpolated regex in a conditional that checks last read line from IO
?
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 like Stan's description!
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 had to break it on 2 line to pass the formatter. That gave me some extra room, so I added some more detail:
case PM_INTERPOLATED_MATCH_LAST_LINE_NODE: { // A test of the last read line with interpolation, | |
case PM_INTERPOLATED_MATCH_LAST_LINE_NODE: { // An interpolated regex literal in a conditional... | |
// ...that implicitly checks against the last read line by an IO object, e.g. `if /wat #{123}/` |
parser/prism/Translator.cc
Outdated
@@ -645,6 +645,16 @@ unique_ptr<parser::Node> Translator::translate(pm_node_t *node) { | |||
// Will only work for positive, 32-bit integers | |||
return make_unique<parser::Integer>(location, std::to_string(intNode->value.value)); | |||
} | |||
case PM_INTERPOLATED_MATCH_LAST_LINE_NODE: { // A test of the last read line with interpolation, |
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 like Stan's description!
86e83a6
to
be27986
Compare
be27986
to
395f4ea
Compare
14b1246
to
5632018
Compare
Similar to #288, but for interpolated regexes. Closes #117.