inducer / inducer/pycparserext

Using OpenCLCParser with cpp breaks show()

Open
#27 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
91
Forks
30
PR merge metrics
No merged PRs in 30d

Description

Hi,

given this simple test file:

```sh
$ cat kernel.cl
void A() {}
```

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

```py
>>> parse_file("kernel.cl", use_cpp=True).children()
(('ext[0]', ),)

>>> parse_file("kernel.cl", use_cpp=True, parser=OpenCLCParser()).children()
(('ext[0]', []),
('ext[1]', []),
('ext[2]', []),
('ext[3]', []),
('ext[4]', []),
('ext[5]', []),
('ext[6]', ))
```

This breaks the behaviour of the `show()` method:

```py
>>> 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?

```sh
$ pip freeze | grep pycp
pycparser==2.17
pycparserext==2016.2
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the parse_file("kernel.cl", use_cpp=True, parser=OpenCLCParser()) example and compare its children() output with the default parser. Read the OpenCLCParser and show() entry points to determine how PreprocessorLine objects are represented and whether list-valued children are expected. Done means the intended API behavior is established and show() no longer fails for this example, with a regression test for the demonstrated case.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.