Skip to content

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

@unwind

Description

@unwind

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.

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