Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using OpenCLCParser with cpp breaks show() #27

Open
ChrisCummins opened this issue Apr 10, 2017 · 1 comment
Open

Using OpenCLCParser with cpp breaks show() #27

ChrisCummins opened this issue Apr 10, 2017 · 1 comment

Comments

@ChrisCummins
Copy link

Hi,

given this simple test file:

$ cat kernel.cl
void A() {}

The output of parse_file() is different when using the OpenCLCparser vs the pycparser default:

>>> parse_file("kernel.cl", use_cpp=True).children()
(('ext[0]', <pycparser.c_ast.FuncDef at 0x7f986ea2e2c8>),)

>>> parse_file("kernel.cl", use_cpp=True, parser=OpenCLCParser()).children()
(('ext[0]', [<pycparserext.ext_c_parser.PreprocessorLine at 0x7f986ea31240>]),
 ('ext[1]', [<pycparserext.ext_c_parser.PreprocessorLine at 0x7f986ea314e0>]),
 ('ext[2]', [<pycparserext.ext_c_parser.PreprocessorLine at 0x7f986ea271d0>]),
 ('ext[3]', [<pycparserext.ext_c_parser.PreprocessorLine at 0x7f986eacc898>]),
 ('ext[4]', [<pycparserext.ext_c_parser.PreprocessorLine at 0x7f986ea31470>]),
 ('ext[5]', [<pycparserext.ext_c_parser.PreprocessorLine at 0x7f986ea31128>]),
 ('ext[6]', <pycparser.c_ast.FuncDef at 0x7f986ed6b908>))

This breaks the behaviour of the show() method:

>>> parse_file("kernel.cl", use_cpp=True, parser=OpenCLCParser()).show()
Traceback (most recent call last)
...
AttributeError: 'list' object has no attribute 'show'

What is the meaning of the PreprocessorLine objects? Is there a way I can disable their creation, or have I misunderstood the API?

$ pip freeze | grep pycp
pycparser==2.17
pycparserext==2016.2
@ChrisCummins
Copy link
Author

By the way, this is the workaround I'm currently using. Stripping out the PreprocessorLines and constructing a new FileAST. It seems to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant