{"id":20170593,"url":"https://github.com/yds12/ulp","last_synced_at":"2026-06-09T10:31:48.644Z","repository":{"id":143440149,"uuid":"266321487","full_name":"yds12/ulp","owner":"yds12","description":"A simple compiler from source to x64 assembly.","archived":false,"fork":false,"pushed_at":"2024-02-25T16:01:40.000Z","size":777,"stargazers_count":3,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-03T04:23:35.501Z","etag":null,"topics":["compiler","programming-language","toy-language"],"latest_commit_sha":null,"homepage":"","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/yds12.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-05-23T11:23:04.000Z","updated_at":"2024-02-03T18:25:55.000Z","dependencies_parsed_at":"2024-02-25T11:26:49.029Z","dependency_job_id":"df1b231f-2307-4977-b738-97330e9f9802","html_url":"https://github.com/yds12/ulp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yds12/ulp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yds12%2Fulp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yds12%2Fulp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yds12%2Fulp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yds12%2Fulp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yds12","download_url":"https://codeload.github.com/yds12/ulp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yds12%2Fulp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34103355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["compiler","programming-language","toy-language"],"created_at":"2024-11-14T01:19:46.462Z","updated_at":"2026-06-09T10:31:48.625Z","avatar_url":"https://github.com/yds12.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compiler Project\n\nThis project is for learning purposes only.\n\nWe implement a compiler for a simple language. The compiler will be divided\ninto the following parts:\n\n* a *lexer*: process the input and generates a list of tokens;\n\n* an [LR(1)](https://en.wikipedia.org/wiki/LR_parser) *parser*: generates an\n[Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree)\n-- or AST;\n\n* a *scope checker*: builds a symbol table for each scope of the program\nand checks whether all variables and functions used have been declared, and\nif there are redeclarations;\n\n* a *type checker*: checks whether assignments and expressions have the\nexpected type;\n\n* a *code generator*: generates x64 assembly code targeted at\nLinux. The resulting assembly will be processed by `nasm` into object\ncode, and then linked with `ld`.\n\n* and a *standard library*: functions that can be included by **ulp** programs,\nand are automatically linked in the linkage phase.\n\n## The Language\n\nAn incomplete specification of the language is in the `docs`\ndirectory. For the lexer we have [`docs/lexicon.txt`](docs/lexicon.txt), and\nfor the parser we have [`docs/grammar.txt`](docs/grammar.txt). For now,\nthe language will just be called **ulp**, for \"uma linguagem de programação\".\n\nMany examples of simple **ulp** programs can be found at the\n[`test/cases`](test/cases) directory.\n\n## Building and Using the Compiler\n\nTo build the compiler, use `make`:\n\n    $ make\n\nThis will create the compiler at `build/ulpc`. To execute, from the `build`\ndirectory:\n\n    $ ./ulpc --help\n    ulpc -- The ulp compiler.\n    Version: 0.0.7\n\nThis will display `ulpc`'s help.\n\nCurrently, some (pretty useless) programs can be compiled. To compile a file:\n\n    $ ./ulpc /path/to/my/source/file.ul\n\nAn executable `a.out` will be created on the working directory.\n\n### Testing the Compiler\n\nTo test the compiler, a series of **ulp** programs in the `test/cases`\ndirectory can be automatically executed via the test script:\n\n    $ make test\n    Running test suite...\n\n    Positive tests:\n\t    pass 0001_noop.ul\n\t    pass 0002_noops.ul\n\n    \u003coutput truncated ... \u003e\n\n        pass 0221_undeclared_func.ul\n\t    pass 0225_declared_wrong.ul\n\t    pass 0226_declared_wrong.ul\n\n    92 tests, 56 passes and 36 failures.\n\nThe passes and fails are displayed in green and red, respectively.\n\n### Inspecting Parse Trees\n\nYou can check the parse trees by using the auxiliar script in `aux/view`:\n\n    $ ./aux/view docs/current.ulp\n\nThis is an example of an AST that you might see:\n\n![AST](docs/ast.png)\n\n## Roadmap\n\nCurrently, the compiler is capable of parsing, doing scope resolution\nfor variables and functions and generating an executable for programs using\na subset of the language including only booleans and 32-bit integers:\n\n    $ ./ulpc ../test/cases/pos/0005a_decl_expr.ul\n\nThis command will create an `a.out` executable file in the working directory.\n\nOur plans for the next versions are:\n\nVersion **0.1.x**: every merge to master should increase `x`.\n\nVersion **0.2.0**: executables being generated for the whole language, as in\nthe current grammar specification.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyds12%2Fulp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyds12%2Fulp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyds12%2Fulp/lists"}