Parsing struct within struct in C using pycparser?
<p>I have this example c file I want to parse:</p>

<pre><code>StrcutWithinStruct.c
// simple struct within a struct example

struct A {
 int a;
};

struct B {
 A a;
 int b;
};
</code></pre>

<p>I'm running <a href="https://github.com/eliben/pycparser" rel="nofollow noreferrer">pcyparser</a> to parse it, with the following code </p>

<pre><code>exploreStruct.py
#parse StructWithinStruct

from pycparser import parse_file
ast = parse_file(filename='..\StructWithinStruct.c')
ast.show()
</code></pre>

<p>As a result, I got the following:</p>

<pre><code>Tracback (most recent call last):
  File "exploreStruct.py", line 3, in &lt;module&gt;
   ast = parse_file(filename='...\StructWithinStruct.c')
  File "D:\...\pycparser\__init__.py", line 93, in parse_file
   return parser.parse(text,filename)
  File "D:\...\pycparser\c_parser.py", line 146, in parse
   debug=debug_level)
  File "D:\...\pycparser\yacc.py", line 331, in parse
   return self.parseropt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "D:\...\pycparser\yacc.py", line 1181, in parseropt_notrack
   tok=call_errorfunc(self.errorfunc, errtoken, self)
  File "D:\...\pycparser\yacc.py", line 193, in call_errorfunc
   r=errorfunc(token)
  File "D:\...\pycparser\c_parser.py", line 1699, in p_error
   column=self.clex.find_tok_column(p)))
  File "D:\...\pycparser\plyparser.py", line 55, in _parse_error
   raise ParseError("%s: %s % (coord, msg))
pycparser.plyparser.ParserError: D:...\StructWithinStruct.c:7:2: Before A
</code></pre>

<p>So, is pycparser can handle struct within struct, or not?
I thought this is some basic requirement, so I'm pretty sure that the problem lying in my configuration somewhere...</p>

<p><strong>One more thing:</strong> I know that pcypareser author, @<a href="https://stackoverflow.com/users/8206/eli-bendersky">Eli Bendersky</a>, says that one should <a href="http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang" rel="nofollow noreferrer">use Clang to parse C++</a>, but I will like to know if there's another option nowadays to parse C++ (preferably over Python), and is user-friendly.</p>

<p>Thanks.</p>