{"id":23642458,"url":"https://github.com/sogaiu/clojure-peg","last_synced_at":"2025-08-31T18:32:58.833Z","repository":{"id":118761586,"uuid":"286327574","full_name":"sogaiu/clojure-peg","owner":"sogaiu","description":"Parsing and Generating Clojure...Using Janet","archived":false,"fork":false,"pushed_at":"2024-08-06T15:57:18.000Z","size":190,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-06T18:51:05.896Z","etag":null,"topics":["clojure","janet","peg"],"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":"support/test-samples.janet","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-09T22:34:44.000Z","updated_at":"2024-08-06T15:57:22.000Z","dependencies_parsed_at":"2024-08-06T18:41:24.870Z","dependency_job_id":null,"html_url":"https://github.com/sogaiu/clojure-peg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fclojure-peg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fclojure-peg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fclojure-peg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogaiu%2Fclojure-peg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sogaiu","download_url":"https://codeload.github.com/sogaiu/clojure-peg/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":["clojure","janet","peg"],"created_at":"2024-12-28T10:51:04.056Z","updated_at":"2024-12-28T10:51:04.785Z","avatar_url":"https://github.com/sogaiu.png","language":"Janet","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clojure-peg\n\nSome code for parsing and generating Clojure source code...using\nJanet's Parsing Expression Grammar support.\n\n## Usage Examples\n\nBasic Parsing and Generation\n```janet\n(import clojure-peg/rewrite)\n\n# parse code string\n(rewrite/par \"(+ 1 1)\")\n# =\u003e\n'@[:code\n   (:list\n     (:symbol \"+\") (:whitespace \" \")\n     (:number \"1\") (:whitespace \" \")\n     (:number \"1\"))]\n\n# generate code string\n(rewrite/gen\n  '@(:map\n     (:keyword \":a\") (:whitespace \" \")\n     (:number \"1\")))\n# =\u003e\n\"{:a 1}\"\n\n# roundtrip\n(def src \"{:x  :y \\n :z  [:a  :b    :c]}\")\n\n(= (rewrite/gen (rewrite/par src))\n   src)\n# =\u003e\ntrue\n\n# replace underscores in keywords with dashes\n(def src-2\n  \"(defn a [] {:a_1 1 :b_2 2})\")\n\n(rewrite/gen\n  (postwalk |(if (and (tuple? $)\n                      (= (first $) :keyword)\n                      (string/find \"_\" (in $ 1)))\n               (tuple ;(let [arr (array ;$)]\n                         (put arr 1\n                              (string/replace-all \"_\" \"-\" (in $ 1)))))\n               $)\n            (rewrite/par src-2)))\n# =\u003e\n\"(defn a [] {:a-1 1 :b-2 2})\"\n```\n\nWith Location Info\n```janet\n(import clojure-peg/location)\n\n# parse code string\n(location/par \"(+ 1 1)\")\n# =\u003e\n'@[:code @{:bc 1 :bl 1\n           :ec 8 :el 1}\n   (:list @{:bc 1 :bl 1\n            :ec 8 :el 1}\n          (:symbol @{:bc 2 :bl 1\n                     :ec 3 :el 1} \"+\")\n          (:whitespace @{:bc 3 :bl 1\n                         :ec 4 :el 1} \" \")\n          (:number @{:bc 4 :bl 1\n                     :ec 5 :el 1} \"1\")\n          (:whitespace @{:bc 5 :bl 1\n                         :ec 6 :el 1} \" \")\n          (:number @{:bc 6 :bl 1\n                     :ec 7 :el 1} \"1\"))]\n\n# generate code string\n(location/gen\n  '@[:code @{}\n     (:list @{}\n            (:symbol @{} \"+\")\n            (:whitespace @{} \" \")\n            (:number @{} \"1\")\n            (:whitespace @{} \" \")\n            (:number @{} \"1\"))])\n# =\u003e\n\"(+ 1 1)\"\n\n# roundtrip\n(def src \"{:x  :y \\n :z  [:a  :b    :c]}\")\n\n(= (location/gen (location/par src))\n   src)\n# =\u003e\ntrue\n```\n\n## Roundtrip Testing\n\nTo perform roundtrip testing on syntactically valid `.clj` files, use\nthe `test-samples.janet` script in the `support` directory.\n\nFor example, to test all `.clj` files in a directory at path `/tmp/samples`:\n\n```\njanet support/test-samples.janet /tmp/samples\n```\n\nIndividual syntactically valid `.clj` files may also be tested by\nspecifying file paths.\n\nFor example, to test `sample.clj` that lives under `/tmp`:\n\n```\njanet support/test-samples.janet /tmp/sample.clj\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsogaiu%2Fclojure-peg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsogaiu%2Fclojure-peg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsogaiu%2Fclojure-peg/lists"}