-
Notifications
You must be signed in to change notification settings - Fork 73
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
Adapt to R devel parser #441
Conversation
d6e517a
to
6b08124
Compare
6b08124
to
4788f2e
Compare
Codecov Report
@@ Coverage Diff @@
## master #441 +/- ##
=========================================
Coverage ? 90.51%
=========================================
Files ? 35
Lines ? 1613
Branches ? 0
=========================================
Hits ? 1460
Misses ? 153
Partials ? 0
Continue to review full report at Codecov.
|
I guess we best merge this now for the release. As this is internals only, we can change it later if necessary. |
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. I think we can rely on the R version here, because the fix is unlikely to be back-ported to R 3.5 (and even if, we still can do that).
I like the way relocate_eq_assign()
works. Is it early enough that we can assume that for all R versions (3.6 and < 3.6) the data format is essentially the same? Maybe we don't need to distinguish anything for the nested parse data?
@@ -26,7 +26,10 @@ flatten_operators <- function(pd_nested) { | |||
#' @keywords internal | |||
flatten_operators_one <- function(pd_nested) { | |||
pd_token_left <- c(special_token, math_token, "'$'") | |||
pd_token_right <- c(special_token, "LEFT_ASSIGN", "'+'", "'-'") | |||
pd_token_right <- c( | |||
special_token, "LEFT_ASSIGN", if (parser_version_get() > 1) "EQ_ASSIGN", |
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.
What happens if we leave "EQ_ASSIGN"
here unconditionally?
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.
Not sure. A few changes in #441 did not have any known effects on the styling, it's just about making the AST look the same. But probably it would break something because there was some reason why it was not included in the list I guess.
The thing is that styler needs to pass
I am not sure if I understand this. The reason we have #419 is that it is (as of today) not the same. |
Closes #419. We need to distinguish two cases: Before the parser fix outlined in #419 was committed into R devel and afterwards. The parser version is identified from the parse data. If the parse data contains an
equal_assign
token, we know it's the second case and say the parser version is2
. If not, we don't know, because parse data for all expressions not involvingEQ_ASSIGN
can't be distinguished, so we just assume it is version1
.I propose to use an environment to store specifications about the current run, i.e. to store the parser version. I am not sure if that's a good idea. But since we need to have the parser version available in different places, I can't think of a better way. Also, I am not sure about using version numbers for the parser and if it is a good idea to derive the parser version from the result of parsing. An alternative approach is to base it on the
Rversion
number, but that's a bit brittle I think. Any comments on that @krlmlr?