Skip to content
New issue

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

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

Already on GitHub? # to your account

GNU C array init with "..." not supported #22

Closed
unwind opened this issue Oct 26, 2016 · 1 comment · Fixed by #53
Closed

GNU C array init with "..." not supported #22

unwind opened this issue Oct 26, 2016 · 1 comment · Fixed by #53

Comments

@unwind
Copy link

unwind commented Oct 26, 2016

This is a GNU extension, see Designated Inits in the GCC manual. However, the GnuCParser doesn't cope:

>>> from pycparserext.ext_c_parser import GnuCParser
>>> p=GnuCParser()
>>> p.parse("int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files (x86)\Python27\lib\site-packages\pycparserext\ext_c_parser.py", line 64, in parse
    return self.cparser.parse(text, lexer=self.clex, debug=debuglevel)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pycparser\ply\yacc.py", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pycparser\ply\yacc.py", line 1181, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pycparser\ply\yacc.py", line 193, in call_errorfunc
    r = errorfunc(token)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pycparser\c_parser.py", line 1721, in p_error
    column=self.clex.find_tok_column(p)))
  File "C:\Program Files (x86)\Python27\lib\site-packages\pycparser\plyparser.py", line 55, in _parse_error
    raise ParseError("%s: %s" % (coord, msg))
pycparser.plyparser.ParseError: :1:21: before: ...

Tested with pycparserext 2016.2.

No idea if this is supposed to be supported, but I had an instance of this in my code so I ran into it.

@inducer
Copy link
Owner

inducer commented Oct 26, 2016

Not currently supported, but I'd be happy to take a patch.

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

Successfully merging a pull request may close this issue.

2 participants