This is a bug report for python-antlr3, antlr-v3.1.3.

Hi, I'm trying to transform a tree of some assembly language via
executing and throwing away nodes of assembler directives.
I'm working for python-target (antlr-v3.1.3) and have a problem with
plain simple tree-to-nil transformation:
`
dot_dot_directive
        :       
                ^(DOT_DOT_NAME ^(ARGS DOT_DOT_ARGS?) DOT_DOT_BODY?)
                   ->                                                // gives
AttributeError: 'NoneType' object has no attribute 'isNil'
                // -> ^()                                            // won't 
compile
                // -> ^({self.adaptor.nil()})                   // gives
AttributeError: 'NoneType' object has no attribute 'isNil'
                // -> ^({self.adaptor.create(HEX,'00')}) // works, but not what 
I want
                // -> ^($block_child)                          // gives
antlr3.tree.RewriteEmptyStreamException: rule retval
        ;
`.

Here is an error message in detail:
`
  File "assembler_I_am_tinkering_Walker.py", line 713, in dot_dot_directive
  File 
"c:\python25\lib\site-packages\antlr_python_runtime-3.1.3-py2.5.egg\antlr3\tree.py",
line 2070, in replaceChildre
n
    parent, startChildIndex, stopChildIndex, t
  File 
"c:\python25\lib\site-packages\antlr_python_runtime-3.1.3-py2.5.egg\antlr3\tree.py",
line 1615, in replaceChildre
n
    parent.replaceChildren(startChildIndex, stopChildIndex, t)
  File 
"c:\python25\lib\site-packages\antlr_python_runtime-3.1.3-py2.5.egg\antlr3\tree.py",
line 809, in replaceChildren

    if newTree.isNil():
AttributeError: 'NoneType' object has no attribute 'isNil'
`.

Looking up generated tree parser code gives:
`
 # 103:55: ->
 root_0 = None

 retval.tree = self._adaptor.rulePostProcessing(root_0)    # None ->
None -> retval.tree
 self.input.replaceChildren(
     self._adaptor.getParent(retval.start),
     self._adaptor.getChildIndex(retval.start),
     self._adaptor.getChildIndex(_last),
     retval.tree
     )
`.

Shallow investigation reveals that error chain leads to
`parent.replaceChildren(startChildIndex, stopChildIndex, t)`,
where t is None and then `t.isNil()` is invoked without checking if t is None.

I don't understand how it should work, but I've just tinkered
rulePostProcessing to return nil node unaffected to push
my job further.

I hope this bug report will help others to spend less time dealing
with the same error.
Terence Parr, Benjamin Niemann, antlr is a great tool, thanks for sharing it.

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to