Closed retif closed 4 months ago
Hello, while trying to run project https://gitlab.com/matpi/pipewire-py
I get an error
State : 406 Stack : declaration_specifiers id_declarator declaration_list_opt brace_open unary_expression assignment_operator LPAREN expression RPAREN . LexToken(ID,'spa_meta_first',3,135) ERROR: Error : declaration_specifiers id_declarator declaration_list_opt brace_open unary_expression assignment_operator LPAREN expression RPAREN . LexToken(ID,'spa_meta_first',3,135) Traceback (most recent call last): File "/home/oleks/projects/pipewire-py/bug/program.py", line 16, in <module> parser.parse(PREPROCESSED_SOURCE, debug=True) File "/home/oleks/.local/lib/python3.12/site-packages/pycparser/c_parser.py", line 147, in parse return self.cparser.parse( ^^^^^^^^^^^^^^^^^^^ File "/home/oleks/.local/lib/python3.12/site-packages/pycparser/ply/yacc.py", line 327, in parse return self.parsedebug(input, lexer, debug, tracking, tokenfunc) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/oleks/.local/lib/python3.12/site-packages/pycparser/ply/yacc.py", line 601, in parsedebug tok = call_errorfunc(self.errorfunc, errtoken, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/oleks/.local/lib/python3.12/site-packages/pycparser/ply/yacc.py", line 193, in call_errorfunc r = errorfunc(token) ^^^^^^^^^^^^^^^^ File "/home/oleks/.local/lib/python3.12/site-packages/pycparser/c_parser.py", line 1945, in p_error self._parse_error( File "/home/oleks/.local/lib/python3.12/site-packages/pycparser/plyparser.py", line 67, in _parse_error raise ParseError("%s: %s" % (coord, msg)) pycparser.plyparser.ParseError: :3:21: before: spa_meta_first
Here is the test python code with extracted code sample leading to the error
import pycparser PREPROCESSED_SOURCE = """ static inline int spa_debugc_buffer(struct spa_debug_context *ctx, int indent, const struct spa_buffer *buffer) { (h) = (__typeof)spa_meta_first(m); for ((h) = (__typeof(h))spa_meta_first(m); spa_meta_check(h, m); (h)++) { } return 0; } """ parser = pycparser.CParser(yacc_debug=True) parser.parse(PREPROCESSED_SOURCE, debug=True)
The error happens at (h) = (__typeof(h))spa_meta_first(m); because of __typeof(h) type casting which seems not considered as a valid cast type for a parser, but initial code source uses this construct and compiles fine. This is a pcpp.Preprocessor preprocessed code from https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/spa/include/spa/buffer/meta.h?ref_type=heads#L90
(h) = (__typeof(h))spa_meta_first(m);
Is this a parser bug?
got to a conclusion that this issue is more relevant to pycparserext
Hello, while trying to run project https://gitlab.com/matpi/pipewire-py
I get an error
Here is the test python code with extracted code sample leading to the error
The error happens at
(h) = (__typeof(h))spa_meta_first(m);
because of __typeof(h) type casting which seems not considered as a valid cast type for a parser, but initial code source uses this construct and compiles fine. This is a pcpp.Preprocessor preprocessed code from https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/spa/include/spa/buffer/meta.h?ref_type=heads#L90Is this a parser bug?