I'm trying to parse this fragment of C code:
void foo(const int *bar, int * const baz);
using GnuCParser
, part of pycparserext.
Based on this answer I expected to see some PtrDecl
s, but here's what I get from ast.show()
on the resulting parse tree:
FileAST:
Decl: foo, [], [], []
FuncDecl:
ParamList:
Decl: bar, ['const'], [], []
TypeDeclExt: bar, ['const']
IdentifierType: ['int']
Decl: baz, [], [], []
TypeDeclExt: baz, []
IdentifierType: ['int']
TypeDecl: foo, []
IdentifierType: ['void']
Notice how baz
, a "const pointer to int
", doesn't have a trace of const
(or "pointeryness") in the data printed by ast.show()
. Is this difference because of GnuCParser
?
How do I figure out the type of baz
from the AST? My actual C code needs the GNU parser. I'm using pycparserext version 2016.1.
UPDATE: I've created a pycparserext issue on GitHub.