Organization of a parser project using boost spirit x3

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Organization of a parser project using boost spirit x3

Exagon
I am currently using boos spirit x3 to implement a DSL which compiles to C code.
Right now my parser is header only, so a rule in a .hpp look loke this:

typedef x3::rule<struct rule_class, ast::RuleAttr> rule_type;

const rule_type rule = "rule";

auto const rule_def = "foo" >> "bar" >> "baz";

BOOST_SPIRIT_DEFINE(rule)


In a lot of examples I am looking through BOOST_SPIRIT_INSTATNIATE, and BOOST_SPIRIT_DECLARE is used and the parser is spilted into different files.

Whats best practice when building a parser using spirit x3?
How should I use BOOST_SPIRIT_INSTATNIATE, BOOST_SPIRIT_DECLARE and BOOST_SPIRIT_DEFINE?
And how should I splitt my parser in different files?

\Exagon