{"id":16475302,"url":"https://github.com/avinal/the-vm-to-hack-translator","last_synced_at":"2025-10-19T12:25:19.258Z","repository":{"id":115433247,"uuid":"310935902","full_name":"avinal/The-VM-to-HACK-Translator","owner":"avinal","description":null,"archived":false,"fork":false,"pushed_at":"2020-11-07T21:35:02.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T01:32:04.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avinal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-07T21:34:51.000Z","updated_at":"2020-11-07T21:35:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"bbc9e246-0a70-47f7-9bcb-ba7f2e813d22","html_url":"https://github.com/avinal/The-VM-to-HACK-Translator","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avinal%2FThe-VM-to-HACK-Translator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avinal%2FThe-VM-to-HACK-Translator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avinal%2FThe-VM-to-HACK-Translator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avinal%2FThe-VM-to-HACK-Translator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avinal","download_url":"https://codeload.github.com/avinal/The-VM-to-HACK-Translator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241131780,"owners_count":19915013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T12:37:37.802Z","updated_at":"2025-10-19T12:25:19.177Z","avatar_url":"https://github.com/avinal.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The-VM-to-HACK-Translator\nTranslates Virtual Machine Language into HACK Assembly language.\n\n**Important: If you are taking this course then I suggest you to try to write the assembler yourself first, it is not very easy and not very tough too. At least not impossible, because I did it 😘**\n\n## Get Started with the project\n1. Directory Structure\n    ```shell\n        .\n        |_include      # Contains headers\n        |_src          # Contains Source Code and Main\n        |_Test-Files   # Example HACK VM Files\n    ```\n2. Clone this repo\n    ```shell\n        git clone https://github.com/avinal/The-VM-to-HACK-Translator.git\n    ```\n3. Build and run, provide only [HACK VM Language](https://www.nand2tetris.org/project08) file. Don't confuse with `.vm` extesion. \n    ```shell\n        cd The-VM-to-HACK-Translator\n        make\n        ./VMTranslator file.vm\n    ```\n4. Start over after modification\n    ```shell\n        make clean\n    ```\n\n\n## Tips\nIn case you want to modify this project, you can use [Boost C++ Libraries](https://www.boost.org/), they can simplify many tasks needed by this project. \n\n## Some Words\nThis was a nice project and taugh me many things. Given below are some miraculous code snippets that proved to be really useful and are well researched. Hope you will find them useful.\n\n1. Trim spaces, comments, carrige returns, newline, tab and verticle tabs:\n    ```cpp\n        inline std::string trim(std::string str)\n        {\n            if (str.find('/') != std::string::npos) // comments\n            {\n                str.erase(str.find('/'));\n            }\n            str.erase(0, str.find_first_not_of(\" \\r\\t\\v\\n\")); //prefixing\n            str.erase(str.find_last_not_of(\" \\r\\t\\v\\n\") + 1); //surfixing}\n            return str;\n        }\n    ```\n2. Tokenize a string using C++ with respect to a delimiter, space by defalt (string split):\n    ```cpp\n        #include \u003csstream\u003e\n        #include \u003cvector\u003e\n        std::vector\u003cstd::string\u003e split(std::string str, char delimiter = ' ')\n        {\n            std::vector\u003cstd::string\u003e tokens;\n            std::stringstream tokenizer(str);\n            std::string intermediate;\n            while (std::getline(tokenizer, intermediate, delimiter))\n            {\n                tokens.push_back(intermediate);\n            }\n            return tokens;\n        }\n    ```\n3. **Fascinating** Using Lambdas with Map to implement a function or function pointers. [See here](https://github.com/avinal/The-VM-to-HACK-Translator/blob/291b239065fc5cc0921b8592dfcd69c6f3022e52/src/code_writer.cpp#L29) ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favinal%2Fthe-vm-to-hack-translator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favinal%2Fthe-vm-to-hack-translator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favinal%2Fthe-vm-to-hack-translator/lists"}