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


C++ readToken函数代码示例

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


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

示例1: currentValue

bool Reader::readArray(Token& tokenStart) {
  currentValue() = Value(arrayValue);
  currentValue().setOffsetStart(tokenStart.start_ - begin_);
  skipSpaces();
  if (*current_ == ']') // empty array
  {
    Token endArray;
    readToken(endArray);
    return true;
  }
  int index = 0;
  for (;;) {
    Value& value = currentValue()[index++];
    nodes_.push(&value);
    bool ok = readValue();
    nodes_.pop();
    if (!ok) // error already set
      return recoverFromError(tokenArrayEnd);

    Token token;
    // Accept Comment after last item in the array.
    ok = readToken(token);
    while (token.type_ == tokenComment && ok) {
      ok = readToken(token);
    }
    bool badTokenType =
        (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
    if (!ok || badTokenType) {
      return addErrorAndRecover(
          "Missing ',' or ']' in array declaration", token, tokenArrayEnd);
    }
    if (token.type_ == tokenArrayEnd)
      break;
  }
  return true;
}
开发者ID:4ker,项目名称:CMake,代码行数:36,代码来源:json_reader.cpp

示例2: parseTrait

/* parses a trait:
 * 	trait Foo {} */
static boolean parseTrait (tokenInfo *const token)
{
	boolean readNext = TRUE;
	tokenInfo *name;

	readToken (token);
	if (token->type != TOKEN_IDENTIFIER)
		return FALSE;

	name = newToken ();
	copyToken (name, token, TRUE);

	makeSimplePhpTag (name, K_TRAIT, ACCESS_UNDEFINED);

	readToken (token);
	if (token->type == TOKEN_OPEN_CURLY)
		enterScope (token, name->string, K_TRAIT);
	else
		readNext = FALSE;

	deleteToken (name);

	return readNext;
}
开发者ID:Dev0Null,项目名称:ctags,代码行数:26,代码来源:php.c

示例3: next

inline bool Json::next(const JsonValue& _current, JsonValue& _next)
{
	m_readPos = m_fileContent.data() + _current.offset;
	// Iterate through the stream to the next ','. Meanwhile the number of
	// brackets ({} and []) must match.
	int parenthesis = 0;
	do {
		if(!readToken()) return false;
		if(m_tokenPos[0] == '{' || m_tokenPos[0] == '[') ++parenthesis;
		else if(m_tokenPos[0] == '}' || m_tokenPos[0] == ']') --parenthesis;
	} while(parenthesis > 0 || m_tokenPos[0] != ',');
	if(parenthesis < 0) return false;
	readProperty(_next);
	return true;
}
开发者ID:Jojendersie,项目名称:Bim,代码行数:15,代码来源:json.hpp

示例4: parseClass

static void parseClass (tokenInfo *const token)
{
	Assert (isKeyword (token, KEYWORD_class));
	readToken (token);
	if (isType (token, TOKEN_IDENTIFIER))
	{
#ifndef TYPE_REFERENCE_TOOL
		makeEiffelClassTag (token);
		readToken (token);
#else
		vStringCopy (token->className, token->string);
		vStringUpper (token->className);
		if (PrintClass)
			puts (vStringValue (token->className));
		if (! PrintReferences)
			exit (0);
		readToken (token);
#endif
	}

	do
	{
		if (isType (token, TOKEN_OPEN_BRACKET))
			parseGeneric (token, TRUE);
		else if (! isType (token, TOKEN_KEYWORD))
			readToken (token);
		else switch (token->keyword)
		{
			case KEYWORD_inherit:  parseInherit (token);        break;
			case KEYWORD_feature:  parseFeatureClauses (token); break;
			case KEYWORD_convert:  parseConvert (token);        break;
			default:               readToken (token);           break;
		}
	} while (! isKeyword (token, KEYWORD_end) &&
	         ! isType (token, TOKEN_EOF));
}
开发者ID:koron,项目名称:ctags,代码行数:36,代码来源:eiffel.c

示例5: parseRename

static void parseRename (tokenInfo *const token)
{
	do {
		readToken (token);
		if (readFeatureName (token))
		{
			readToken (token);
			if (isKeyword (token, KEYWORD_as))
			{
				readToken (token);
				if (readFeatureName (token))
				{
#ifndef TYPE_REFERENCE_TOOL
					makeEiffelFeatureTag (token);  /* renamed feature */
#endif
					readToken (token);
				}
			}
		}
	} while (isType (token, TOKEN_COMMA));

	findKeyword (token, KEYWORD_end);
	readToken (token);
}
开发者ID:05storm26,项目名称:codelite,代码行数:24,代码来源:eiffel.c

示例6: syntaxError

PARSENODE_PTR SQLParser::parseInsert() {
    if (!startsInsert(nowReading)) {
        syntaxError(nowReading, "expect insert token!");        
        return nullptr;
    }
    //LOG_TRACE(logger, "parse insert statement.");

    PARSENODE_PTR insertNode = PARSENODE_PTR(new ParseNode(INSERT));
    readToken();
    expect(INTO);
    insertNode->children.push_back(parseIdentifier());
    expect(VALUES);

    expect(LEFT_BRACE);
    insertNode->children.push_back(parseLiteral());
    while (nowReading == SLICE) {
        readToken();
        insertNode->children.push_back(parseLiteral());
    }
    expect(RIGHT_BRACE);

    expect(TERMINATOR);
    return insertNode;
}
开发者ID:LLLLKKKK,项目名称:miniSQL,代码行数:24,代码来源:SQLParser.cpp

示例7: parseConvert

static void parseConvert (tokenInfo *const token)
{
	Assert (isKeyword (token, KEYWORD_convert));
	do
	{
		readToken (token);
		if (! isType (token, TOKEN_IDENTIFIER))
			break;
		else if (isType (token, TOKEN_OPEN_PAREN))
		{
			while (! isType (token, TOKEN_CLOSE_PAREN) &&
			       ! isType (token, TOKEN_EOF))
				readToken (token);
		}
		else if (isType (token, TOKEN_COLON))
		{
			readToken (token);
			if (! isType (token, TOKEN_OPEN_BRACE))
				break;
			else while (! isType (token, TOKEN_CLOSE_BRACE))
				readToken (token);
		}
	} while (isType (token, TOKEN_COMMA));
}
开发者ID:jankap,项目名称:ctags,代码行数:24,代码来源:eiffel.c

示例8: expectData

bool DbcParser::expectData(DbcParser::DbcTokenList &tokens, dbc_token_type_t type, QString *data, bool skipWhitespace, bool skipSectionEnding, bool newLineIsSectionEnding)
{
    DbcToken *token;
    if (!(token = readToken(tokens, type, skipWhitespace, skipSectionEnding, newLineIsSectionEnding))) {
        return false;
    }

    if (data) {
        data->clear();
        data->append(token->getData());
    }

    free(token);
    return true;
}
开发者ID:esclear,项目名称:cangaroo,代码行数:15,代码来源:DbcParser.cpp

示例9: int

bool 
Reader::recoverFromError( TokenType skipUntilToken )
{
   int errorCount = int(errors_.size());
   Token skip;
   for (;;)
   {
      if ( !readToken(skip) )
         errors_.resize( errorCount ); // discard errors caused by recovery
      if ( skip.type_ == skipUntilToken  ||  skip.type_ == tokenEndOfStream )
         break;
   }
   errors_.resize( errorCount );
   return false;
}
开发者ID:AchironOS,项目名称:chromium-2,代码行数:15,代码来源:json_reader.cpp

示例10: parseConstant

static void parseConstant (bool local)
{
	tokenInfo *const name = newToken ();
	readToken (name);
	if (local)
	{
		makeVhdlTag (name, VHDLTAG_LOCAL);
	}
	else
	{
		makeVhdlTag (name, VHDLTAG_CONSTANT);
	}
	skipToCharacterInInputFile (';');
	deleteToken (name);
}
开发者ID:pragmaware,项目名称:ctags,代码行数:15,代码来源:vhdl.c

示例11: parseLocal

static void parseLocal (tokenInfo *const token)
{
    Assert (isKeyword (token, KEYWORD_local));
    readToken (token);

    /*  Check keyword first in case local clause is empty
     */
    while (! isKeyword (token, KEYWORD_do)  &&
	   ! isKeyword (token, KEYWORD_once))
    {
#ifndef TYPE_REFERENCE_TOOL
	if (isType (token, TOKEN_IDENTIFIER))
	    makeEiffelLocalTag (token);

#endif
	readToken (token);
	if (isType (token, TOKEN_COLON))
	{
	    readToken (token);
	    if (isType (token, TOKEN_IDENTIFIER))
		parseType (token);
	}
    }
}
开发者ID:att,项目名称:uwin,代码行数:24,代码来源:eiffel.c

示例12: findJsonTags

static void findJsonTags (void)
{
	tokenInfo *const token = newToken ();

	/* We allow multiple top-level elements, although it's not actually valid
	 * JSON.  An interesting side effect of this is that we allow a leading
	 * Unicode BOM mark -- even though ok, many JSON parsers will choke on it */
	do
	{
		readToken (token);
		parseValue (token);
	}
	while (token->type != TOKEN_EOF);

	deleteToken (token);
}
开发者ID:FabianInostroza,项目名称:geany,代码行数:16,代码来源:json.c

示例13: parseInherit

static void parseInherit (tokenInfo *const token)
{
    Assert (isKeyword (token, KEYWORD_inherit));
#ifdef TYPE_REFERENCE_TOOL
    readToken (token);
    while (isType (token, TOKEN_IDENTIFIER))
    {
        parseType (token);
        if (isType (token, TOKEN_KEYWORD))
        {
            switch (token->keyword)  /* check for feature adaptation */
            {
            case KEYWORD_rename:
            case KEYWORD_export:
            case KEYWORD_undefine:
            case KEYWORD_redefine:
            case KEYWORD_select:
                findKeyword (token, KEYWORD_end);
                readToken (token);
            default:
                break;
            }
        }
    }
#else
    readToken (token);
    while (isType (token, TOKEN_IDENTIFIER))
    {
        parseType (token);
        switch (token->keyword)  /* check for feature adaptation */
        {
        case KEYWORD_rename:
            parseRename (token);
            if (isKeyword (token, KEYWORD_end))
                readToken (token);
            break;

        case KEYWORD_export:
        case KEYWORD_undefine:
        case KEYWORD_redefine:
        case KEYWORD_select:
            findKeyword (token, KEYWORD_end);
            readToken (token);
            break;

        case KEYWORD_end:
            readToken (token);
            break;

        default:
            break;
        }
    }
#endif
}
开发者ID:Figoer,项目名称:i_figoer,代码行数:55,代码来源:eiffel.c

示例14: findHtmlTags

static void findHtmlTags (void)
{
	tokenInfo token;

	token.string = vStringNew ();

	do
	{
		readToken (&token, true);
		if (token.type == TOKEN_TAG_START)
			readTag (&token, NULL, 0);
	}
	while (token.type != TOKEN_EOF);

	vStringDelete (token.string);
}
开发者ID:qzhuyan,项目名称:ctags,代码行数:16,代码来源:html.c

示例15: while

int Parser::readToken(s_cursor_t &it, const s_cursor_t &end) {
    // skipping any whitespace
    while (it != end && isspace(_lastChar))
      _lastChar = *(it++); // getting char and advancing cursor

    if (isalpha(_lastChar)) { /// identifier: [a-zA-Z][a-zA-Z0-9]*
        _identifier = _lastChar;
        while (it != end && isalnum((_lastChar = *(it++))))
          _identifier += _lastChar;

        if (_identifier == def_id)
            return tok_def;
        else if (_identifier == extern_id)
            return tok_extern;

        return tok_identifier;
    }

    if (isdigit(_lastChar)) { // number [0-9]
        std::string num;
        do {
          num += _lastChar;
        } while (it != end && isdigit((_lastChar = *(it++))));
        _number = strtol(num.c_str(), nullptr, 10);

        return tok_number;
    }

    if (_lastChar == '#') {
        // just a loop for ignoring everything after the #
        do
            _lastChar = *(it++);
        while (it != end && _lastChar != '\n' && _lastChar != '\r');

        if (_lastChar != EOF)
        return readToken(it, end);
    }

    if (it == end || _lastChar == EOF) {
      _lastChar = tok_eof;
    }

    // don't know what to do with this char
    int thisChar = _lastChar;
    _lastChar = *(it++);
    return thisChar;
}
开发者ID:alediaferia,项目名称:sand,代码行数:47,代码来源:parser.cpp


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