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


C++ Preprocessor::LexUnexpandedToken方法代码示例

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


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

示例1: HandlePragma

void PragmaRecorder::HandlePragma(clang::Preprocessor &PP,
                                  clang::PragmaIntroducerKind Introducer,
                                  clang::Token &FirstToken) {
  clang::Token &CurrentToken = FirstToken;
  std::string PragmaName, PragmaValue = "";
  // Pragma in ACC should be a name/value pair

  if (GetPragmaNameFromToken(FirstToken, PragmaName)) {
    // start parsing the value '(' PragmaValue ')', if we have one.
    const clang::Token* NextToken = &PP.LookAhead(0);

    if (NextToken->is(clang::tok::l_paren))
      PP.LexUnexpandedToken(CurrentToken);
    else
      goto end_parsing_pragma_value;

    NextToken = &PP.LookAhead(0);
    if (GetPragmaValueFromToken(*NextToken, PragmaValue)) {
      PP.Lex(CurrentToken);
    } else {
      PP.LexUnexpandedToken(CurrentToken);
      PP.Diag(NextToken->getLocation(),
              PP.getDiagnostics().getCustomDiagID(
                  clang::DiagnosticsEngine::Error,
                  "expected value after '#pragma %0('")) << PragmaName;
      return;
    }

    if (!NextToken->is(clang::tok::r_paren)) {
      NextToken = &PP.LookAhead(0);
      if (NextToken->is(clang::tok::r_paren)) {
        PP.LexUnexpandedToken(CurrentToken);
      } else {
        PP.LexUnexpandedToken(CurrentToken);
        PP.Diag(NextToken->getLocation(),
                PP.getDiagnostics().getCustomDiagID(
                    clang::DiagnosticsEngine::Error,
                    "missing ')' after '#pragma %0(%1'"))
            << PragmaName << PragmaValue;
        return;
      }
    }
  } else {
    PP.Diag(FirstToken.getLocation(),
            PP.getDiagnostics().getCustomDiagID(
                clang::DiagnosticsEngine::Error,
                "no pragma name or value"));
    return;
  }

 end_parsing_pragma_value:

  // PragmaValue may be an empty string.
  mPragmas->push_back(make_pair(PragmaName, PragmaValue));

  // Inform lex to eat the token
  PP.LexUnexpandedToken(CurrentToken);

  return;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_frameworks_compile_slang,代码行数:60,代码来源:slang_pragma_recorder.cpp

示例2: HandlePragma

void PragmaRecorder::HandlePragma(clang::Preprocessor &PP,
                                  clang::PragmaIntroducerKind Introducer,
                                  clang::Token &FirstToken) {
    clang::Token &CurrentToken = FirstToken;
    std::string PragmaName, PragmaValue = "";
    // Pragma in ACC should be a name/value pair

    if (GetPragmaNameFromToken(FirstToken, PragmaName)) {
        // start parsing the value '(' PragmaValue ')'
        const clang::Token* NextToken = &PP.LookAhead(0);

        if (NextToken->is(clang::tok::l_paren))
            PP.LexUnexpandedToken(CurrentToken);
        else
            goto end_parsing_pragma_value;

        NextToken = &PP.LookAhead(0);
        if (GetPragmaValueFromToken(*NextToken, PragmaValue))
            PP.Lex(CurrentToken);
        else
            goto end_parsing_pragma_value;

        if (!NextToken->is(clang::tok::r_paren)) {
            NextToken = &PP.LookAhead(0);
            if (NextToken->is(clang::tok::r_paren))
                PP.LexUnexpandedToken(CurrentToken);
            else
                goto end_parsing_pragma_value;
        }

        // Until now, we ensure that we have a pragma name/value pair
        mPragmas->push_back(make_pair(PragmaName, PragmaValue));
    }

end_parsing_pragma_value:
    // Inform lex to eat the token
    PP.LexUnexpandedToken(CurrentToken);

    return;
}
开发者ID:hhachutw,项目名称:MTK6577,代码行数:40,代码来源:slang_pragma_recorder.cpp


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