Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Failure parsing unnamed function parameters with array dim qualifiers #314

Closed
amirgon opened this issue Mar 25, 2019 · 1 comment
Closed

Comments

@amirgon
Copy link
Contributor

amirgon commented Mar 25, 2019

Consider the following:

from pycparser import c_parser, c_ast, c_generator
parser = c_parser.CParser()
gen = c_generator.CGenerator()

ast1 = parser.parse("int g(int i[const 20]);")
ast2 = parser.parse("int g(int[20]);")
ast3 = parser.parse("int g(int[const 20]);")

This code will fail on the last line:

>>> ast3 = parser.parse("int g(int[const 20]);")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pycparser/c_parser.py", line 152, in parse
    debug=debuglevel)
  File "pycparser/ply/yacc.py", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "pycparser/ply/yacc.py", line 1199, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "pycparser/ply/yacc.py", line 193, in call_errorfunc
    r = errorfunc(token)
  File "pycparser/c_parser.py", line 1847, in p_error
    column=self.clex.find_tok_column(p)))
  File "pycparser/plyparser.py", line 67, in _parse_error
    raise ParseError("%s: %s" % (coord, msg))
pycparser.plyparser.ParseError: :1:11: before: const
@eliben
Copy link
Owner

eliben commented Mar 26, 2019

Thanks for the report. Feel free to submit a PR

saullocarvalho added a commit to saullocarvalho/pycparser that referenced this issue May 31, 2019
@eliben eliben closed this as completed in dd6b6f1 Jun 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants