antlr / antlr4test-maven-plugin

A maven plugin used to test the grammars-v4 repo grammars
BSD 3-Clause "New" or "Revised" License
17 stars 16 forks source link

Write and use toStringTreeIndented function instead of toStringTree for .tree files comparison #4

Open KvanTTT opened 7 years ago

KvanTTT commented 7 years ago

It improves and simplifies diff for .tree files. See also https://github.com/antlr/grammars-v4/issues/748 and https://github.com/antlr/antlr4/issues/1502.

Marti2203 commented 3 years ago

Hi, I see there has not been any change? Is it possible to work on this fix?

KvanTTT commented 3 years ago

I don't think so becuase firstly we should choose a format for parsing tree rendering. It should be lightweight and convenient for machine comparison. I suggest the following one, without parentheses:

propertyDeclaration
  VAL("val")
  variableDeclaration
    simpleIdentifier
      Identifier("result")
  ASSIGNMENT("=")
  expression
    disjunction
      conjunction
        equality
          comparison
            infixOperation
              elvisExpression
                infixFunctionCall
                  rangeExpression
                    additiveExpression
                      multiplicativeExpression
                        asExpression
                          prefixUnaryExpression
                            postfixUnaryExpression
                              primaryExpression
                                simpleIdentifier
                                  Identifier("ArrayList")
  DOT(".")
  THIS("this")
  DOT(".")
  Identifier("remove")
  LPAREN("(")
  Identifier("index")
  SUB("-")
  IntegerLiteral("1")
  RPAREN(")")