• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TokenPtr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: paramCb

 void paramCb(const TokenPtr& msg)
 {
     if (std::dynamic_pointer_cast<EndOfSequenceMessage const>(msg->getTokenData())) {
         return;
     }
     params_.push_back(msg->getTokenData());
 }
开发者ID:cogsys-tuebingen,项目名称:csapex_core_plugins,代码行数:7,代码来源:get_best_optimization_result.cpp


示例2: SymbolListPtr

void IOBlock::preprocess() {
	// get rid of the beginning and end parens
	this->get_unprocessed()->erase(this->get_unprocessed()->begin());
	this->get_unprocessed()->erase(this->get_unprocessed()->end() - 1);
	if (this->action == IO_WRITE) {
		SymbolListPtr pre = SymbolListPtr(new SymbolList());
		for (auto i = this->get_unprocessed()->begin();
			 i != this->get_unprocessed()->end(); i++) {
			TokenPtr t = *i;
			if (t->get_token() != MP_COMMA) {
				SymbolPtr p = translate(t);
				pre->push_back(p);
			} else {
				// reset
				this->expressions->push_back(pre);
				pre = SymbolListPtr(new SymbolList());
			}
		}
		this->expressions->push_back(pre);
	} else if (this->action == IO_READ) {
		for (auto i = this->get_unprocessed()->begin();
			 i != this->get_unprocessed()->end(); i++) {
			TokenPtr t = *i;
			if (t->get_token() != MP_COMMA) {
				SymbolPtr p = translate(t);
				this->get_symbol_list()->push_back(p);
			}
		}
	}
}
开发者ID:jonfast565,项目名称:Mikropascal-Compiler,代码行数:30,代码来源:SemanticAnalyzer.cpp


示例3: assert

void Document::_processBlocksItems(TokenPtr inTokenContainer) {
	if (!inTokenContainer->isContainer()) return;

	token::Container *tokens=dynamic_cast<token::Container*>(inTokenContainer.get());
	assert(tokens!=0);

	TokenGroup processed;

	for (TokenGroup::const_iterator ii=tokens->subTokens().begin(),
		iie=tokens->subTokens().end(); ii!=iie; ++ii)
	{
		if ((*ii)->text()) {
			optional<TokenPtr> subitem;
			if (!subitem) subitem=parseHeader(ii, iie);
			if (!subitem) subitem=parseHorizontalRule(ii, iie);
			if (!subitem) subitem=parseListBlock(ii, iie);
			if (!subitem) subitem=parseBlockQuote(ii, iie);
			if (!subitem) subitem=parseCodeBlock(ii, iie);

			if (subitem) {
				_processBlocksItems(*subitem);
				processed.push_back(*subitem);
				if (ii==iie) break;
				continue;
			} else processed.push_back(*ii);
		} else if ((*ii)->isContainer()) {
			_processBlocksItems(*ii);
			processed.push_back(*ii);
		}
	}
	tokens->swapSubtokens(processed);
}
开发者ID:Cargo2k,项目名称:simplestCMS,代码行数:32,代码来源:markdown.cpp


示例4: DefineOprt

/** \brief Define a binary operator.
        \param a_pCallback Pointer to the callback object
  */
void ParserXBase::DefineOprt(const TokenPtr<IOprtBin> &oprt)
{
    if (IsOprtDefined(oprt->GetIdent()))
        throw ParserError(ErrorContext(ecFUNOPRT_DEFINED, 0, oprt->GetIdent()));

    oprt->SetParent(this);
    m_OprtDef[oprt->GetIdent()] = ptr_tok_type(oprt->Clone());
}
开发者ID:tomilov,项目名称:math-parser-benchmark-project,代码行数:11,代码来源:mpParserBase.cpp


示例5: style

/**
 * Style text based on the token for the length given
 */
void FbEditor::style(int length, TokenPtr token)
{
    if (token->getKind() == TokenKind::Invalid || !token->isValid()) {
        SetIndicatorCurrent(ErrorIndicator);
        IndicatorFillRange(GetEndStyled(), length);
    }
    style(length, _tokenStyles[(int)token->getKind()]);
}
开发者ID:albeva,项目名称:fbide-test-ast,代码行数:11,代码来源:FbEditor.cpp


示例6: write_raw

void LoopBlock::generate_pre() {
	if (this->type == RPTUNTLLOOP) {
		write_raw(this->body_label + ":\n");
	} else if (this->type == WHILELOOP) {
		write_raw(this->cond_label + ":\n");
		VarType result = this->generate_expr(this->get_symbol_list());
		if (result != BOOLEAN) {
			report_error_lc("Semantic Error",
							"Conditional expression doesn't evaluate to boolean value.",
							(*this->get_symbol_list()->begin())->get_row(),
							(*this->get_symbol_list()->begin())->get_col());
		}
		write_raw("\nBRTS " + this->body_label);
		write_raw("BR " + this->exit_label);
		write_raw(this->body_label + ":\n");
	} else if (this->type == FORLOOP) {
		// parse the assignment
		// process the assignment
		AssignmentBlockPtr assignment = AssignmentBlockPtr(new AssignmentBlock(false));
		assignment->set_analyzer(this->get_analyzer());
		for (auto i = 0; i < 3; i++) {
			assignment->catch_token((*this->get_unprocessed())[i]);
		}
		// generate its code
		assignment->preprocess();
		assignment->generate_pre();
		assignment->generate_post();
		// generate the condition label
		write_raw(this->cond_label + ":\n");
		// process the ordinal expression
		AssignmentBlockPtr ordinal_expr = AssignmentBlockPtr(new AssignmentBlock(true));
		ordinal_expr->set_analyzer(this->get_analyzer());
		for (unsigned int i = 4; i < this->get_unprocessed()->size(); i++) {
			ordinal_expr->catch_token((*this->get_unprocessed())[i]);
		}
		// get the comparison components for the ordinal expr
		TokenPtr incrementer = (*this->get_unprocessed())[3];
		if (incrementer->get_token() == MP_TO) {
			ordinal_expr->catch_token(TokenPtr(new Token(MP_EQUALS, "=", -1, -1)));
		} else if (incrementer->get_token() == MP_DOWNTO) {
			ordinal_expr->catch_token(TokenPtr(new Token(MP_EQUALS, "=", -1, -1)));
		}
		ordinal_expr->catch_token((*this->get_unprocessed())[0]);
		if (incrementer->get_token() == MP_TO) {
			ordinal_expr->catch_token(TokenPtr(new Token (MP_MINUS, "-", -1, -1)));
			ordinal_expr->catch_token(TokenPtr(new Token (MP_INT_LITERAL, "1", -1, -1)));
		} else if (incrementer->get_token() == MP_DOWNTO) {
			ordinal_expr->catch_token(TokenPtr(new Token (MP_PLUS, "+", -1, -1)));
			ordinal_expr->catch_token(TokenPtr(new Token (MP_INT_LITERAL, "1", -1, -1)));
		}
		// generate its code
		ordinal_expr->preprocess();
		ordinal_expr->generate_pre();
		write_raw("\nBRFS " + this->body_label);
		write_raw("BR " + this->exit_label + "\n");
		write_raw(this->body_label + ":\n");
	}
}
开发者ID:jonfast565,项目名称:Mikropascal-Compiler,代码行数:58,代码来源:SemanticAnalyzer.cpp


示例7: TEST_F

TEST_F(AutoGenerateTest, ExplicitTypesAreDetected)
{
    factory.registerNodeType(GenericNodeFactory::createConstructorFromFunction(f1, "f1"));

    UUID node_id = UUIDProvider::makeUUID_without_parent("foobarbaz");
    NodeFacadeImplementationPtr node = factory.makeNode("f1", node_id, uuid_provider);

    ASSERT_TRUE(node != nullptr);
    ASSERT_EQ(node_id, node->getUUID());

    ASSERT_EQ(node->getParameters().size(), 1);

    ASSERT_EQ(node->getInputs().size(), 2 + node->getParameters().size());
    ASSERT_EQ(node->getOutputs().size(), 1 + node->getParameters().size());

    GenericValueMessage<int>::Ptr a(new GenericValueMessage<int>);
    GenericValueMessage<int>::Ptr b(new GenericValueMessage<int>);

    a->value = 23;
    b->value = 42;

    InputPtr i1 = node->getNodeHandle()->getInput(UUIDProvider::makeDerivedUUID_forced(node_id, "in_0"));
    ASSERT_TRUE(i1 != nullptr);

    InputPtr i2 = node->getNodeHandle()->getInput(UUIDProvider::makeDerivedUUID_forced(node_id, "in_1"));
    ASSERT_TRUE(i2 != nullptr);

    TokenPtr ta = std::make_shared<Token>(a);
    TokenPtr tb = std::make_shared<Token>(b);

    param::ParameterPtr p = node->getParameter("param 2");
    ASSERT_TRUE(p != nullptr);

    p->set<int>(1337);

    param::ValueParameter::Ptr vp = std::dynamic_pointer_cast<param::ValueParameter>(p);
    ASSERT_TRUE(vp != nullptr);

    i1->setToken(ta);
    i2->setToken(tb);

    NodePtr n = node->getNode();
    n->process(*node->getNodeHandle(), *n);

    OutputPtr o = node->getNodeHandle()->getOutput(UUIDProvider::makeDerivedUUID_forced(node_id, "out_0"));
    ASSERT_TRUE(o != nullptr);

    o->commitMessages(false);

    TokenPtr to = o->getToken();
    ASSERT_TRUE(to != nullptr);
    ASSERT_TRUE(to->getTokenData() != nullptr);

    GenericValueMessage<int>::ConstPtr result = std::dynamic_pointer_cast<GenericValueMessage<int> const>(to->getTokenData());
    ASSERT_TRUE(result != nullptr);

    ASSERT_EQ((a->value + b->value + vp->as<int>()), result->value);
}
开发者ID:cogsys-tuebingen,项目名称:csapex,代码行数:58,代码来源:auto_generate_test.cpp


示例8: data

void SubgraphNode::deactivation()
{
    if (deactivation_event_) {
        TokenDataConstPtr data(new connection_types::AnyMessage);
        TokenPtr token = std::make_shared<Token>(data);
        token->setActivityModifier(ActivityModifier::DEACTIVATE);
        deactivation_event_->triggerWith(token);
    }
}
开发者ID:cogsys-tuebingen,项目名称:csapex,代码行数:9,代码来源:subgraph_node.cpp


示例9: catch_token

void IOBlock::catch_token(TokenPtr token) {
	// no filtering, since the capture is for
	// comma separated expressions
	if (token->get_token() != MP_WRITE
		&& token->get_token() != MP_WRITELN
		&& token->get_token() != MP_READ
		&& token->get_token() != MP_READLN)
	this->get_unprocessed()->push_back(token);
}
开发者ID:jonfast565,项目名称:Mikropascal-Compiler,代码行数:9,代码来源:SemanticAnalyzer.cpp


示例10: DefineInfixOprt

/** \brief Add a user defined operator.
      \param a_pOprt Pointer to a unary postfix operator object. The parser will
             become the new owner of this object hence will destroy it.
  */
void ParserXBase::DefineInfixOprt(const TokenPtr<IOprtInfix> &oprt)
{
    if (IsInfixOprtDefined(oprt->GetIdent()))
        throw ParserError(ErrorContext(ecFUNOPRT_DEFINED, 0, oprt->GetIdent()));

    // Function is not added yet, add it.
    oprt->SetParent(this);
    m_InfixOprtDef[oprt->GetIdent()] = ptr_tok_type(oprt->Clone());
}
开发者ID:tomilov,项目名称:math-parser-benchmark-project,代码行数:13,代码来源:mpParserBase.cpp


示例11: initilizeObject

void ParserMixin::initilizeObject(const ParseContextSPtr& context, const TokenPtr& token, ObjectSPtr object)
{
    if (!token)
    {
        initilizeObject(context, object);
        return;
    }
    object->set_sourceId(context->mSourceId);
    object->set_line(token->line());
    object->set_column(token->beginColumn());
}
开发者ID:ggeorgiev,项目名称:compil,代码行数:11,代码来源:parser-mixin.cpp


示例12: fitnessCb

    void fitnessCb(const TokenPtr& data)
    {
        if (auto val = std::dynamic_pointer_cast<GenericValueMessage<double> const>(data->getTokenData())) {
            //            std::unique_lock<std::mutex> lock(data_available_mutex_);
            fitness_.push_back(val->value);

        } else if (std::dynamic_pointer_cast<EndOfSequenceMessage const>(data->getTokenData())) {
        } else {
            throw std::runtime_error("unkown message recieved: " + data->getTokenData()->typeName());
        }
    }
开发者ID:cogsys-tuebingen,项目名称:csapex_core_plugins,代码行数:11,代码来源:get_best_optimization_result.cpp


示例13: parseProjectStatement

bool ProjectParserMixin::parseProjectStatement(const ProjectParseContextSPtr& context, const CommentSPtr& comment)
{
    TokenizerPtr& tokenizer = context->tokenizer;

    TokenPtr core;

    if (tokenizer->check(Token::TYPE_IDENTIFIER, "core"))
    {
        core = tokenizer->current();
        tokenizer->shift();
        skipComments(context);
    }

    if (tokenizer->check(Token::TYPE_IDENTIFIER, "section"))
    {
        SectionSPtr section = parseSection(context, comment);
        if (section)
        {
            context->mProject << section;
        }
    }
    else
    if (tokenizer->check(Token::TYPE_IDENTIFIER, "package"))
    {
        if (!core)
        {
            *context <<= errorMessage(context, Message::p_unknownStatment)
                         << Message::Context("package")
                         << Message::Options("core");
        }
        PackageSPtr package = parsePackage(context);
        if (!core || !package)
            return false;

        core.reset();
        context->mProject->set_corePackage(package);
    }
    else
    {
        *context <<= errorMessage(context, Message::p_unknownStatment)
                     << Message::Context("top")
                     << Message::Options("section");
        tokenizer->shift();
    }

    return true;
}
开发者ID:ggeorgiev,项目名称:compil,代码行数:47,代码来源:project_parser-mixin.cpp


示例14: parse

        typename parser_result<self_t, Scanner>::type
        parse(Scanner const& scan) const
        {
          if (!scan.at_end())
          {
            TokenPtr t = *scan;

            if(ReferenceCounting::strict_cast<Type> (t) != 0 &&
               lexeme_ == t->lexeme ())
            {
              Iterator save(scan.first);
              ++scan;
              return scan.create_match(1, t, save, scan.first);
            }
          }
          return scan.no_match();
        }
开发者ID:DOCGroup,项目名称:XSC,代码行数:17,代码来源:Elements.hpp


示例15: yield_if

void PageTemplate::yield_if(const ArgumentList& arguments, const ArrayArgument::Item* arrayItem, const TokenPtr& token, std::string& result) const
{
	const IfToken* iftoken = static_cast<const IfToken*>(token.get());
	const std::string& value = get_variable(arguments, arrayItem, iftoken->data);
	if (value.empty())
		yield_tokens(arguments, arrayItem, iftoken->if_false, result);
	else
		yield_tokens(arguments, arrayItem, iftoken->if_true, result);
}
开发者ID:dmitry-root,项目名称:simurga,代码行数:9,代码来源:template.cpp


示例16: mprinterr

/** Add a DataSet of specified type, set it up and return pointer to it. 
  * \param inType type of DataSet to add.
  * \param metaIn DataSet MetaData.
  * \return pointer to successfully set-up DataSet or 0 if error.
  */ 
DataSet* DataSetList::AddSet(DataSet::DataType inType, MetaData const& metaIn)
{ // TODO Always generate default name if empty?
  // Do not add to a list with copies
  if (hasCopies_) {
    mprinterr("Internal Error: Attempting to add DataSet (%s) to DataSetList with copies.\n",
              metaIn.PrintName().c_str());
    return 0;
  }
  MetaData meta( metaIn );
  meta.SetEnsembleNum( ensembleNum_ );
  // Check if DataSet with same attributes already present.
  DataSet* DS = CheckForSet(meta);
  if (DS != 0) {
    mprintf("Warning: DataSet '%s' already present.\n", DS->Meta().PrintName().c_str());
    // NOTE: Should return found dataset?
    return 0; 
  }
  TokenPtr token = &(DataArray[inType]);
  if ( token->Alloc == 0) {
    mprinterr("Internal Error: No allocator for DataSet type [%s]\n", token->Description);
    return 0;
  }
  DS = (DataSet*)token->Alloc();
  if (DS==0) {
    mprinterr("Internal Error: DataSet %s memory allocation failed.\n", meta.PrintName().c_str());
    return 0;
  }
  // If 1 dim set and time series status not set, set to true.
  if (meta.TimeSeries() == MetaData::UNKNOWN_TS && DS->Ndim() == 1) {
    meta.SetTimeSeries( MetaData::IS_TS );
    // Also set dimension default
    DS->SetDim(Dimension::X, Dimension(1.0, 1.0, "Frame") );
  }
  // Set up dataset 
  if ( DS->SetMeta( meta ) ) {
    mprinterr("Error setting up data set %s.\n", meta.PrintName().c_str());
    delete DS;
    return 0;
  }

  Push_Back(DS); 
  //fprintf(stderr,"ADDED dataset %s\n",dsetName);
  return DS;
}
开发者ID:yuqinc,项目名称:cpptraj,代码行数:49,代码来源:DataSetList.cpp


示例17: generate_pre

// Program Block stuff
void ProgramBlock::generate_pre() {
	// get the program id and set it as the open file
	TokenPtr p = *this->get_unprocessed()->begin();
	// open a file to write to
	this->get_analyzer()->open_file(p->get_lexeme());
	// generate program entry point
	write_raw("MOV SP D0");
	// push begin symbols
	for (auto i = get_symbol_list()->begin(); i != get_symbol_list()->end(); i++) {
		if (static_pointer_cast<SymData>(*i)->get_var_type() == STRING) {
			write_raw("PUSH #\"\"");
		} else if (static_pointer_cast<SymData>(*i)->get_var_type() == FLOATING) {
			write_raw("PUSH #0.0");
		} else {
			write_raw("PUSH #0");
		}
	}
	write_raw("");
}
开发者ID:jonfast565,项目名称:Mikropascal-Compiler,代码行数:20,代码来源:SemanticAnalyzer.cpp


示例18: scanner_test

int scanner_test(string filename) {
	cout << "[ Scanner Test ]" << endl;
	shared_ptr<Input> test_input = Input::open_file(filename);
    if (test_input != nullptr) {
        shared_ptr<Scanner> scanner = shared_ptr<Scanner>(new Scanner(test_input));
        TokenPtr t;
        do {
            t = scanner->scan_one();
            if (t == nullptr) {
                report_error("Scan Error", "Token returned was invalid");
            }
        } while (t->get_token() != MP_EOF);
        scanner->display_tokens();
    } else {
        return -1;
    }
	cout << "[ End ]" << endl;
	return 0;
}
开发者ID:jonfast565,项目名称:Mikropascal-Compiler,代码行数:19,代码来源:Tests.hpp


示例19: createInternalInput

UUID SubgraphNode::addForwardingOutput(const UUID& internal_uuid, const TokenDataConstPtr& type, const std::string& label)
{
    graph_->registerUUID(internal_uuid);

    Output* external_output = VariadicOutputs::createVariadicOutput(type, label);

    InputPtr relay = createInternalInput(type, internal_uuid, label, true);

    crossConnectLabelChange(external_output, relay.get());

    std::weak_ptr<Output> external_output_weak = std::dynamic_pointer_cast<Output>(external_output->shared_from_this());
    relay->message_set.connect([this, external_output_weak, relay](Connectable*) {
        if (auto external_output = external_output_weak.lock()) {
            TokenPtr token = relay->getToken();
            if (is_iterating_) {
                connection_types::GenericVectorMessage::Ptr vector;
                if (!external_output->hasMessage()) {
                    vector = connection_types::GenericVectorMessage::make(token->getTokenData());
                } else {
                    auto collected = external_output->getAddedToken()->getTokenData()->cloneAs<TokenData>();
                    vector = std::dynamic_pointer_cast<connection_types::GenericVectorMessage>(collected);
                }
                apex_assert(vector);
                vector->addNestedValue(token->getTokenData());
                msg::publish(external_output.get(), vector);

                external_output->setType(vector);

            } else {
                msg::publish(external_output.get(), token->getTokenData());
            }
        }
    });

    external_to_internal_inputs_[external_output->getUUID()] = relay;

    relay_to_external_output_[internal_uuid] = external_output->getUUID();

    forwarding_connector_added(relay);

    return external_output->getUUID();
}
开发者ID:cogsys-tuebingen,项目名称:csapex,代码行数:42,代码来源:subgraph_node.cpp


示例20: ParseError

// ------------------------------------------------------------------------------------------------
Scope::Scope(Parser& parser,bool topLevel)
{
    if(!topLevel) {
        TokenPtr t = parser.CurrentToken();
        if (t->Type() != TokenType_OPEN_BRACKET) {
            ParseError("expected open bracket",t);
        }
    }

    TokenPtr n = parser.AdvanceToNextToken();
    if(n == NULL) {
        ParseError("unexpected end of file");
    }

    // note: empty scopes are allowed
    while(n->Type() != TokenType_CLOSE_BRACKET) {
        if (n->Type() != TokenType_KEY) {
            ParseError("unexpected token, expected TOK_KEY",n);
        }

        const std::string& str = n->StringContents();
        elements.insert(ElementMap::value_type(str,new_Element(*n,parser)));

        // Element() should stop at the next Key token (or right after a Close token)
        n = parser.CurrentToken();
        if(n == NULL) {
            if (topLevel) {
                return;
            }
            ParseError("unexpected end of file",parser.LastToken());
        }
    }
}
开发者ID:ppiecuch,项目名称:assimp-portable,代码行数:34,代码来源:FBXParser.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TokenScanner类代码示例发布时间:2022-05-31
下一篇:
C++ TokenList类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap