{"id":23642435,"url":"https://github.com/sogaiu/janet-ts-dsl","last_synced_at":"2025-08-31T18:32:58.074Z","repository":{"id":118761809,"uuid":"601857245","full_name":"sogaiu/janet-ts-dsl","owner":"sogaiu","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-06T13:32:50.000Z","size":92,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-09-06T15:05:16.484Z","etag":null,"topics":["dsl","edn","janet","jdn","json","tree-sitter"],"latest_commit_sha":null,"homepage":"","language":"Janet","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/sogaiu.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,"publiccode":null,"codemeta":null}},"created_at":"2023-02-15T01:06:28.000Z","updated_at":"2024-09-06T13:32:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"5b6973aa-9132-4794-a33f-88bc69c950b7","html_url":"https://github.com/sogaiu/janet-ts-dsl","commit_stats":{"total_commits":25,"total_committers":1,"mean_commits":25.0,"dds":0.0,"last_synced_commit":"64d68ff690ef4ad47e8a28194a0caeee76872833"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fjanet-ts-dsl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fjanet-ts-dsl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fjanet-ts-dsl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fjanet-ts-dsl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sogaiu","download_url":"https://codeload.github.com/sogaiu/janet-ts-dsl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231615472,"owners_count":18400983,"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":["dsl","edn","janet","jdn","json","tree-sitter"],"created_at":"2024-12-28T10:51:00.005Z","updated_at":"2024-12-28T10:51:00.640Z","avatar_url":"https://github.com/sogaiu.png","language":"Janet","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EDN / JDN Tree-sitter Grammar DSL\n\nSupport for converting a tree-sitter grammar expressed in\n[EDN](https://github.com/edn-format/edn) or\n[JDN](https://github.com/andrewchambers/janet-jdn) to `grammar.json`\nand `grammar.js`.\n\nHere's a bit of how it can look:\n\n```clojure\n :rules\n [:source [:repeat [:choice :_form\n                            :_gap]]\n\n  :_gap [:choice :_ws\n                 :comment\n                 :dis_expr]\n\n  :_ws :WHITESPACE\n\n  :comment :COMMENT\n\n  :dis_expr [:seq [:field \"marker\" \"#_\"]\n                  [:repeat :_gap]\n                  [:field \"value\" :_form]]\n```\n\nSee the `data` directory for some examples.\n\n## Background\n\nThe default DSL for expressing a grammar for tree-sitter is something\nthat is quite close to but [not quite a standard\nJavaScript](./doc/javascript.md).\n\nThe TLDR is that I found working with JavaScript and existing\nformatters for this particular endeavor to be unsatisfactory enough to\nconsider investigating alternatives.\n\nSpecifically, being able to work with EDN or JDN seems to reduce\nenough some problems I experienced with `grammar.js`.\n\nSee [here](./doc/rationale.md) for detailed background.\n\n## Status\n\nIt's possible to create `grammar.json` as well as `grammar.js`\nstarting from `grammar.edn` / `grammar.jdn`.\n\n### `grammar.json`\n\nThe tooling here can do the left arrow portion of:\n\n```\ngrammar.edn -\u003e grammar.json -\u003e parser.c\n```\n\nThe right arrow portion can be accomplished by invoking `tree-sitter\ngenerate grammar.json`.\n\nThe resulting `parser.c` is the same as if one used a typical\n`tree-sitter generate` invocation that does:\n\n```\ngrammar.js -\u003e (grammar.json -\u003e) parser.c\n```\n\nNote that using the former sequence starting with `grammar.edn` (or\n`grammar.jdn`) does not use `node`, whereas the latter sequence that\nstarts with `grammar.js` does.\n\n### `grammar.js`\n\nIt's possible to generate `grammar.js` from `grammar.edn` or\n`grammar.jdn`.\n\nThis means that in theory one can test how well the generation works via\ntwo paths:\n\n1. `grammar.jdn` / `grammar.edn` -\u003e `grammar.json`\n2. `grammar.edn` / `grammar.jdn` -\u003e `grammar.js`\n\nAfter creating `grammar.json` via path 1 using the tooling here,\n`grammar.js` can be generated via path 2 and then by using\n`tree-sitter generate`, another `grammar.json` can be created and\ncompared with the one generated by path 1.\n\nAnother use of `grammar.js` generation might be if there is a desire\nto stop using the tooling at some point.  To do this, it would be\nnicer if comments were maintained and formatting was nicer in the\ngenerated `grammar.js` :)\n\n## Observations\n\nSome miscellaneous observations:\n\n* `grammar.edn` does not have to be written by hand.  One can write\n  code (e.g. in Clojure) to generate `grammar.edn`.  Similarly for\n  `grammar.jdn`.\n\n* It's not necessary to express a grammar for Clojure using\n  `grammar.edn`.  It should be possible to write grammars for other\n  programming languages as well.  Similarly for Janet and\n  `grammar.jdn`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsogaiu%2Fjanet-ts-dsl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsogaiu%2Fjanet-ts-dsl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsogaiu%2Fjanet-ts-dsl/lists"}