[antlr-interest] Bug report for python-antlr3: None --> rulePostProcessing(...) --> None --> replaceChildren(..., None)
Jim Idle
jimi at temporal-wave.com
Tue May 31 06:41:51 PDT 2011
A set of nodes that is ^(NODE) is actually NODE, so you need:
: ^(DOT_DOT_NAME
( ARGS // No args (perhaps don't write if no args?
| ^(ARGS DOT_DOT_ARGS)
)
DOT_DOT_BODY?
)
;
Note that there is no root if the tree is just a single token. Generally:
X A* -> ^(X A*)
Will parse as:
r: X // No As
| ^(X A+) // Some As
;
Jim
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of ?????? ????
> Sent: Tuesday, May 31, 2011 12:23 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Bug report for python-antlr3: None -->
> rulePostProcessing(...) --> None --> replaceChildren(..., None)
>
> 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
More information about the antlr-interest
mailing list