forked from jasder/antlr
Merge pull request #1476 from renatahodovan/python-target-1472
Implement the fix of #1298 for Python targets.
This commit is contained in:
commit
6a20919cb7
|
@ -112,7 +112,7 @@ public class ParseTreesDescriptors {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean ignore(String targetName) {
|
public boolean ignore(String targetName) {
|
||||||
return !targetName.equals("Java");
|
return !targetName.matches("Java|Python2|Python3");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,15 @@ class ParserRuleContext(RuleContext):
|
||||||
self.exception = None
|
self.exception = None
|
||||||
|
|
||||||
#* COPY a ctx (I'm deliberately not using copy constructor)#/
|
#* COPY a ctx (I'm deliberately not using copy constructor)#/
|
||||||
|
#
|
||||||
|
# This is used in the generated parser code to flip a generic XContext
|
||||||
|
# node for rule X to a YContext for alt label Y. In that sense, it is
|
||||||
|
# not really a generic copy function.
|
||||||
|
#
|
||||||
|
# If we do an error sync() at start of a rule, we might add error nodes
|
||||||
|
# to the generic XContext so this function must copy those nodes to
|
||||||
|
# the YContext as well else they are lost!
|
||||||
|
#/
|
||||||
def copyFrom(self, ctx):
|
def copyFrom(self, ctx):
|
||||||
# from RuleContext
|
# from RuleContext
|
||||||
self.parentCtx = ctx.parentCtx
|
self.parentCtx = ctx.parentCtx
|
||||||
|
@ -54,6 +63,15 @@ class ParserRuleContext(RuleContext):
|
||||||
self.start = ctx.start
|
self.start = ctx.start
|
||||||
self.stop = ctx.stop
|
self.stop = ctx.stop
|
||||||
|
|
||||||
|
# copy any error nodes to alt label node
|
||||||
|
if ctx.children is not None:
|
||||||
|
self.children = []
|
||||||
|
# reset parent pointer for any error nodes
|
||||||
|
for child in ctx.children:
|
||||||
|
if isinstance(child, ErrorNodeImpl):
|
||||||
|
self.children.append(child)
|
||||||
|
child.parentCtx = self
|
||||||
|
|
||||||
# Double dispatch methods for listeners
|
# Double dispatch methods for listeners
|
||||||
def enterRule(self, listener):
|
def enterRule(self, listener):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -51,6 +51,15 @@ class ParserRuleContext(RuleContext):
|
||||||
self.exception = None
|
self.exception = None
|
||||||
|
|
||||||
#* COPY a ctx (I'm deliberately not using copy constructor)#/
|
#* COPY a ctx (I'm deliberately not using copy constructor)#/
|
||||||
|
#
|
||||||
|
# This is used in the generated parser code to flip a generic XContext
|
||||||
|
# node for rule X to a YContext for alt label Y. In that sense, it is
|
||||||
|
# not really a generic copy function.
|
||||||
|
#
|
||||||
|
# If we do an error sync() at start of a rule, we might add error nodes
|
||||||
|
# to the generic XContext so this function must copy those nodes to
|
||||||
|
# the YContext as well else they are lost!
|
||||||
|
#/
|
||||||
def copyFrom(self, ctx:ParserRuleContext):
|
def copyFrom(self, ctx:ParserRuleContext):
|
||||||
# from RuleContext
|
# from RuleContext
|
||||||
self.parentCtx = ctx.parentCtx
|
self.parentCtx = ctx.parentCtx
|
||||||
|
@ -59,6 +68,15 @@ class ParserRuleContext(RuleContext):
|
||||||
self.start = ctx.start
|
self.start = ctx.start
|
||||||
self.stop = ctx.stop
|
self.stop = ctx.stop
|
||||||
|
|
||||||
|
# copy any error nodes to alt label node
|
||||||
|
if ctx.children is not None:
|
||||||
|
self.children = []
|
||||||
|
# reset parent pointer for any error nodes
|
||||||
|
for child in ctx.children:
|
||||||
|
if isinstance(child, ErrorNodeImpl):
|
||||||
|
self.children.append(child)
|
||||||
|
child.parentCtx = self
|
||||||
|
|
||||||
# Double dispatch methods for listeners
|
# Double dispatch methods for listeners
|
||||||
def enterRule(self, listener:ParseTreeListener):
|
def enterRule(self, listener:ParseTreeListener):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue