{"id":28485481,"url":"https://github.com/typefox/langium-llvm","last_synced_at":"2025-06-28T06:31:15.809Z","repository":{"id":227822842,"uuid":"760516906","full_name":"TypeFox/langium-llvm","owner":"TypeFox","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-18T13:15:54.000Z","size":78,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-08T00:11:25.440Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TypeFox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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},"funding":{"github":"TypeFox"}},"created_at":"2024-02-20T15:08:19.000Z","updated_at":"2025-03-18T10:23:28.000Z","dependencies_parsed_at":"2024-03-18T14:37:19.886Z","dependency_job_id":null,"html_url":"https://github.com/TypeFox/langium-llvm","commit_stats":null,"previous_names":["typefox/langium-llvm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TypeFox/langium-llvm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TypeFox%2Flangium-llvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TypeFox%2Flangium-llvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TypeFox%2Flangium-llvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TypeFox%2Flangium-llvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TypeFox","download_url":"https://codeload.github.com/TypeFox/langium-llvm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TypeFox%2Flangium-llvm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262387188,"owners_count":23303183,"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":"2025-06-08T00:10:41.710Z","updated_at":"2025-06-28T06:31:15.803Z","avatar_url":"https://github.com/TypeFox.png","language":"TypeScript","readme":"# Ox: Implementation with Langium \u0026 LLVM\n\nThis repository contains a Langium and LLVM based implementation of the Ox language, a subset of the [Lox language](https://craftinginterpreters.com/the-lox-language.html).\n\nThe main purpose of the Ox language is to show how Langium and LLVM can be used together to get an executable and debuggable language. In the screenshot below, you can see the VSCode window where a factorial program written in Ox language is running in debug mode.\n\n\u003cimg width=\"1512\" alt=\"demo\" src=\"https://github.com/TypeFox/langium-llvm/assets/15619772/2c8d6d56-ea23-4bfc-973c-70c217f8a0c7\"\u003e\n\nThe implementation includes:\n - Ox grammar and LSP services generated by Langium\n - LLVM IR and Debug Information (DI) generator\n    - depends on [llvm-bindings](https://www.npmjs.com/package/llvm-bindings), a binding library for calling the LLVM API in TypeScript \n - CLI for the LLVM IR code generation\n\nCode samples in Ox are located in the `./examples` folder.\n\n## How to build\n\n1. Install the library [llvm-bindings](https://github.com/ApsarasX/llvm-bindings?tab=readme-ov-file#install)\n    - to generate LLVM IR and DI\n2. Compile the Ox language and other sources\n```bash\nnpm i\nnpm run langium:generate\nnpm run build\n```\n3. Install the [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) extension\n    - to debug Ox in VSCode and not using the debugger CLI\n\n## How to execute and debug Ox\n\n### In the IDE\n\n1. Run the Ox IDE using the VSCode `Run Extension` launch config\n2. Open the `./examples` folder. It has `.ox` files and its own VSCode launch config\n3. Open any `.ox` file in the editor, set a breakpoint, and use the `Debug` launch config\n  - make sure that the VSCode `Debug: Allow Breakpoints Everywhere` flag is set to true\n\n### Using the CLI\n\n1. Generate `factorial.ll` with LLVM IR and DI for `./examples/factorial.ox` in `./examples/dbg`\n```bash\nnode ./bin/cli.js generate ./examples/basic.ox -d ./examples/dbg\n```\n2. Compile `factorial.ll` into an executable `./examples/dbg/out` in debug mode\n```bash\nclang -g ./examples/dbg/factorial.ll -o ./examples/dbg/out\n```\n  - To execute\n    ```bash\n    ./examples/dbg/out\n    ```\n3. To debug using the LLDB debugger CLI\n```bash\nlldb ./examples/dbg/out\n(lldb) b 3     # sets the breakpoint on line 3\n(lldb) r       # runs the program\n(lldb) print n # prints the value of the variable n\n(lldb) next    # go to the next line 4\n(lldb) q       # quit the debugger\n```\n","funding_links":["https://github.com/sponsors/TypeFox"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypefox%2Flangium-llvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypefox%2Flangium-llvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypefox%2Flangium-llvm/lists"}