fesch / Structorizer.Desktop

Structorizer is a little tool which you can use to create Nassi-Schneiderman Diagrams (NSD).
https://structorizer.fisch.lu
GNU General Public License v3.0
65 stars 19 forks source link

Java import fails on qualified `new` operators #1144

Open codemanyak opened 6 months ago

codemanyak commented 6 months ago

For see instantiation of nested static classes a qualified new operator may be needed (see e.g. https://stackoverflow.com/questions/2863157/how-does-object_new-work-does-java-have-a-new-operator).

If the Java parser bumps into such a qualified new operator it fails inevitably:

error.syntax in file "D:\SW-Produkte\Structorizer\tests\Issue1132_Java_import\parsers\COBOLParser.java"

Preceding source context:
 5762:       {
 5763:           // START KGU#537 2018-07-01: Enh. #553
 5764:           checkCancelled();
 5765:           // END KGU#537 2018-07-01
 5766:           if (_reduction.isEmpty()) {
 5767:               return;
 5768:           }
 5769:   
 5770:           // create a dummy-program because we may have only a partial source that doesn't start with 
     +   program definition
 5771:           if (currentProg == null) {
 5772:               currentProg = cobTools.» new CobProg(STRUCTORIZER_PARTIAL, null, false, null);

Found token new

Expected: Identifier

A grammar modification will be necessary to solve this problem.

codemanyak commented 6 months ago

An apparently obvious approach to update the grammar caused normal object instantiation with type parameters to fail instead, which seems worse.

codemanyak commented 6 months ago

There is no simple solution at hand (except that the preprocessor would simply delete the class path prefix), but the occurrence of qualified new operators seems unlikely enough to leave it as is.