本文整理汇总了C++中statik::OR方法的典型用法代码示例。如果您正苦于以下问题:C++ statik::OR方法的具体用法?C++ statik::OR怎么用?C++ statik::OR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类statik
的用法示例。
在下文中一共展示了statik::OR方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parser
// parser = ((cmd|codeblock)end)*
auto_ptr<Rule> exstatik::CreateParser_Complex() {
auto_ptr<Rule> parser(STAR("parser"));
Rule* line = parser->AddChild(SEQ("line"));
//line->AddChild(META("WS"));
Rule* cmdorcode = line->AddChild(OR("Or (cmdorcode)"));
Rule* end = line->AddChild(OR("end"));
end->AddChild(META(";"));
end->AddChild(META("\n"));
Rule* cmdline = cmdorcode->AddChild(SEQ("cmdline"));
cmdline->AddChild(META("ID", "program"));
Rule* cmdargs = cmdline->AddChild(STAR("* (cmdargs)"));
Rule* cmdarg = cmdargs->AddChild(SEQ("cmdarg"));
cmdarg->AddChild(META("WS"));
cmdarg->AddChild(META("arg"));
Rule* codeblock = cmdorcode->AddChild(SEQ("codeblock"));
codeblock->AddChild(META("{"));
Rule* stmts = codeblock->AddChild(STAR("* (stmts)"));
codeblock->AddChild(META("}"));
Rule* stmt = stmts->AddChild(OR("Or (stmt)"));
Rule* newstmt = stmt->AddChild(SEQ("new stmt"));
newstmt->AddChild(META("new"));
newstmt->AddChild(META("WS"));
newstmt->AddChild(META("identifier", "ID"));
newstmt->AddChild(META(";"));
Rule* delstmt = stmt->AddChild(SEQ("del stmt"));
delstmt->AddChild(META("del"));
delstmt->AddChild(META("WS"));
delstmt->AddChild(META("identifier", "ID"));
delstmt->AddChild(META(";"));
return parser;
}
示例2: lexer
auto_ptr<Rule> exstatik::CreateLexer_Splash() {
auto_ptr<Rule> lexer(STAR("star"));
Rule* or_ = lexer->AddChild(OR("or"));
or_->AddChild(KEYWORD("cat"));
or_->AddChild(KEYWORD("dog"));
or_->AddChild(KEYWORD("car"));
return lexer;
}
示例3: lexer
auto_ptr<Rule> exstatik::CreateLexer_Nick() {
auto_ptr<Rule> lexer(STAR("star"));
Rule* or1_ = lexer->AddChild(OR("or1"));
or1_->AddChild(KEYWORD("car"));
or1_->AddChild(KEYWORD("cat"));
Rule* star2_ = or1_->AddChild(STAR("star2"));
star2_->AddChild(KEYWORD("dog"));
return lexer;
}
示例4: 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 )
*/
//.........这里部分代码省略.........