Replies: 5 comments
-
I'm not sure it's a good idea. There are other similar entities like |
Beta Was this translation helpful? Give feedback.
-
In C++ the difference is basically a single member variable, |
Beta Was this translation helpful? Give feedback.
-
The two are used in completely different contexts. One is the lexer, the other is the parser. How would you unite these two classes? Have a single class with all the fields combined from each former class? There's more than a single member variable that sets both classes apart. The differences are not huge, but given the sizes of these classes, it doesn't appear to be useful to merge them. The use of shared_ptr in the prediction code stems from the fact that the configs constitute a graph with no root that controls lifetime. Sometimes configs are created temporarily and replaced. In Java, when you set a new instance of a class in a field, the existing value is automatically destroyed, unless used otherwise. You can use this approach only by using a shared_ptr. |
Beta Was this translation helpful? Give feedback.
-
ATNConfig is the same as LexerATNConfig except for |
Beta Was this translation helpful? Give feedback.
-
What about the non-greedy decision check (whose result is also part of the hash)? And can't follow your argumentation of avoiding For the |
Beta Was this translation helpful? Give feedback.
-
We can potentially remove most shared_ptr<ATNConfig> by merging LexerATNConfig into ATNConfig, making it non virtual and concrete. All members would be trivially copyable or shared_ptr themselves. Now we could return ATNConfig by value and avoid all usages of shared_ptr<ATNConfig> in the atn code.
@mike-lischke WDYT?
Beta Was this translation helpful? Give feedback.
All reactions