inducer / pycparserext

Extensions for Eli Bendersky's pycparser
http://pypi.python.org/pypi/pycparserext
Other
83 stars 28 forks source link

Array attributes unsupported #10

Closed Smattr closed 9 years ago

Smattr commented 9 years ago

Example of this at the bottom. I'm not sure why attributes on arrays are not supported and whether this is a deliberate choice. I can't promise anything soon, but if you're happy to accept a pull request for this I can have a go at implementing it sometime.

By the way, impressive work with this project!

pycparserext: 2013.2 python-ply: 3.4-3ubuntu2 python-pycparser: 2.10+dfsg-1ubuntu2

$ cat foo.c
int x[10] __attribute__((unused));

$ cat test.py
from pycparserext.ext_c_parser import GnuCParser
f = open('foo.c', 'r').read()
ast = GnuCParser().parse(f)

$ python test.py
Traceback (most recent call last):
  File "test.py", line 3, in <module>
    ast = GnuCParser().parse(f)
  File "/home/matthew/.local/lib/python2.7/site-packages/pycparserext/ext_c_parser.py", line 65, in parse
    return self.cparser.parse(text, lexer=self.clex, debug=debuglevel)
  File "/usr/lib/python2.7/dist-packages/ply/yacc.py", line 269, in parse
    return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
  File "/usr/lib/python2.7/dist-packages/ply/yacc.py", line 975, in parseopt_notrack
    p.callable(pslice)
  File "/home/matthew/.local/lib/python2.7/site-packages/pycparserext/ext_c_parser.py", line 232, in p_declarator_1
    % type(p[1]))
NotImplementedError: cannot attach attributes to nodes of type '<class 'pycparser.c_ast.ArrayDecl'>'
inducer commented 9 years ago

Certainly not deliberate. I'd appreciate a PR.