grammars-v4 icon indicating copy to clipboard operation
grammars-v4 copied to clipboard

[GrammarTest] Grammar tester doesn't support parsers with `options { superClass=...;}`

Open RossPatterson opened this issue 3 years ago • 3 comments

There doesn't seem to be a way to make the grammar tester work for a grammar that uses options {superClass=...;}. Specifically, there doesn't appear to be a way to feed the GenericParser a set of grammar files that includes either the Java source file for the superclass or a compiled class from it. Or, for that matter, superclass files for any language.

I'd love to be wrong, because I'm trying to use GrammarTest to test my changes for [rexx] Hexstrings and binarystrings aren't parsed correctly.

@julianthome - Am I missing something key here?

RossPatterson avatar Aug 14 '22 19:08 RossPatterson

Why does grammar-test exist? It duplicates information in the pom.xml, including:

If the grammar changes, this code must also change! I've assumed that all the information for the grammar would be in the pom.xml. Now I see that it doesn't. (Note, in absence of a pom.xml, trgen could deduce all the information that we explicitly list out in pom.xml. It searches for all .g4's, and performs static semantic analysis of the grammar files deriving import/tokenVocab dependencies.)

We have already three methods of testing grammars:

  • Maven:
    • cd abnf; mvn clean test
  • _scripts/regtest.sh:
    • cd abnf; bash ../regtest.sh Java
  • _scripts/test.ps1.

The latter two employ trgen, which generates a driver+build files for any target, any platform.

kaby76 avatar Aug 15 '22 15:08 kaby76

I'm guessing grammar-test is unused. It apparently hasn't been able to compile since commit 45133256c6fefc649ebcf9aa451096883eec4bc4 on 2020-11-14, which updated the inmemantlr dependency to one that no longer has org.snt.inmemantlr.tree.Ast - it was renamed to ParseTree, and grammar-test was never updated. Which means that it certainly isn't being used in the CI pipeline, which means it's not useful for the Rexx unit tests I wanted to write.

Time to find a Plan B for my tests.

RossPatterson avatar Aug 16 '22 00:08 RossPatterson

Usually I just run a "mvn clean test" in the grammar directory to do a quick overall test for Java. That usually clears up most problems. Then, after that if you are working on a port to another target, you can use regtest.sh or just submit the code, and either it will go through a build, or I'll see it stuck there, and try the fork myself on my machine.

kaby76 avatar Aug 16 '22 00:08 kaby76

#2818 removed the Grammar tester.

RossPatterson avatar Sep 21 '22 01:09 RossPatterson