folder reordering
This commit is contained in:
30
src/loader/CommandParser.cpp
Normal file
30
src/loader/CommandParser.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// Created by black on 12.06.25.
|
||||
//
|
||||
|
||||
#include "emulator/CommandParser.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
CommandParser & CommandParser::getInstance() {
|
||||
static CommandParser instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
std::vector<std::string> CommandParser::parseLine(const std::string &input) {
|
||||
std::vector<std::string> output{};
|
||||
/// Konvertiere den Input String in einen IStringStream, damit dieser bei Leerzeichen gesplittet werden kann
|
||||
std::istringstream iss(input);
|
||||
std::string out;
|
||||
do {
|
||||
/// Trenne den IStringStream bei jedem Leerzeichen und füge die Befehl(e)/-sargumente dem Output hinzu
|
||||
std::getline(iss, out, ' ');
|
||||
/// Stoppe, sobald ein Kommentar im Source Code vorkommt
|
||||
if (out.at(0) != '#') {
|
||||
output.push_back(out);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (!out.empty());
|
||||
return output;
|
||||
}
|
||||
38
src/loader/CommandParser.h
Normal file
38
src/loader/CommandParser.h
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Created by black on 12.06.25.
|
||||
//
|
||||
|
||||
#ifndef COMMANDPARSER_H
|
||||
#define COMMANDPARSER_H
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class CommandParser {
|
||||
|
||||
private:
|
||||
CommandParser() = default;
|
||||
|
||||
public:
|
||||
/// Singleton Logik
|
||||
CommandParser(const CommandParser&) = delete;
|
||||
CommandParser(const CommandParser&&) = delete;
|
||||
CommandParser& operator=(const CommandParser&) = delete;
|
||||
CommandParser& operator=(const CommandParser&&) = delete;
|
||||
~CommandParser() = default;
|
||||
|
||||
static CommandParser& getInstance();
|
||||
|
||||
/**
|
||||
* Parst eine Zeile des Assembly Codes und gibt diese als sortierten Vektor zurück
|
||||
*
|
||||
* @param input Eine Zeile aus dem Assembly Code
|
||||
* @return Ein Vektor mit Befehl und dessen Argumenten
|
||||
*/
|
||||
static std::vector<std::string> parseLine(const std::string& input);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //COMMANDPARSER_H
|
||||
Reference in New Issue
Block a user