Files
The-VM-to-HACK-Translator/parser.hpp

35 lines
551 B
C++
Raw Normal View History

2020-08-18 21:32:19 +05:30
#pragma once
2020-08-18 19:00:05 +05:30
#include <tuple>
#include <vector>
#include <unordered_map>
#include <fstream>
#include "vutility.hpp"
2020-08-18 21:32:19 +05:30
2020-08-18 19:00:05 +05:30
enum c_type
{
C_ARITHMETIC,
C_PUSH,
C_POP,
C_LABEL,
C_GOTO,
C_IF,
C_FUNCTION,
C_RETURN,
C_CALL
};
typedef std::tuple<c_type, std::string, int> vmcommand;
class parser
{
private:
std::string input_file;
std::vector<vmcommand> parsed;
public:
2020-08-21 17:54:14 +05:30
bool change_file(std::string name);
2020-08-18 19:00:05 +05:30
std::vector<vmcommand> get_commands();
c_type command_type(std::string com);
void parse();
};