Open gvlasov opened 9 years ago
It is not currently possible to do this. There is an outstanding effort to allow some sharing within a single parser (#697), but I'm not aware of any proposal or work to support sharing classing between different parsers.
I have a grammar
SharedParser.g4
with rulesa
andb
. This grammar is imported to grammarsClient1Parser.g4
andClient2Parser.g4
which use these rules.When antlr generates Java sources for
Client{1,2}Parser.g4
, each of the parsers define their own types for the shared rules. As a result, there are three types for each of rulesa
andb
:Client1Parser.A
,Client1Parser.B
;Client2Parser.A
,Client2Parser.B
;SharedParser.A
,SharedParser.B
.I expected the client parsers to return types
SharedParser.A
andSharedParser.B
from their methodsparser.a()
andparser.b()
. Is this possible?