forked from jasder/antlr
[Python3] Fix the import of parser superclasses.
Until now, the generated Python3 code imported the custom parser superclasses relatively. However, this only worked in Python3 if the module was inside a package, since relative imports rely on __name__ to determine the current module's position in the package hierarchy. In case of a standalone script, this was always __main__ and hence these relative imports failed. The patch handles this issue them same way as it is handled by listener imports.
This commit is contained in:
parent
432022fc1c
commit
b748545707
|
@ -119,7 +119,10 @@ Parser(parser, funcs, atn, sempredFuncs, superClass) ::= <<
|
||||||
|
|
||||||
Parser_(parser, funcs, atn, sempredFuncs, ctor, superClass) ::= <<
|
Parser_(parser, funcs, atn, sempredFuncs, ctor, superClass) ::= <<
|
||||||
<if(superClass)>
|
<if(superClass)>
|
||||||
from .<superClass> import <superClass>
|
if __name__ is not None and "." in __name__:
|
||||||
|
from .<superClass> import <superClass>
|
||||||
|
else:
|
||||||
|
from <superClass> import <superClass>
|
||||||
|
|
||||||
<endif>
|
<endif>
|
||||||
<atn>
|
<atn>
|
||||||
|
|
Loading…
Reference in New Issue