示例#1
0
void Parser::parse()
{
	LexerToken currentToken;
	
	do {
		currentToken = mLexer->getToken();

		BaseExpression* expr = 0;
		switch (currentToken.type) {
			case TYPE:
				expr = handleType(currentToken.value);
				break;
			case IDENTIFIER:
				expr = handleIdentifier(currentToken);
				break;
			case EXPRESSION_END:
				
				break;
			case ASSIGNMENT_OP:
// 				handleAssignment();
				break;
			case CONST_NUMBER:

				break;
			case BRACE:
// 				handleBrace(currentToken.value.c_str()[0]);
				break;
			case KEYWORD:
				expr = handleKeyword(currentToken.value);
				break;
			default:
				break;
		}

		if(expr) {
			mExprList.push_back(expr);
		};
	} while (currentToken.type != TOKEN_EOF);
}
示例#2
0
void DirectHandler::handleValue(const JSONEntity& val)
{
	if (0 == icompare(_key, "action"))
	{
		handleAction(val.toString());
	}
	else if (0 == icompare(_key, "method"))
	{
		handleMethod(val.toString());
	}
	else if (0 == icompare(_key, "data"))
	{
		handleData(val);
	}
	else if (0 == icompare(_key, "type"))
	{
		handleType(val.toString());
	}
	else if (0 == icompare(_key, "tid"))
	{
		handleTID(val.toInteger());
	}
}
示例#3
0
ExprAST *Parser::handlePrimary() {
    switch (currentToken.type){
        case TOK_IDENT:
            return handleIdentifierExpression();
        case TOK_NUMBER:
            return handleNumberExpression();
        case TOK_OPARENTHESES:
            return handleParenthesesExpression();
        case TOK_TYPE:
            return handleType(currentToken.value);
        case TOK_RETURN:
            return handleReturn();
        case TOK_PRINTF:
            return handlePrintf();
        case TOK_WHILE:
            return handleWhile();
        case TOK_IF:
            return handleIf();
        case TOK_NOP:
            return handleNop();
        default:
            return nullptr;
    }
}