void Console::keyPressEvent(QKeyEvent* e) { switch(e->key()) { case Qt::Key_Enter: case Qt::Key_Return: if(inPromptBlock()) handleReturn(); return; case Qt::Key_Left: case Qt::Key_Backspace: if(handleBackspace()||!inPromptBlock()) return; break; case Qt::Key_Down: case Qt::Key_Up: return; case Qt::Key_Right: case Qt::Key_Home: case Qt::Key_End: break; default: if(!inPromptBlock()) { moveCursor(QTextCursor::End,QTextCursor::MoveAnchor); } } QPlainTextEdit::keyPressEvent(e); }
ExprAST* Parser::handleTopLevelExpr() { switch (lexer->token) { case '[': return handleVarDef(); case Lexer::TOK_RETURN: return handleReturn(); case Lexer::TOK_IF: return handleCondition(); case Lexer::TOK_FOR: return handleForLoop(); case Lexer::TOK_BREAK: lexer->NextToken(); return new BreakAST(); case Lexer::TOK_CONTINUE: lexer->NextToken(); return new ContinueAST(); default: return parseExpression(); } }
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; } }