当前位置: 首页>>代码示例>>C++>>正文


C++ statik::SEQ方法代码示例

本文整理汇总了C++中statik::SEQ方法的典型用法代码示例。如果您正苦于以下问题:C++ statik::SEQ方法的具体用法?C++ statik::SEQ怎么用?C++ statik::SEQ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在statik的用法示例。


在下文中一共展示了statik::SEQ方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parser

// JSON parser
auto_ptr<Rule> exstatik::CreateParser_JSON() {
  auto_ptr<Rule> parser(STAR("JSON"));
  Rule* var_ = parser->AddChild(SEQ("var"))
    ->CapOutput("var");
  Rule* ws_OPT = var_->AddChild(OPT("ws?"));
  ws_OPT->AddChild(META("WS", "WS"));
  var_->AddChild(META("name", "ID"));
  var_->AddChildRecursive(ws_OPT);
  var_->AddChild(META("=", "="));
  var_->AddChildRecursive(ws_OPT);
  Rule* value_ = var_->AddChild(OR("value"));
  Rule* semi_OPT = var_->AddChild(OPT("semi?"));
  var_->AddChildRecursive(ws_OPT);
  semi_OPT->AddChild(META(";", ";"));
  var_->AddChildRecursive(ws_OPT);

  value_->AddChild(META("string", "STR"));
  Rule* object_ = value_->AddChild(SEQ("object"));

  object_->AddChild(META("{", "{"));
  Rule* var_STAR = object_->AddChild(STAR("varstar"));
  var_STAR->AddChildRecursive(var_);
  object_->AddChild(META("}", "}"));
  return parser;
}
开发者ID:nfomon,项目名称:shok,代码行数:26,代码来源:Parser.cpp

示例2: lexer

auto_ptr<Rule> exstatik::CreateLexer_Seq() {
    auto_ptr<Rule> lexer(SEQ("seq"));
    lexer->AddChild(KEYWORD("cat"));
    lexer->AddChild(KEYWORD("dog"));
    Rule* optmoo = lexer->AddChild(OPT("opt"));
    optmoo->AddChild(KEYWORD("moo"));
    lexer->AddChild(KEYWORD("car"));
    return lexer;
}
开发者ID:Johnicholas,项目名称:shok,代码行数:9,代码来源:Lexer.cpp

示例3: while


//.........这里部分代码省略.........
    unary-expression:
      postfix-expression
      ++ unary-expression
      -- unary-expression
      unary-operator cast-expression
      sizeof unary-expression
      sizeof ( type-name )
  */

  auto_ptr<Rule> assignment_operator_(OR("assignment-operator")); // FAKE assignment_expression_
  assignment_operator_->AddChild(META("=", "="));
  assignment_operator_->AddChild(META("*=", "*="));
  assignment_operator_->AddChild(META("/=", "/="));
  assignment_operator_->AddChild(META("%=", "%="));
  assignment_operator_->AddChild(META("+=", "+="));
  assignment_operator_->AddChild(META("-=", "+="));
  assignment_operator_->AddChild(META("<<=", "<<="));
  assignment_operator_->AddChild(META(">>=", ">>="));
  assignment_operator_->AddChild(META("&=", "&="));
  assignment_operator_->AddChild(META("^=", "^="));
  assignment_operator_->AddChild(META("|=", "|="));

  /*
    expression:
      assignment-expression (, assignmentexpression)*
    assignment-expression:
      conditional-expression
      unary-expression assignment-operator assignment-expression
  */

  // FAKE
  auto_ptr<Rule> assignment_expression_(assignment_operator_);

  auto_ptr<Rule> return_statement_(SEQ("return-statement"));  // jump_statement_
  return_statement_->AddChild(META("return", "return"));
  //return_statement_->AddChild(OPT(expression_));
  return_statement_->AddChild(META(";", ";"));

  auto_ptr<Rule> break_statement_(SEQ("break-statement"));  // jump_statement_
  break_statement_->AddChild(META("break", "break"));
  break_statement_->AddChild(META(";", ";"));

  auto_ptr<Rule> continue_statement_(SEQ("continue-statement"));  // jump_statement_
  continue_statement_->AddChild(META("continue", "continue"));
  continue_statement_->AddChild(META(";", ";"));

  auto_ptr<Rule> goto_statement_(SEQ("goto-statement"));  // jump_statement_
  goto_statement_->AddChild(META("goto", "goto"));
  Rule* identifier_REC = goto_statement_->AddChild(identifier_);
  goto_statement_->AddChild(META(";", ";"));

  auto_ptr<Rule> jump_statement_(OR("jump-statement")); // statement_
  jump_statement_->AddChild(goto_statement_);
  jump_statement_->AddChild(continue_statement_);
  jump_statement_->AddChild(break_statement_);
  jump_statement_->AddChild(return_statement_);

  /*
    labeled-statement:
      identifier : statement
      case constant-expression : statement
      default : statement
    expression-statement:
      expression_OPT ;
    (compound-statement)
    selection-statement:
开发者ID:nfomon,项目名称:shok,代码行数:67,代码来源:Parser.cpp


注:本文中的statik::SEQ方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。