42 #include <boost/bind.hpp> 43 #include <boost/lambda/lambda.hpp> 47 #pragma optimize( "", off) 53 using namespace boost;
54 using namespace detail;
57 boost::spirit::classic::assertion<std::string> expect_ifblock(
"Expected a statement (or { block } ).");
58 boost::spirit::classic::assertion<std::string> expect_then(
"Wrongly formatted \"if ... then\" clause.");
59 boost::spirit::classic::assertion<std::string> expect_elseblock(
"Expected a statement (or {block} ) after else.");
60 boost::spirit::classic::assertion<std::string> expect_ident(
"Expected a valid identifier.");
63 void ProgramGraphParser::setup2()
68 >> expect_ident( commonparser.identifier[boost::bind( &ProgramGraphParser::seenfuncidentifier,
this, _1, _2) ] )
69 >> !arguments[ boost::bind( &ProgramGraphParser::seencallfuncargs,
this )]
70 )[ boost::bind( &ProgramGraphParser::seencallfuncstatement,
this ) ];
74 (
keyword_p(
"return" )[boost::bind(&ProgramGraphParser::noskip_eol,
this )]
75 >> ( eps_p(commonparser.notassertingeos) | expressionparser.parser()[boost::bind( &ProgramGraphParser::seenreturnvalue,
this ) ] )[boost::bind(&ProgramGraphParser::skip_eol,
this )])[ boost::bind( &ProgramGraphParser::seenreturnstatement,
this ) ];
79 keyword_p(
"break" )[ boost::bind (&ProgramGraphParser::seenbreakstatement,
this) ];
81 catchpart = (
keyword_p(
"catch") [boost::bind(&ProgramGraphParser::startcatchpart,
this)]
82 >> expect_ifblock( ifblock ) )[boost::bind(&ProgramGraphParser::seencatchpart,
this)];
84 forstatement = (
keyword_p(
"for") >> openbrace
85 >> !(valuechangeparser.parser()[boost::bind(&ProgramGraphParser::seenforinit,
this)]
87 expressionparser.parser()[boost::bind(&ProgramGraphParser::seenforinit_expr,
this)])>> semicolon
88 >> condition >> semicolon >> !
keyword_p(
"set")
89 >> ( (expressionparser.parser()[boost::bind(&ProgramGraphParser::seenforincr,
this)] >> closebrace ) | closebrace[boost::bind(&ProgramGraphParser::seenemptyforincr,
this)])
90 ) [boost::bind(&ProgramGraphParser::seenforstatement,
this)]
91 >> expect_ifblock( ifblock[ boost::bind(&ProgramGraphParser::endforstatement,
this) ]);
95 >> expect_then(
keyword_p(
"then")[boost::bind(&ProgramGraphParser::seenifstatement,
this)] )
96 >> expect_ifblock( ifblock[ boost::bind(&ProgramGraphParser::endifblock,
this) ] )
97 >> !(
keyword_p(
"else") >> expect_elseblock(ifblock) )
98 )[ boost::bind(&ProgramGraphParser::endifstatement,
this) ];
101 ifblock = ( ch_p(
'{') >> *line >> closecurly ) | statement;
106 [boost::bind(&ProgramGraphParser::seenwhilestatement,
this)]
107 >> expect_ifblock( ifblock[ boost::bind(&ProgramGraphParser::endwhilestatement,
this) ] );
109 continuepart =
keyword_p(
"continue")[ boost::bind( &ProgramGraphParser::seencontinue,
this)];
#define keyword_p(word)
Returns a rule which parses a keyword followed by a non-identifier character, newline or semicolon...
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.