{"id":20633560,"url":"https://github.com/davidelettieri/sample-racket-language","last_synced_at":"2026-03-07T18:31:08.319Z","repository":{"id":83965655,"uuid":"604734643","full_name":"davidelettieri/sample-racket-language","owner":"davidelettieri","description":"Minimal setup to create a new racket language with custom syntax","archived":false,"fork":false,"pushed_at":"2024-11-26T07:21:46.000Z","size":36,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-08T11:48:15.759Z","etag":null,"topics":["programming-languages","racket","racket-language"],"latest_commit_sha":null,"homepage":"","language":"Racket","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/davidelettieri.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":"2023-02-21T17:19:22.000Z","updated_at":"2025-11-11T00:23:28.000Z","dependencies_parsed_at":"2024-11-16T14:21:56.128Z","dependency_job_id":"fd9529bf-a252-423d-953e-b596da895135","html_url":"https://github.com/davidelettieri/sample-racket-language","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/davidelettieri/sample-racket-language","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidelettieri%2Fsample-racket-language","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidelettieri%2Fsample-racket-language/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidelettieri%2Fsample-racket-language/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidelettieri%2Fsample-racket-language/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidelettieri","download_url":"https://codeload.github.com/davidelettieri/sample-racket-language/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidelettieri%2Fsample-racket-language/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30226245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T18:12:09.766Z","status":"ssl_error","status_checked_at":"2026-03-07T18:11:58.786Z","response_time":53,"last_error":"SSL_read: 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":["programming-languages","racket","racket-language"],"created_at":"2024-11-16T14:21:05.174Z","updated_at":"2026-03-07T18:31:07.451Z","avatar_url":"https://github.com/davidelettieri.png","language":"Racket","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/davidelettieri/sample-racket-language/actions/workflows/ci.yml/badge.svg)](https://github.com/davidelettieri/sample-racket-language/actions/workflows/ci.yml)\r\n\r\n# Minimal setup for a racket language with custom syntax\r\n\r\nThis repo serves as a start project for a new racket language with a custom surface syntax. A parser generator is used to parse a very simple language of aritmetic expression only integers, `+`, `-` and grouping `(..)`. Our sample language supports multiple aritmetic expressions defined on different lines.\r\n\r\nValid expressions in the language are:\r\n```\r\n1+2-(10-2)\r\n```\r\nand\r\n```\r\n4-5\r\n```\r\nand\r\n```\r\n1+2\r\n6+7+9\r\n```\r\nbut not\r\n```\r\n1.5-1\r\n```\r\n\r\n# How to use it\r\n\r\nRun in the root directory of the project\r\n\r\n```bash\r\nraco pkg install\r\n```\r\n\r\nAfter that you will be able to use\r\n```\r\n#lang sample-racket-language\r\n```\r\n\r\nat the top of your racket files. The `use-language.rkt` file contains a minimal example using the language defined in the repo.\r\n\r\nPlease note that the language name `sample-racket-language` is defined into the `info.rkt` file with the syntax\r\n```scheme\r\n(define collection \"sample-racket-language\")\r\n```\r\n\r\nThe folder structure has been created using \r\n\r\n```bash\r\nraco pkg new sample-racket-language\r\n```\r\n\r\nand then customizing the collection name.\r\n\r\n## Running the test suite\r\n\r\n```\r\nraco test -x -p sample-racket-language\r\n```\r\n\r\n## How it works\r\n\r\nThe project leverages the [parser-tools-lib](https://pkgs.racket-lang.org/package/parser-tools-lib) package to create a parser for the sample language.\r\nThe language project is built around three files:\r\n- `lexer.rkt`\r\n- `parser.rkt`\r\n- `main.rkt`\r\n\r\nIn the `lexer.rkt` file we define the tokens of the language differentiating between tokens that are carrying a value with them (for example number literals), using `define-tokens`, and tokens that have no value (for example parenthesis), using `define-empty-tokens`.\r\n\r\nIn the `parser.rkt` we use the tokens defined in the `lexer.rkt` file to define our parser. The parser will return a tree describing the expression using custom functions `add`,`multiply`,`subtract`,`divide` where by custom I mean that racket doesn't provide functions nor macros with these names by default. \r\n\r\nThe `main.rkt` contains the required macros, the required exports and brings everything together defining the language module with a reader submodule.\r\n\r\n```scheme\r\n(module reader racket \r\n    ...)\r\n```\r\n\r\nwhere we provide the `read` and `read-syntax` functions as required when creating a language with a custom surface syntax. The module definition part is sourced from the [racket official documentation](https://docs.racket-lang.org/guide/language-collection.html).\r\n\r\n# Resources\r\n\r\n[This](https://school.racket-lang.org/2019/plan/index.html) is an awesome resource about macros and languages.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidelettieri%2Fsample-racket-language","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidelettieri%2Fsample-racket-language","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidelettieri%2Fsample-racket-language/lists"}