|
|
@@ -1,230 +1,398 @@
|
|
|
#include "parse.h"
|
|
|
|
|
|
#include <QObject>
|
|
|
+#include <QException>
|
|
|
+#include <QVector>
|
|
|
+
|
|
|
+int32_t process_param(const QString& param, bool& isSepecial)
|
|
|
+{
|
|
|
+ QRegExp regMatchNumber("\\d*");
|
|
|
+
|
|
|
+ isSepecial = true;
|
|
|
+
|
|
|
+ if(param.compare("#1", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_1;
|
|
|
+ }
|
|
|
+ else if(param.compare("#2", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_2;
|
|
|
+ }
|
|
|
+ else if(param.compare("#3", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_3;
|
|
|
+ }
|
|
|
+ else if(param.compare("#4", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_4;
|
|
|
+ }
|
|
|
+ else if(param.compare("#5", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_5;
|
|
|
+ }
|
|
|
+ else if(param.compare("#6", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_6;
|
|
|
+ }
|
|
|
+ else if(param.compare("#7", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_7;
|
|
|
+ }
|
|
|
+ else if(param.compare("#8", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_8;
|
|
|
+ }
|
|
|
+ else if(param.compare("#9", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_9;
|
|
|
+ }
|
|
|
+ else if(param.compare("#10", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_10;
|
|
|
+ }
|
|
|
+ else if(param.compare("#11", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_11;
|
|
|
+ }
|
|
|
+ else if(param.compare("#12", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_12;
|
|
|
+ }
|
|
|
+ else if(param.compare("#13", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_13;
|
|
|
+ }
|
|
|
+ else if(param.compare("#14", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_14;
|
|
|
+ }
|
|
|
+ else if(param.compare("#15", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_15;
|
|
|
+ }
|
|
|
+ else if(param.compare("#16", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_16;
|
|
|
+ }
|
|
|
+ else if(param.compare("#17", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_17;
|
|
|
+ }
|
|
|
+ else if(param.compare("#18", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_18;
|
|
|
+ }
|
|
|
+ else if(param.compare("#19", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_19;
|
|
|
+ }
|
|
|
+ else if(param.compare("#20", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return Local_20;
|
|
|
+ }
|
|
|
+ else if(param.compare("#Active", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return LocalActive;
|
|
|
+ }
|
|
|
+ else if(param.compare("$Banks", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return LocalBanks;
|
|
|
+ }
|
|
|
+ else if(param.compare("$InstrSet", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return LocalInstrSet;
|
|
|
+ }
|
|
|
+ else if(param.compare("$Mobile", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return LocalMobile;
|
|
|
+ }
|
|
|
+ else if(param.compare("$Age", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return LocalAge;
|
|
|
+ }
|
|
|
+ else if(param.compare("$Tasks", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return LocalTasks;
|
|
|
+ }
|
|
|
+ else if(param.compare("$Generation", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return LocalGeneration;
|
|
|
+ }
|
|
|
+ else if(param.compare("$ID", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return LocalId;
|
|
|
+ }
|
|
|
+ else if(param.compare("%Active", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return RemoteActive;
|
|
|
+ }
|
|
|
+ else if(param.compare("%Banks", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return RemoteBanks;
|
|
|
+ }
|
|
|
+ else if(param.compare("%InstrSet", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return RemoteInstrSet;
|
|
|
+ }
|
|
|
+ else if(param.compare("%Mobile", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return RemoteMobile;
|
|
|
+ }
|
|
|
+ else if(param.compare("%Age", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return RemoteAge;
|
|
|
+ }
|
|
|
+ else if(param.compare("%Tasks", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return RemoteTasks;
|
|
|
+ }
|
|
|
+ else if(param.compare("%Generation", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return RemoteGeneration;
|
|
|
+ }
|
|
|
+ else if(param.compare("#Pub", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return GlobalPub;
|
|
|
+ }
|
|
|
+ else if(param.compare("#Team", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return GlobalTeam;
|
|
|
+ }
|
|
|
+ else if(param.compare("$Own", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return GlobalOwn;
|
|
|
+ }
|
|
|
+ else if(param.compare("$Others", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return GlobalOthers;
|
|
|
+ }
|
|
|
+ else if(param.compare("$Fields", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return GlobalFields;
|
|
|
+ }
|
|
|
+ else if(param.compare("$Time", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return GlobalTime;
|
|
|
+ }
|
|
|
+ else if(param.compare("$Timeout", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return GlobalTimeout;
|
|
|
+ }
|
|
|
+ else if(regMatchNumber.exactMatch(param))
|
|
|
+ {
|
|
|
+ isSepecial = false;
|
|
|
+ return param.toInt();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw QException();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+Instruction process_0(const QString& cmd)
|
|
|
+{
|
|
|
+ if(cmd.compare("MOVE", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {MOVE, N, 0, 0, 0};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("DIE", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {DIE, N, 0, 0, 0};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("BREAK", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {BREAK, N, 0, 0, 0};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("RESUME", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {RESUME, N, 0, 0, 0};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("SEIZE", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {SEIZE, N, 0, 0, 0};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("QUIT", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {QUIT, N, 0, 0, 0};
|
|
|
+ }
|
|
|
+ throw QException();
|
|
|
+}
|
|
|
+
|
|
|
+Instruction process_1(const QString& cmd, const QString& a)
|
|
|
+{
|
|
|
+ bool isSpecialA;
|
|
|
+ auto vA = process_param(a, isSpecialA);
|
|
|
+ Params params = isSpecialA ? V : L;
|
|
|
+
|
|
|
+ if(cmd.compare("TURN", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {TURN, params, vA};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("JUMP", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {JUMP, params, vA};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("AJUMP", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {AJUMP, params, vA};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("SCAN", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {SCAN, params, vA};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("SLEEP", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {SLEEP, params, vA};
|
|
|
+ }
|
|
|
+ throw QException();
|
|
|
+}
|
|
|
|
|
|
-QVector<Token> lex(const QString& code) {
|
|
|
- QVector<Token> tokens;
|
|
|
- size_t i = 0;
|
|
|
- size_t lineCounter = 0;
|
|
|
- size_t columnCounter = 0;
|
|
|
- while(i < code.size()) {
|
|
|
- if(code[i] == '\n') {
|
|
|
- tokens.push_back({lineCounter, columnCounter, TokenTypeEOL, i, i + 1});
|
|
|
- ++lineCounter;
|
|
|
- columnCounter = 0;
|
|
|
- ++i;
|
|
|
- }
|
|
|
- else if(code[i] == ',') {
|
|
|
- tokens.push_back({lineCounter, columnCounter, TokenTypeComma, i, i + 1});
|
|
|
- ++i;
|
|
|
- }
|
|
|
- else if(code[i] == '#') {
|
|
|
- tokens.push_back({lineCounter, columnCounter, TokenTypeHash, i, i + 1});
|
|
|
- ++i;
|
|
|
- }
|
|
|
- else if(code[i] == '%') {
|
|
|
- tokens.push_back({lineCounter, columnCounter, TokenTypePercent, i, i + 1});
|
|
|
- ++i;
|
|
|
- }
|
|
|
- else if(code[i] == '$') {
|
|
|
- tokens.push_back({lineCounter, columnCounter, TokenTypeDollar, i, i + 1});
|
|
|
- ++i;
|
|
|
- }
|
|
|
- else if(code[i] == '/' && (i+1) < code.size() && code[i+1] == '/') {
|
|
|
- size_t s = i + 2;
|
|
|
- while(s < code.size() && code[s] != '\n') {
|
|
|
- ++s;
|
|
|
- }
|
|
|
- i = s;
|
|
|
- }
|
|
|
- else if(code[i].isSpace()) {
|
|
|
- ++i;
|
|
|
- }
|
|
|
- else if(code[i].isDigit()) {
|
|
|
- size_t s = i + 1;
|
|
|
- while(s < code.size() && code[s].isDigit()){
|
|
|
- ++s;
|
|
|
- }
|
|
|
-
|
|
|
- tokens.push_back({lineCounter, columnCounter, TokenTypeNumber, i, s});
|
|
|
- i = s;
|
|
|
- }
|
|
|
- else if(code[i].isLetter()) {
|
|
|
- size_t s = i + 1;
|
|
|
- while(s < code.size() && code[s].isLetter()){
|
|
|
- ++s;
|
|
|
- }
|
|
|
-
|
|
|
- tokens.push_back({lineCounter, columnCounter, TokenTypeWord, i, s});
|
|
|
- i = s;
|
|
|
- }
|
|
|
- else {
|
|
|
- tokens.push_back({lineCounter, columnCounter, TokenTypeError, i, i + 1});
|
|
|
- ++i;
|
|
|
- }
|
|
|
-
|
|
|
- ++columnCounter;
|
|
|
- }
|
|
|
-
|
|
|
- return tokens;
|
|
|
+Instruction process_2(const QString& cmd, const QString& a, const QString& b)
|
|
|
+{
|
|
|
+ bool isSpecialA;
|
|
|
+ bool isSpecialB;
|
|
|
+ auto vA = process_param(a, isSpecialA);
|
|
|
+ auto vB = process_param(b, isSpecialB);
|
|
|
+ Params params = isSpecialA ? ( isSpecialB ? VV : VL) : ( isSpecialB ? LV : LL);
|
|
|
+
|
|
|
+ if(cmd.compare("TRANS", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {TRANS, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("RTRANS", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {RTRANS, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("BJUMP", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {BJUMP, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("SET", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {SET, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("ADD", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {ADD, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("SUB", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {SUB, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("MUL", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {MUL, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("DIV", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {DIV, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("MOD", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {MOD, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("MIN", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {MIN, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("MAX", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {MAX, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("IF", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {IF, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("IFN", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {IFN, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("IFG", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {IFG, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("IFL", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {IFL, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("IFGE", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {IFGE, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("IFLE", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {IFLE, params, vA, vB};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("INIT", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {INIT, params, vA, vB};
|
|
|
+ }
|
|
|
+ throw QException();
|
|
|
}
|
|
|
|
|
|
+Instruction process_3(const QString& cmd, const QString& a, const QString& b, const QString& c)
|
|
|
+{
|
|
|
+ bool isSpecialA;
|
|
|
+ bool isSpecialB;
|
|
|
+ bool isSpecialC;
|
|
|
+ auto vA = process_param(a, isSpecialA);
|
|
|
+ auto vB = process_param(b, isSpecialB);
|
|
|
+ auto vC = process_param(c, isSpecialC);
|
|
|
+ Params params = isSpecialA ? ( isSpecialB ? ( isSpecialC ? VVV: VVL) : ( isSpecialC ? VLV: VLL)) : ( isSpecialB ? ( isSpecialC ? LVV : LVL) : ( isSpecialC ? LLV : LLL));
|
|
|
+
|
|
|
+ if(cmd.compare("CREATE", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {CREATE, params, vA, vB, vC};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("FARSCAN", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {FARSCAN, params, vA, vB, vC};
|
|
|
+ }
|
|
|
+ else if(cmd.compare("RANDOM", Qt::CaseInsensitive) == 0)
|
|
|
+ {
|
|
|
+ return {RANDOM, params, vA, vB, vC};
|
|
|
+ }
|
|
|
+ throw QException();
|
|
|
+}
|
|
|
+
|
|
|
+Instruction process_parts(const QStringList& parts)
|
|
|
+{
|
|
|
+ if(parts.size() == 1)
|
|
|
+ {
|
|
|
+ return process_0(parts[0]);
|
|
|
+ }
|
|
|
+ else if(parts.size() == 2)
|
|
|
+ {
|
|
|
+ return process_1(parts[0], parts[1]);
|
|
|
+ }
|
|
|
+ else if(parts.size() == 3)
|
|
|
+ {
|
|
|
+ return process_2(parts[0], parts[1], parts[2]);
|
|
|
+ }
|
|
|
+ else if(parts.size() == 4)
|
|
|
+ {
|
|
|
+ return process_3(parts[0], parts[1], parts[2], parts[3]);
|
|
|
+ }
|
|
|
+ throw QException();
|
|
|
+}
|
|
|
+
|
|
|
+void process_line(QString line, QVector<QVector<Instruction>>& banks)
|
|
|
+{
|
|
|
+ line = line.mid(0, line.indexOf("//"));
|
|
|
+
|
|
|
+ if(line.isEmpty())
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(line.startsWith("BANK ", Qt::CaseInsensitive))
|
|
|
+ {
|
|
|
+ banks.resize(banks.size() + 1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
-QVector<QVector<Instruction>> parse(const QString& code, const QVector<Token>& tokens, QVector<ParseError>& errors) {
|
|
|
- size_t i = 0;
|
|
|
-
|
|
|
- auto skipToEol = [&tokens, &i](){
|
|
|
- while(i < tokens.size() && tokens[i].tokenType != TokenTypeEOL) {
|
|
|
- ++i;
|
|
|
- }
|
|
|
- ++i;
|
|
|
- };
|
|
|
-
|
|
|
- while(i < tokens.size()) {
|
|
|
- if(tokens[i].tokenType != TokenTypeWord) {
|
|
|
- errors += ParseError(tokens[i].line, tokens[i].column, QObject::tr("is not a valid Instruction"));
|
|
|
- //lets fast forward to next line
|
|
|
- skipToEol();
|
|
|
- continue;
|
|
|
- }
|
|
|
- else {
|
|
|
- auto getTokenText = [&](size_t k){
|
|
|
- return code.mid(tokens[k].begin, tokens[k].end - tokens[k].begin).toUpper();
|
|
|
- };
|
|
|
-
|
|
|
- QString word = getTokenText(i);
|
|
|
-
|
|
|
- if(word.compare("CREATE", Qt::CaseInsensitive)) {
|
|
|
- }
|
|
|
- else if(word.compare("MOVE", Qt::CaseInsensitive)) {
|
|
|
- }
|
|
|
- else if(word.compare("DIE", Qt::CaseInsensitive)) {
|
|
|
- if(i + 1 >= tokens.size() || tokens[i + 1].tokenType != TokenTypeEOL) {
|
|
|
- errors += ParseError(tokens[i - 1].line, tokens[i - 1].column, QObject::tr("error"));
|
|
|
- }
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("TRANS", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("RTRANS", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("TURN", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("JUMP", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("AJUMP", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("BJUMP", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("TURN", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("SCAN", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("FARSCAN", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("SET", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("ADD", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("SUB", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("MUL", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("DIV", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("MOD", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("MIN", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("MAX", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("RANDOM", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("IF", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("IFN", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("IFG", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("IFL", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("IFGE", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("IFLE", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("INIT", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("BREAK", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("RESUME", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("SLEEP", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else if(word.compare("QUIT", Qt::CaseInsensitive)) {
|
|
|
-
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- else {
|
|
|
- errors += ParseError(tokens[i].line, tokens[i].column, QObject::tr("is not a valid Instruction"));
|
|
|
- skipToEol();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ auto parts = line.split(QRegExp("[\\s,]"), QString::SplitBehavior::SkipEmptyParts);
|
|
|
+ banks.back() += process_parts(parts);
|
|
|
}
|