fix jump forward
This commit is contained in:
26
src/IO.cpp
26
src/IO.cpp
@@ -6,22 +6,38 @@
|
||||
BinaryData ParseFile(const std::string& fileName) {
|
||||
std::ifstream file{fileName};
|
||||
std::uint32_t lineNumber = 0, realLineNumber = 0;
|
||||
std::string line;
|
||||
std::string currentLine;
|
||||
|
||||
std::vector<std::string> lines;
|
||||
|
||||
Assembleur assembleur;
|
||||
|
||||
BinaryData output;
|
||||
|
||||
while (getline(file, line)) {
|
||||
// parsing labels
|
||||
while (getline(file, currentLine)) {
|
||||
lines.push_back(currentLine);
|
||||
lineNumber++;
|
||||
realLineNumber++;
|
||||
|
||||
if (line.find(":") != std::string::npos) {
|
||||
std::string label = line.substr(0, line.size() - 1);
|
||||
if (currentLine.find(":") != std::string::npos) {
|
||||
std::string label = currentLine.substr(0, currentLine.size() - 1);
|
||||
assembleur.AddLabel(label, lineNumber);
|
||||
lineNumber--;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
lineNumber = realLineNumber = 0;
|
||||
|
||||
// parsing instructions
|
||||
for (std::string line : lines) {
|
||||
lineNumber++;
|
||||
realLineNumber++;
|
||||
|
||||
if (line.find(":") == std::string::npos) {
|
||||
output.push_back(assembleur.ParseInstruction(line, lineNumber, realLineNumber));
|
||||
} else {
|
||||
lineNumber--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user