Skip to content

Using OpenCLCParser with cpp breaks show() #27

Description

@ChrisCummins

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions