I am practicing using Spirit x3 to parse C language and store it in a custom data structure.
But I encountered huge difficulties and still couldn't compile after 5 days.
Most of the errors prompted are incomplete structures and cannot be assigned.
But I carefully checked that there were no incomplete data structures.
For example, the following structure cannot be converted:

Who accepts this challenge to help modify the code and make it compile。 The code of the git repository can be cloned and modified at will:
That's not what the complaints are about. It says "incompatible", not "incomplete". There are things that do not convert.
Using this adhoc CMakeLists.txt
After a few cleanup/review commits I ended up with the first propagation related error for
You can tell from the rule tag in the error message here:
The AST being:
I can see how you expect that to match, but Spirit can't:
/home/sehe/custom/superboost/libs/spirit/include/boost/spirit/home/x3/support/ast/variant.hpp|184 col 17| error: no match for ‘operator=’ (operand types are ‘boost::spirit::x3::variant<ast::test::init_declarator_1, boost::spirit::x3::forward_ast<ast::test::declarator> >::variant_type’ and ‘boost::fusion::deque<ast::test::declarator, ast::test::initializer>’)How can you assign
fusion::deque<...>toinit_declarator_1? I know you adapted it, but X3 has no contextual clue what to synthesize. Make the rule explicit:Now it compiles, and the next hiccup is in
selection_statement_class. Rinse and repeat from here.Summary
Debug your attribute compatibility. Ideally, start with SMALL subgrammars, only preceed to the higher level productions IFF the lower-level productions all compile and propagate correctly.
You may note that this is a basic tenet of test-driven programming. Really you cannot expect to grind your way through the error novels if you don't limit the scope to look for context.
BONUS
Note that I tend to use a type-coercion facility to make the above easier:
Now you can write the above anonymous rule like
When you go and fix the
selection_statementplease do yourself a favour and stop using inscrutable names likeselection_statement_1. We are humans, not code generators.Really what you need is rules like:
And the AST to match:
PEG grammar isn't BNF. Also, Spirit is an eDSL for parser specification. Your goal is not a machine translation but a maintainable, productive parser generator.