示例#1
0
inline static bool tokenMaybeRegionEnd( const TokenIterator & it )
{
    Q_ASSERT(it.isValid());
    if (it->character != ')')
        return false;
    TokenIterator next_it = it.next();
    return (!next_it.isValid() ||
            next_it.block() != it.block() ||
            next_it->character == ';');
}
示例#2
0
void ScCodeEditor::matchBracket( const TokenIterator & bracket, BracketPair & match )
{
    Q_ASSERT(bracket.isValid());

    switch(bracket->type) {
    case Token::OpeningBracket:
        match.first = bracket;
        match.second = nextClosingBracket(bracket.next());
        break;
    case Token::ClosingBracket:
        match.second = bracket;
        match.first = previousOpeningBracket(bracket.previous());
        break;
    default:
        match.first = TokenIterator();
        match.second = TokenIterator();
    }
}
示例#3
0
List<Token> 
PreProcessor::replaceMacroParams(const List<Token> &mtokens, const List<List<Token>> &caller_params)
{
	//FIXME: nested macro
	//i.e. FUNC(x, FUNC(x,y))

	List<Token> replace = mtokens;
	TokenIterator it;
	it.setTokens(&replace);
	while (!it.eof()) {
		if (it.is(_PP_MACRO_PARAM)) {
			int index = it.val()->toInt();
			const List<Token> &param = caller_params.at(index);
			it.erase(1);
			it.insert(param);
		}
		it.next();
	}
	return replace;
}