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

C++ token类代码示例

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

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



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

示例1: expandVariable

void Foam::primitiveEntry::append
(
    const token& currToken,
    const dictionary& dict,
    Istream& is
)
{
    if (currToken.isWord())
    {
        const word& w = currToken.wordToken();

        if
        (
            w.size() == 1
         || (
                !(w[0] == '$' && expandVariable(w, dict))
             && !(w[0] == '#' && expandFunction(w, dict, is))
            )
        )
        {
            newElmt(tokenIndex()++) = currToken;
        }
    }
    else
    {
        newElmt(tokenIndex()++) = currToken;
    }
}
开发者ID:Brzous,项目名称:WindFOAM,代码行数:28,代码来源:primitiveEntryIO.C


示例2: get_token

/*
 * Returns the contents of the lexer as a token
 */
bool lexer::get_token(token &tok) {

	// set appropriate values
	tok.set_text(text);
	tok.set_type(type);
	return true;
}
开发者ID:majestic53,项目名称:Cli-Calc,代码行数:10,代码来源:lexer.cpp


示例3: intersect

    void intersect (basic_charset &rhs_, basic_charset &overlap_)
    {
        _token.intersect (rhs_._token, overlap_._token);

        if (!overlap_._token.empty ())
        {
            typename index_set::const_iterator iter_ = _index_set.begin ();
            typename index_set::const_iterator end_ = _index_set.end ();

            for (; iter_ != end_; ++iter_)
            {
                overlap_._index_set.insert (*iter_);
            }

            iter_ = rhs_._index_set.begin ();
            end_ = rhs_._index_set.end ();

            for (; iter_ != end_; ++iter_)
            {
                overlap_._index_set.insert (*iter_);
            }

            if (_token.empty ())
            {
                _index_set.clear ();
            }

            if (rhs_._token.empty ())
            {
                rhs_._index_set.clear ();
            }
        }
    }
开发者ID:BioinformaticsArchive,项目名称:MulRFRepo,代码行数:33,代码来源:charset.hpp


示例4: opPriority

int
opPriority(token t)
{
    if ( (binOP_Table.end() != binOP_Table.find(t.Tok())) )
	return binOP_Table[t.Tok()];
    else // this will stop OpPrecedence parsing once we hit a
	return -1;  // non-op while evaluating InfixEpxr
}
开发者ID:RalfMBecker,项目名称:decaf,代码行数:8,代码来源:tables.cpp


示例5: to_string

bool token::operator == (const token& rhs) const
{
   if (this == &rhs)
      return true;

   if (valid() && rhs.valid())
      return to_string() == rhs.to_string();
   else
      return false;
}
开发者ID:darkangel-ua,项目名称:hammer,代码行数:10,代码来源:token.cpp


示例6: parse

  virtual parse_result parse( string::const_iterator& i, 
			      string::const_iterator e, 
			      token& tok ) const
  {
    string::const_iterator j = i;
    if ( *j != '&' && *j != '+' ) return failed; ++j;
    while ( j < e && ( *j == '.' || *j == '-' || isalnum(*j) ) ) ++j;
    tok.assign(i, j); tok.type( tok_types::pn_lit ); i = j;
    return done;
  }
开发者ID:brucegentles,项目名称:ringinglib,代码行数:10,代码来源:parser.cpp


示例7: get_root_contents

/*
 * Returns the contents at the root
 */
bool syn_tree::get_root_contents(token &tok) {

	// check that root token exists
	if(!root)
		return false;

	// set the text & type
	tok.set_text(root->get_text());
	tok.set_type(root->get_type());
	return true;
}
开发者ID:majestic53,项目名称:Cli-Calc,代码行数:14,代码来源:syn_tree.cpp


示例8:

zstring::zstring(const token& tok)
    : _buf(0)
    , _pool(0)
{
    if(tok.len() == 0)
        _zptr = _zend = nullstring;
    else {
        _zptr = tok.ptr();
        _zend = tok.ptre() - 1;
    }
}
开发者ID:cyrilgramblicka,项目名称:X264RecorderPlugin,代码行数:11,代码来源:str-win.cpp


示例9: set_contents

/*
 * Set the contents of the current token
 */
bool syn_tree::set_contents(token &tok) {

	// make sure current token exists
	if(!cur)
		return false;

	// set current token contents
	cur->set_text(tok.get_text());
	cur->set_type(tok.get_type());
	return true;
}
开发者ID:majestic53,项目名称:Cli-Calc,代码行数:14,代码来源:syn_tree.cpp


示例10: get_contents

/*
 * Returns contents at current token
 */
bool syn_tree::get_contents(token &tok) {

	// check that current token exists
	if(!cur)
		return false;

	// set the text & type
	tok.set_text(cur->get_text());
	tok.set_type(cur->get_type());
	return true;
}
开发者ID:majestic53,项目名称:Cli-Calc,代码行数:14,代码来源:syn_tree.cpp


示例11: is_greater_precedence

  static bool is_greater_precedence(const token &one, const token &two) {
    size_t one_id = one.first_matching_sym_op_fn_id();
    size_t two_id = two.first_matching_sym_op_fn_id();
    typename Fn_Table::fn_info one_info = Fn_Table::get_info(one_id);
    typename Fn_Table::fn_info two_info = Fn_Table::get_info(two_id);
    bool one_is_left_assoc = one_info.is_left_assoc();
    size_t one_precedence = one_info.precedence();
    size_t two_precedence = two_info.precedence();

    return ((one_is_left_assoc && (one_precedence >= two_precedence))
            || (!one_is_left_assoc && (one_precedence > two_precedence)));
  }
开发者ID:barrbrain,项目名称:r17,代码行数:12,代码来源:shunting_yard.hpp


示例12: fprintf

 void dotfile_visitor::format_node(abstract_node *node, const char *name, const token &tok)
 {
   if (!m_connectTo)
   {
     if (tok.type() == token_types::STRING_LITERAL)
       fprintf(m_file, "\tptr%p [label=\"[%s]\\n[%s]\\n\\\"%.*s\\\"\"];\n", node, name, token_types::names[tok.type()], tok.length() - 2, tok.text() + 1);
     else if (tok.text())
       fprintf(m_file, "\tptr%p [label=\"[%s]\\n[%s]\\n%.*s\"];\n", node, name, token_types::names[tok.type()], tok.length(), tok.text());
     else
       format_node(node, name);
   }
 }
开发者ID:ImOnALampshade,项目名称:brandy,代码行数:12,代码来源:dotfilevisitor.cpp


示例13: new_const

string symbol_table::new_const(token tkconst)
{
    string type = type_of(tkconst);
    auto ent = consts_.find(type+tkconst.text());
    if (ent != consts_.end()) {
        return ent->second.place();
    }
    
    const_desc desc(tkconst);
    consts_[type+tkconst.text()] = desc;
    return desc.place();
}
开发者ID:Aetf,项目名称:ACCompiler,代码行数:12,代码来源:symbol_table.cpp


示例14: hash

static inline token hash(const std::string &pw, token const& salt)
{
	token result;
	if(::libscrypt_scrypt(
		(const uint8_t*)pw.data(), pw.size(),
		salt.data(), salt.size(),
		SCRYPT_N, SCRYPT_r, SCRYPT_p,
		result.data(), result.size()
	) == -1)
		throw std::runtime_error("Incapable of hashing plaintext");

	return result;
}
开发者ID:Supermarx,项目名称:common,代码行数:13,代码来源:session_operations.hpp


示例15: get_size

/*
 * Sets the contents of the specified child token of current token
 */
bool syn_tree::set_child_contents(token &tok, unsigned int index) {

	// check to make sure child token exists
	if(!cur
			|| !get_size()
			|| index >= get_size())
		return false;

	// set contents
	token *child = cur->get_child(index);
	child->set_text(tok.get_text());
	child->set_type(tok.get_type());
	return true;
}
开发者ID:majestic53,项目名称:Cli-Calc,代码行数:17,代码来源:syn_tree.cpp


示例16: parse_operator

int parse_operator(string &str, string::iterator i_iter, token &output)
{
    bool is_error = false;
    output.clean();
    if(i_iter != str.end())
    {
        switch(*i_iter)
        {
            case '+': output._typeid = OPER_ADD; break;
            case '-': output._typeid = OPER_SUB; break;
            case '*': output._typeid = OPER_MULT;break;
            case '/': output._typeid = OPER_DIV; break;
            case '=': output._typeid = OPER_EQU; break;
            case '(': output._typeid = OPER_LPAR;break;
            case '{': output._typeid = OPER_LPAR;break;
            case ')': output._typeid = OPER_RPAR;break;
            case '}': output._typeid = OPER_RPAR;break;
            case '!': if((i_iter+1) != str.end() && *(i_iter + 1) == '=') output._typeid = OPER_NOTEQ;break;
            default: is_error = true; break;
        }
    }else{
        is_error = true;
    }
    if(is_error){
        return -1;
    }else if(output._typeid != OPER_NOTEQ){
        output.elemt = *i_iter;
        return 1;
    }else{
        output.elemt = "!=";
        return 2;
    }
}
开发者ID:Kingwl,项目名称:lexical_analysis,代码行数:33,代码来源:lexical_analysis.cpp


示例17: parse_string

int parse_string(string &str, string::iterator i_iter, token& output)
{
    const int s_input = 0;
    const int s_exit = 1;
    const int s_note = 2;
    output.clean();
    bool flag = false;
    bool is_error = false;
    vector <char> o;
    string::iterator iter = i_iter;
    int state = s_input;

    if(*iter != '"'){
        state = s_exit;
    }else{
        ++iter;
    }
    while(flag == false)
    {
        switch(state)
        {
        case s_input:
            if(iter == str.end()){
                 state = s_exit;
            }else if(*iter == '\\'){
                state = s_note;
            }else if(*iter == '"'){
                state = s_exit;
            }else{
                o.push_back(*iter++);
            }
            break;
        case s_exit:
            if(iter == i_iter) is_error = true;
            flag = true;
            break;
        case s_note:
            if((iter + 1) != str.end() && *(iter + 1) == '"'){
                o.push_back(*(iter + 1 ));
                iter += 2;
            }else if((iter + 1) != str.end() && *(iter + 1) == 'n'){
                o.push_back('\n');
                iter += 2;
            }else if((iter + 1) != str.end() && *(iter + 1) == 't'){
                o.push_back('\t');
                iter += 2;
            }
            state = s_input;
            break;
        }
    }
    if(is_error)
    {
        return -1;
    }else{
        output.elemt = string(o.begin(), o.end());
        output._typeid = TYPE_STR;
        return iter - i_iter;
    }
}
开发者ID:Kingwl,项目名称:lexical_analysis,代码行数:60,代码来源:lexical_analysis.cpp


示例18: expandVariable

void Foam::primitiveEntry::append
(
    const token& currToken,
    const dictionary& dict,
    Istream& is
)
{
    if (currToken.isWord())
    {
        const word& w = currToken.wordToken();

        if
        (
            disableFunctionEntries
         || w.size() == 1
         || (
                !(w[0] == '$' && expandVariable(w, dict))
             && !(w[0] == '#' && expandFunction(w, dict, is))
            )
        )
        {
            newElmt(tokenIndex()++) = currToken;
        }
    }
    else if (currToken.isVariable())
    {
        const string& w = currToken.stringToken();

        if
        (
            disableFunctionEntries
         || w.size() <= 3
         || !(
                w[0] == '$'
             && w[1] == token::BEGIN_BLOCK
             && expandVariable(w, dict)
            )
        )
        {
            newElmt(tokenIndex()++) = currToken;
        }
    }
    else
    {
        newElmt(tokenIndex()++) = currToken;
    }
}
开发者ID:Kiiree,项目名称:CONSELFcae-dev,代码行数:47,代码来源:primitiveEntryIO.C


示例19: myToken

parsetree::parsetree(const token &t) // {{{
  : myToken(t),
    myType(t.Name()),
    myCase("_TOKEN"),
    is_token(true)
{
  myContent.clear();
} // }}}
开发者ID:lassenielsen,项目名称:libdpl,代码行数:8,代码来源:parsetree.cpp


示例20: comparison_interpret

Condition DB_Set::comparison_interpret(token& t, vector<Table*> r)
{
	if(t.get_value() == "OP")
	{
		string left, right;
		if(t[0][0].get_type() == identifier) left = t[0][0].get_value();
		else left = t[0][0][0].get_value();
		if(t[2][0].get_type() == identifier) right = t[2][0].get_value();
		else right = t[2][0][0].get_value();
		Condition_Sing op(left, t[1].get_value(), right);
		Condition c(op);
		return c;
	}
	else if(t.get_value() == "CONDITION")
		return condition_interpret(t[0], r);
    return condition_interpret(t[0],r);
}
开发者ID:jwaang,项目名称:sql-db-engine,代码行数:17,代码来源:DB_Set.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ token_type类代码示例发布时间:2022-05-31
下一篇:
C++ tok_ctx类代码示例发布时间: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