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

Adapt to R devel parser #441

Merged
merged 6 commits into from
Nov 18, 2018
Merged

Conversation

lorenzwalthert
Copy link
Collaborator

@lorenzwalthert lorenzwalthert commented Nov 16, 2018

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 is 2. If not, we don't know, because parse data for all expressions not involving EQ_ASSIGN can't be distinguished, so we just assume it is version 1.
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?

@codecov-io
Copy link

codecov-io commented Nov 16, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@0154a18). Click here to learn what that means.
The diff coverage is 95.23%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #441   +/-   ##
=========================================
  Coverage          ?   90.51%           
=========================================
  Files             ?       35           
  Lines             ?     1613           
  Branches          ?        0           
=========================================
  Hits              ?     1460           
  Misses            ?      153           
  Partials          ?        0
Impacted Files Coverage Δ
R/environments.R 100% <100%> (ø)
R/roxygen-examples-parse.R 100% <100%> (ø)
R/nested-to-tree.R 96.42% <100%> (ø)
R/parse.R 83.67% <100%> (ø)
R/relevel.R 95.31% <87.5%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0154a18...25b0e28. Read the comment docs.

@lorenzwalthert
Copy link
Collaborator Author

I guess we best merge this now for the release. As this is internals only, we can change it later if necessary.

@lorenzwalthert lorenzwalthert merged commit 7f61328 into r-lib:master Nov 18, 2018
@lorenzwalthert lorenzwalthert deleted the fix-parsing branch November 18, 2018 11:46
Copy link
Member

@krlmlr krlmlr left a 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",
Copy link
Member

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?

Copy link
Collaborator Author

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.

@lorenzwalthert
Copy link
Collaborator Author

The thing is that styler needs to pass R CMD CHECK on R devel and the patch mentioned in #49 is not going to be in R before 3.6. So I am not sure how I should use the R version for distinction in this case.

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?

I am not sure if I understand this. The reason we have #419 is that it is (as of today) not the same.

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.

Upcoming fix in R devel parser requires action
3 participants