void IPCClass::messageRecived(uint8 type, const char* buff, uint32 size) { if (type == MT_FUNCTIONCALL) { handleFunctionCall(buff, size, false); } else if (type == MT_FUNCTIONCALL_ASYNC) { handleFunctionCall(buff, size, true); } else if (type == MT_FUNCTIONRETURN) { handleFunctionReturn(buff, size); } else if (type == MT_EVENTTRIGGER) { handleEventTrigger(buff,size); } }
Ast::UnaryOp* Parser::primary() { ++current; switch(current->type) { case TokenType::String: return new Ast::UnaryOp(new Ast::Literal(Variable(current->getValue<Variable::StringType>()))); case TokenType::Number: return new Ast::UnaryOp(new Ast::Literal(Variable(current->getValue<Variable::NumberType>()))); case TokenType::Article: // We actually expect another primary now // because we allow an optional article before a primary return primary(); case TokenType::Identifier: return new Ast::UnaryOp(new Ast::VarNode(current->getValue<std::string>(), &data_handler)); case TokenType::FuncResult: skipOptional(TokenType::Of); ++current; if(current->type == TokenType::Identifier && current->getValue<std::string>() == "calling"); ++current; return new Ast::UnaryOp(handleFunctionCall()); case TokenType::Operator: { char op = current->getValue<char>(); if(op == '(') { Ast::UnaryOp* uop = new Ast::UnaryOp(expression()); ++current; if(current->getValue<char>() != ')') error("expected ')' after '('", current->line); return uop; } else if(op == '-') return new Ast::UnaryOp(primary(), op); else error("unexpected operator in primary", current->line); } default: error("primary expected", current->line); } return nullptr; }
bool Parser::handleToken() { switch(current->type) { case TokenType::Begin: case TokenType::End: case TokenType::Error: return false; case TokenType::FuncName: handleFunctionCall(); break; default: { auto handler = handlers.find(current->type); if(handler == handlers.end()) handleUnexpectedToken(); else (handler->second)(this); } } ++current; if(current->type != TokenType::Dot) error("sentences are usually ended with a dot", current->line); ++current; return true; }
void Parser::handleIdentifier() { program->attach(handleFunctionCall(false)); }