{"id":15657894,"url":"https://github.com/willothy/letter","last_synced_at":"2025-05-05T16:40:40.656Z","repository":{"id":40454920,"uuid":"476851823","full_name":"willothy/Letter","owner":"willothy","description":"Letter is a compiler project built in TypeScript using LLVM node bindings.","archived":false,"fork":false,"pushed_at":"2022-09-01T18:36:55.000Z","size":13252,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T22:25:16.733Z","etag":null,"topics":["compiler","llvm","llvm-javascript","parser","programming-language","typescript"],"latest_commit_sha":null,"homepage":"","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/willothy.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}},"created_at":"2022-04-01T19:55:19.000Z","updated_at":"2024-09-15T18:55:05.000Z","dependencies_parsed_at":"2022-08-09T21:00:46.727Z","dependency_job_id":null,"html_url":"https://github.com/willothy/Letter","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2FLetter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2FLetter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2FLetter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2FLetter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willothy","download_url":"https://codeload.github.com/willothy/Letter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252535007,"owners_count":21763878,"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":["compiler","llvm","llvm-javascript","parser","programming-language","typescript"],"created_at":"2024-10-03T13:10:13.940Z","updated_at":"2025-05-05T16:40:40.597Z","avatar_url":"https://github.com/willothy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Letter\n[![CodeQL](https://github.com/willothy/Letter/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/willothy/Letter/actions/workflows/codeql-analysis.yml)\n[![DeepSource](https://deepsource.io/gh/willothy/Letter.svg/?label=active+issues\u0026show_trend=true\u0026token=s7FPYpp55Oo71OQtpE1BL1Hm)](https://deepsource.io/gh/willothy/Letter/?ref=repository-badge)\n[![DeepSource](https://deepsource.io/gh/willothy/Letter.svg/?label=resolved+issues\u0026show_trend=true\u0026token=s7FPYpp55Oo71OQtpE1BL1Hm)](https://deepsource.io/gh/willothy/Letter/?ref=repository-badge)\n\nLetter is a compiler project built in TypeScript using the [llvm-bindings](https://github.com/ApsarasX/llvm-bindings) module. The parser is based off of lectures by [Dmitry Soshnikov](https://github.com/DmitrySoshnikov/). Letter compiles to LLVM IR, which can then be compiled with Clang.\n\nLetter is functional-only at the moment, though the parser supports objects and I plan on implementing them.\n\nSince Letter compiles using LLVM, it is compatible with C and C++. This hasn't been tested much, but there's an example of a Letter function being called from a C program in the `/example/c-link/` folder.\n\nLetter requires an installation of LLVM 13. The [llvm-bindings](https://github.com/ApsarasX/llvm-bindings) readme has good installation instructions.\n\nFeatures that are working now: \n- Main function as entry point\n- Preprocessor (import, define)\n- Math operations\n- Extern functions\n- Function definitions\n    - Void type\n    - Overloading\n- If statements\n- Implicit typecasting of numbers\n- Printing values using print.lt (printf wrapper)\n- Strings, Floats, Doubles, Booleans, Integers \n\n\u003cbr\u003e\nUse:\u003cbr\u003e\nThe released version is outdated: I'll update this when there's a release with LLVM working fully. For now, it must be run from node.\n\nRun the compiler using `npm run compile \u003cfilename\u003e`. This will run letter and clang, prividing an executable.\u003cbr\u003e\nTo build an object file, run `npm run object \u003cfilename\u003e`.\nThe below flags don't work with this command - only with `npx ts-node ./letter.ts -f \u003cfilename\u003e \u003cflags\u003e` which will generate llvm IR.\nYou then need to compile this IR using clang.\n\u003cbr\u003e\n\nCurrent flags available:\nTested:\n- `-s, --stack`: Prints the full JS stack on error. Normally, errors just print the message without stack trace when no debug flags are set.\n- `-t, --tokens`: Prints a list of all tokens in the program, including from imported files.\n- `-a, --ast`: Prints the full program's AST representation in JSON.\n- `-i, --emit-ir`: Emits LLVM IR for compilation.\n\nUntested with new versions:\n- `-m, --minify`: Combines all code into one file, and turns it into one line.\n    - Recommended use: `./bin/letter.rdp -f filename --minify \u003e file.min.lt`\n\nSample programs and are included in the `/example/` folder. \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillothy%2Fletter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillothy%2Fletter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillothy%2Fletter/lists"}