{"id":19818070,"url":"https://github.com/mekhyw/logicomp-compiler","last_synced_at":"2026-04-13T11:01:46.947Z","repository":{"id":243955451,"uuid":"752856078","full_name":"MekhyW/LogiComp-Compiler","owner":"MekhyW","description":"Custom simplified Lua compiler that generates assembly code for Linux and Windows, developed from scratch in C++","archived":false,"fork":false,"pushed_at":"2024-06-11T22:37:35.000Z","size":5186,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-14T18:09:27.276Z","etag":null,"topics":["assembly","compiler","cpp","lua"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MekhyW.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":"2024-02-05T00:57:03.000Z","updated_at":"2024-06-11T23:10:18.000Z","dependencies_parsed_at":"2024-06-14T00:33:10.731Z","dependency_job_id":null,"html_url":"https://github.com/MekhyW/LogiComp-Compiler","commit_stats":null,"previous_names":["mekhyw/logicomp-compiler"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/MekhyW/LogiComp-Compiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MekhyW%2FLogiComp-Compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MekhyW%2FLogiComp-Compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MekhyW%2FLogiComp-Compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MekhyW%2FLogiComp-Compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MekhyW","download_url":"https://codeload.github.com/MekhyW/LogiComp-Compiler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MekhyW%2FLogiComp-Compiler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31749763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["assembly","compiler","cpp","lua"],"created_at":"2024-11-12T10:14:33.164Z","updated_at":"2026-04-13T11:01:46.924Z","avatar_url":"https://github.com/MekhyW.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LogiComp-Compiler\n\nCustom, simplified Lua compiler that generates assembly code for Linux and Windows x86, developed from scratch in C++.\n\nWARNING: This was made for educational purposes only. It is not intended to be used in production as it is not optimized and has many limitations compared to the original Lua compiler.\n\n## Compiler structure\n\nThe compiler is divided into the following modules:\n- **Main.cpp**: Main module that reads the input file and calls the other modules.\n- **Preprocessor.h**: Preprocessor module that handles preprocessor directives and macros.\n- **Tokenizer.h**: Tokenizer module that reads the input file and generates tokens.\n- **Parser.h**: Parser module that generates the abstract syntax tree (AST) from the tokens.\n- **Node.h**: Node module that defines the nodes of the AST.\n- **SymbolTable.h**: Symbol table module that stores the variables and functions of the program (and their types).\n- **Assembly.h**: Assembly module that generates the assembly code from the AST and the symbol table.\n\n![Compiler structure](docs/Diagram2.png)\n\n## Syntactic diagram \nThis diagram shows how the Lua language is seen by the compiler´s parser, after the tokens are generated by the tokenizer.\n\n![Syntactic diagram](docs/Diagram.jpg)\n\n## Extended Backus-Naur Form (EBNF)\n\n\u003cli\u003eBLOCK = { STATEMENT };\n\u003cli\u003eSTATEMENT = ( \n    IDENTIFIER, ( \"=\", BOOL_EXP | \"(\" , ( | BOOL_EXP, { ( \",\" ) , BOOL_EXP } ), \")\" )\n    | \"local\", IDENTIFIER, [\"=\", BOOL_EXP] \n    | \"print\", \"(\", BOOL_EXP, \")\" \n    | \"while\", BOOL_EXP, \"do\", \"\\n\", { ( STATEMENT )}, \"end\" \n    | \"if\", BOOL_EXP, \"then\", \"\\n\", { ( STATEMENT ) }, [ \"else\", \"\\n\", { ( STATEMENT )}], \"end\"\n    | \"function\", IDENTIFIER, \"(\", ( | IDENTIFIER, { ( \",\" ), IDENTIFIER } ), \")\", \"\\n\", { ( STATEMENT ) }, \"end\"\n    | \"return\", BOOL_EXP\n    ), \"\\n\" ;\n\u003cli\u003eBOOL_EXP = BOOL_TERM, { (\"or\"), BOOL_TERM } ;\n\u003cli\u003eBOOL_TERM = REL_EXP, { (\"and\"), REL_EXP } ;\n\u003cli\u003eEXPRESSION = TERM, { (\"+\" | \"-\" |\"..\"), TERM } ;\n\u003cli\u003eTERM = FACTOR, { (\"*\" | \"/\" | \"%\"), FACTOR } ;\n\u003cli\u003eFACTOR = NUMBER \n    | STRING \n    | IDENTIFIER, ( | \"(\" , ( | BOOL_EXP, { ( \",\" ) , BOOL_EXP } ), \")\" ) \n    | (\"+\" | \"-\" | \"not\"), FACTOR \n    | \"(\", BOOL_EXP, \")\" \n    | \"read\", \"(\", \")\" ;\n\u003cli\u003eIDENTIFIER = LETTER, { LETTER | DIGIT | \"_\" } ;\n\u003cli\u003eNUMBER = DIGIT, { DIGIT } ;\n\u003cli\u003eLETTER = ( \"a\" | \"...\" | \"z\" | \"A\" | \"...\" | \"Z\" ) ;\n\u003cli\u003eDIGIT = ( \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\" | \"0\" ) ;\n\u003cli\u003eSTRING = '\"', ({LETTER | DIGIT | \"_\"}), '\"';\n\n## Usage\nCompile the compiler using g++:\n```bash\ng++ -Wall -O3 -w main.cpp -o main -std=c++17\n```\nRun the compiler:\n```bash\n./main program.lua\nnasm -f elf -o program.o program.asm # For Linux\nnasm -f win32 -o program.o program.asm # For Windows\ngcc -m32 -o program program.o\n./program\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmekhyw%2Flogicomp-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmekhyw%2Flogicomp-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmekhyw%2Flogicomp-compiler/lists"}