speedy-antlr-tool icon indicating copy to clipboard operation
speedy-antlr-tool copied to clipboard

tree.parser attribute is None

Open m-zakeri opened this issue 3 years ago • 2 comments

It seems that the tree.parser attribute does not set to its correct reference when using USE_CPP_BACKEND to create a parse tree. It returns None. However, this attribute is set to a valid reference of ANTLR parser when using Python backend It is required to initialize the TokenStreamRewriter class with parse tree tokens in the following code (line 4 raise an exception): 'NoneType' object has no attribute 'getInputStream'

file_stream = FileStream(java_file_path)
sa_javalabeled.USE_CPP_IMPLEMENTATION = config.USE_CPP_BACKEND
tree = sa_javalabeled.parse(file_stream, 'compilationUnit')
tokens = tree.parser.getInputStream()
rewriter = TokenStreamRewriter(tokens)

m-zakeri avatar Jan 09 '22 11:01 m-zakeri

I also watched that token_stream.fill(); is called in C++ do_parse function but it did not affects the returned PyObject.

m-zakeri avatar Jan 09 '22 11:01 m-zakeri

It seems that the tree.parser attribute does not set to its correct reference when using USE_CPP_BACKEND to create a parse tree. It returns None. However, this attribute is set to a valid reference of ANTLR parser when using Python backend It is required to initialize the TokenStreamRewriter class with parse tree tokens in the following code (line 4 raise an exception): 'NoneType' object has no attribute 'getInputStream'

file_stream = FileStream(java_file_path)
sa_javalabeled.USE_CPP_IMPLEMENTATION = config.USE_CPP_BACKEND
tree = sa_javalabeled.parse(file_stream, 'compilationUnit')
tokens = tree.parser.getInputStream()
rewriter = TokenStreamRewriter(tokens)

Can anyone help me implement the binding of the input stream tokens?

m-zakeri avatar Apr 30 '22 05:04 m-zakeri