congo-cc / congo-parser-generator

The CongoCC Parser Generator, the Next Generation of JavaCC 21, which in turn was the next generation of JavaCC
https://discuss.congocc.org/
Other
36 stars 11 forks source link

reproducable code with LinkedHashSet and cleanup NFA names #36

Closed stbischof closed 1 year ago

stbischof commented 1 year ago

reproducible : use orderd LinkedHashSet and Interfaces where possible

checked against the generated file in build: /examples/java/org/parsers/java/JavaLexer.java

NFA names: does not change the behavior of the code in any way. generated only cleaner method-names in java code.

revusky commented 1 year ago

As regards the renaming of the NFA methods, well, it's harmless, I guess. Of course, it's quite rare, in practice, that anybody even needs to read them! But, since you are probably the only person who cares how these things are named, I'll accept the change. I assume you got rid of the changing order of methods/imports by changing HashSet/HashMap to LinkedHashSet/LinkedHashMap all over the place. However, I also think you did change it in places where it is completely unnnecessary, i.e. has no effect. As best I can tell, you can always use a LinkedHashSet/LinkedHashMap instead of a regular HashSet/HashMap, but the only actual difference is when you iterate over the keys. The LinkedHashSet gives you a determinate order and the regular HashSet makes no promise about the order of iteration. But if you change it in cases where it never iterated over the container anyway (or it did iterate but the order really didn't matter) then it makes no difference, except that there is some (probably slight) extra computational inefficiency because it is maintaining a LinkedList internally that is never used. Just looking at this, it seems that the changes to LinkedHashSet are superfluous in Expansion.java and in Reaper.java since there is no iteration happening. Some other places as well, I guess I'll merge the request and maybe you should look over the various LinkedHashSets and see if they really need to be LinkedXXX. I guess maybe it's the ones in FilesGenerator.java that made the difference. I changed it in CodeGenerator.java and maybe that was the wrong place! Or not enough...

stbischof commented 1 year ago

I fully agree with every word! but was the easiest way. was to complex to find out witch HashSet was the one....

THANK YOU