本文整理汇总了C++中statik::META方法的典型用法代码示例。如果您正苦于以下问题:C++ statik::META方法的具体用法?C++ statik::META怎么用?C++ statik::META使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类statik
的用法示例。
在下文中一共展示了statik::META方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parser
// Nifty parser
auto_ptr<Rule> exstatik::CreateParser_Nifty() {
auto_ptr<Rule> parser(STAR("parser"));
Rule* stmts_ = parser->AddChild(OR("Or (stmts)"))
->CapOutput("stmt");
/*
Rule* cmd_ = stmts_->AddChild(SEQ("cmd stmt"));
cmd_->AddChild(META("cmd", "ID"));
Rule* cmdexts_ = cmd_->AddChild(STAR("cmdexts"));
Rule* cmdext_ = cmdexts_->AddChild(SEQ("cmdext"));
cmdext_->AddChild(META("cmd", "WS"));
cmdext_->AddChild(META("cmd", "ID"));
*/
Rule* newstmt_ = stmts_->AddChild(SEQ("new stmt"));
newstmt_->AddChild(META("new"));
newstmt_->AddChild(META("WS"))
->SilenceOutput();
Rule* newor_ = newstmt_->AddChild(STAR("new*"));
newor_->AddChildRecursive(newstmt_);
newstmt_->AddChild(META("identifier", "ID"));
newstmt_->AddChild(META(";"))
->SilenceOutput();
Rule* delstmt_ = stmts_->AddChild(SEQ("del stmt"));
delstmt_->AddChild(META("del"));
delstmt_->AddChild(META("WS"))
->SilenceOutput();
delstmt_->AddChild(META("identifier", "ID"));
delstmt_->AddChild(META(";"))
->SilenceOutput();
return parser;
}
示例2: while
// C parser
auto_ptr<Rule> exstatik::CreateParser_C() {
auto_ptr<Rule> identifier_(META("identifier", "ID")); // goto_statement_
auto_ptr<Rule> integer_constant_(META("integer", "INT")); // constant_
auto_ptr<Rule> character_constant_(META("char", "CHAR")); // constant_
auto_ptr<Rule> floating_constant_(META("float", "FLOAT")); // constant_
auto_ptr<Rule> enumeration_constant_(META("enum", "ENUM")); // constant_
auto_ptr<Rule> constant_(OR("constant")); // FAKE constant_expression_
constant_->AddChild(integer_constant_);
constant_->AddChild(character_constant_);
constant_->AddChild(floating_constant_);
constant_->AddChild(enumeration_constant_);
/*
postfix-expression:
primary-expression
postfix-expression [ expression ]
postfix-expression ( argument-expression-list_OPT )
postfix-expression . identifier
postfix-expression -> identifier
postfix-expression ++
postfix-expression --
primary-expression:
identifier
constant
string
( expression )
argument-expression-list:
assignment-expression
argument-expression-list , assignment-expression
*/
auto_ptr<Rule> unary_operator_(OR("unary-operator"));
unary_operator_->AddChild(META("&", "&"));
unary_operator_->AddChild(META("*", "*"));
unary_operator_->AddChild(META("+", "+"));
unary_operator_->AddChild(META("-", "-"));
unary_operator_->AddChild(META("~", "~"));
unary_operator_->AddChild(META("!", "!"));
// FAKE
auto_ptr<Rule> constant_expression_(constant_); // FAKE direct-declarator-suffix-1
/*
conditional-expression:
logical-OR-expression
logical-OR-expression ? expression : conditional-expression
constant-expression:
conditional-expression
logical-OR-expression:
logical-AND-expression
logical-OR-expression || logical-AND-expression
logical-AND-expression:
inclusive-OR-expression
logical-AND-expression && inclusive-OR-expression
inclusive-OR-expression:
exclusive-OR-expression
inclusive-OR-expression | exclusive-OR-expression
exclusive-OR-expression:
AND-expression
exclusive-OR-expression ^ AND-expression
AND-expression:
equality-expression
AND-expression & equality-expression
equality-expression:
relational-expression
equality-expression == relational-expression
equality-expression != relational-expression
relational-expression:
shift-expression
relational-expression < shift-expression
relational-expression > shift-expression
relational-expression <= shift-expression
relational-expression >= shift-expression
shift-expression:
additive-expression
shift-expression << additive-expression
shift-expression >> additive-expression
additive-expression:
multiplicative-expression
additive-expression + multiplicative-expression
additive-expression - multiplicative-expression
multiplicative-expression:
cast-expression
multiplicative-expression * cast-expression
multiplicative-expression / cast-expression
multiplicative-expression % cast-expression
cast-expression:
unary-expression
( type-name ) cast-expression
unary-expression:
postfix-expression
++ unary-expression
-- unary-expression
unary-operator cast-expression
sizeof unary-expression
sizeof ( type-name )
*/
//.........这里部分代码省略.........