[java] Make binary operators left-recursive#1979
Merged
oowekyala merged 9 commits intoSep 27, 2019
Merged
Conversation
a995701 to
8d47824
Compare
Generated by 🚫 Danger |
Member
|
I've added doc to https://github.com/pmd/pmd/wiki/Java_clean_changes#binary-operators-are-left-recursive - please update it, if I didn't get it right, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So this should fix #1661 definitively
The structure of infix expressions is now always the same: a left-hand side, an operator, a right hand side. Since having different node types for each of those adds no information that the operator constant doesn't already provide, I think it's useful to merge all those nodes (there's 10) into a single one. This decreases the size of the API, and is for example what Eclipse JDT does
I also experimented with generating nice tree images for our javadocs. For example:
Unfortunately rendering the images is not really portable for now, as the build machine needs a LaTeX distribution. So I prerendered them and committed them here.
Copy of the discussion on left-recursiveness
What to do about #1661 (operator nodes) ? Sensible solution would be to make AdditiveExpression be parsed completely left-recursively, but then, it looks weird that all other binary expressions are not left-recursive…
The problem also arises for operators
&,|,^, which may be boolean non-shortcut expressions or numeric bitwise expressionsArguments for left recursiveness:
((1 + 4) + returnString()) = “14” “5”
((1 + 4) + 4) == (1 + 4 + 4)
Arguments against: