#ifndef PARSEUTIL_H #define PARSEUTIL_H #include #include enum TokenType { Number, Operator, }; class Token { public: Token(QString value = "", QString type = "") { this->value = value; this->type = TokenType::Operator; if (type == "decimal" || type == "hex") { this->type = TokenType::Number; this->operatorPrecedence = -1; } else if (type == "operator") { this->operatorPrecedence = precedenceMap[value]; } } static QMap precedenceMap; QString value; TokenType type; int operatorPrecedence; // only relevant for operator tokens }; class ParseUtil { public: ParseUtil(); void strip_comment(QString*); QList* parseAsm(QString); int evaluateDefine(QString, QMap*); private: QList tokenizeExpression(QString expression, QMap* knownIdentifiers); QList generatePostfix(QList tokens); int evaluatePostfix(QList postfix); }; #endif // PARSEUTIL_H