javacc / javacc

JavaCC - a parser generator for building parsers from grammars. It can generate code in Java, C++ and C#.
https://javacc.org
BSD 3-Clause "New" or "Revised" License
1.19k stars 248 forks source link

Avoid use of static fields #146

Open vlsi opened 4 years ago

vlsi commented 4 years ago

For instance, org.javacc.parser.Main#mainProgram starts with

https://github.com/javacc/javacc/blob/ac4941edb86297408833b0de796b4e9962769845/src/main/java/org/javacc/parser/Main.java#L163-L166

1) It means the parser can't be executed concurrently, and it might leave non-initialized state behind. 2) It makes it harder to follow the code: static fields might create unexpected couplings.

It would be better to move the relevant state to the instance fields.

The same goes for org.javacc.parser.Options (which is fully static) and so on.

mbrigl commented 4 years ago

I agree, I'm already working on it for branch 8.0