Skip to content

Commit adb46ef

Browse files
author
hartsantler
committed
continue translation even if CommonNodeError is hit.
1 parent dca878b commit adb46ef

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

java2python/compiler/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def altIdent(self, name):
164164
if name in method.variables:
165165
return name
166166
if OPTIONS and OPTIONS.rusthon:
167-
raise RuntimeError('ooookkk')
167+
pass
168168
return ('cls' if method.isStatic else 'self') + '.' + name
169169
return name
170170

java2python/compiler/visitor.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def set_global_options(self, cfg):
4242

4343
def accept(self, node, memo):
4444
""" Accept a node, possibly creating a child visitor. """
45+
if node.token is None: return None ## bug?
4546
tokType = tokens.map.get(node.token.type)
4647
missing = lambda node, memo:self
4748
call = getattr(self, 'accept{0}'.format(tokens.title(tokType)), missing)
@@ -51,6 +52,9 @@ def accept(self, node, memo):
5152

5253
def insertComments(self, tmpl, tree, index, memo):
5354
""" Add comments to the template from tokens in the tree. """
55+
if not hasattr(tree, 'parser'):
56+
## see: lang/selector.py class Type, method __call__
57+
return
5458
prefix = self.config.last('commentPrefix', '# ')
5559
cache, parser, comTypes = memo.comments, tree.parser, tokens.commentTypes
5660
comNew = lambda t:t.type in comTypes and (t.index not in cache)
@@ -93,12 +97,13 @@ def walk(self, tree, memo=None):
9397
visitor.walk(child, memo)
9498
comIns(visitor, child, child.tokenStopIndex, memo)
9599
comIns(self, tree, tree.tokenStopIndex, memo)
96-
if tree.isJavaSource:
97-
comIns(self, tree, len(tree.parser.input.tokens), memo)
98-
# fixme: we're calling the mutators far too frequently instead
99-
# of only once per object after its walk is finished.
100-
for handler in self.configHandlers('PostWalk', suffix='Mutators'):
101-
handler(self)
100+
if hasattr(tree, 'isJavaSource'): ## else CommonNodeError
101+
if tree.isJavaSource:
102+
comIns(self, tree, len(tree.parser.input.tokens), memo)
103+
# fixme: we're calling the mutators far too frequently instead
104+
# of only once per object after its walk is finished.
105+
for handler in self.configHandlers('PostWalk', suffix='Mutators'):
106+
handler(self)
102107

103108
def zipWalk(self, nodes, visitors, memo):
104109
""" Walk the given nodes zipped with the given visitors. """

java2python/lang/selector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ def __init__(self, key, value=None):
160160
self.value = value
161161

162162
def __call__(self, tree):
163-
if tree.token.type == self.key:
163+
if tree.token is None: ## bug?
164+
pass
165+
elif tree.token.type == self.key:
164166
if self.value is None or self.value == tree.token.text:
165167
yield tree
166168

0 commit comments

Comments
 (0)