mirror of
https://github.com/hazemKrimi/jack-vm-translator.git
synced 2026-05-01 18:00:27 +00:00
chore: use vector instead of custom linked list
This commit is contained in:
+8
-2
@@ -2,6 +2,7 @@
|
||||
#include <iostream>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "parser.hpp"
|
||||
#include "utils.hpp"
|
||||
@@ -10,7 +11,7 @@ int process(std::string source) {
|
||||
std::ifstream ifs(source);
|
||||
std::string line;
|
||||
|
||||
LinkedList<Command> *commands = nullptr;
|
||||
std::vector<Command> commands;
|
||||
|
||||
while (getline(ifs, line)) {
|
||||
if (isComment(line) || isEmptyLine(line))
|
||||
@@ -18,8 +19,13 @@ int process(std::string source) {
|
||||
|
||||
int parseResult;
|
||||
|
||||
if ((parseResult = parseCommand(commands, line)) != 0)
|
||||
if ((parseResult = parseCommand(commands, line)) != 0) {
|
||||
return parseResult;
|
||||
}
|
||||
}
|
||||
|
||||
for (const Command &cmd : commands) {
|
||||
std::cout << int(cmd.type) << " " << int(cmd.segment) << " " << cmd.index << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user