Donate Bitcoins
What changes do you want to see?
struct Statement {
typedef boost::variant< boost::recursive_wrapper<CompoundStatement>,
boost::recursive_wrapper<IfStatement>,
VarStatement > Type0;
Type0 stmt;

Statement()
: stmt()
{}

Statement(const CompoundStatement& cs)
: stmt(cs)
{}

Statement(const IfStatement& is)
: stmt(is)
{}

Statement(const VarStatement& vs)
: stmt(vs)
{}
};

struct IfStatement {
typedef double Type0;
typedef Statement Type1;
typedef boost::optional<Statement> Type2;

Type0 expr;
Type1 trueStmt;
Type2 falseStmt;
};

BOOST_FUSION_ADAPT_STRUCT(
Lang::IfStatement,
(Lang::IfStatement::Type0, expr)
(Lang::IfStatement::Type1, trueStmt)
(Lang::IfStatement::Type2, falseStmt)
)

BOOST_FUSION_ADAPT_STRUCT(
Lang::Statement,
(Lang::Statement::Type0, stmt)
)

if_statement
%= "if"
> qi::double_
> statement
>> -("else" > statement)
;

statement
%= var_statement
| if_statement
| compound_statement
;

qi::rule<IterT, Lang::IfStatement(), ascii::space_type> if_statement;
qi::rule<IterT, Lang::Statement(), ascii::space_type> statement;
View count: 355

Enjoy the site? All donations are appreciated. Paypal or BTC

Donate Bitcoins
Free Text Host is brought to you by Dagon Design
This site contains no adware, spyware, or popups
Questions? Comments?     Privacy Policy     Report abuse here