{"id":13467880,"url":"https://github.com/comby-tools/comby","last_synced_at":"2025-05-14T04:09:29.535Z","repository":{"id":34688244,"uuid":"180236648","full_name":"comby-tools/comby","owner":"comby-tools","description":"A code rewrite tool for structural search and replace that supports ~every language.","archived":false,"fork":false,"pushed_at":"2025-03-20T06:34:26.000Z","size":1910,"stargazers_count":2471,"open_issues_count":79,"forks_count":64,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-14T04:58:29.708Z","etag":null,"topics":["c","go","java","javascript","linting","parser-combinators","parsing","php","program-transformation","python","reason","refactoring","regex","rewriting","rust","search-and-replace","swift","syntax","syntax-transformation","typescript"],"latest_commit_sha":null,"homepage":"https://comby.dev","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/comby-tools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","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":"2019-04-08T21:35:40.000Z","updated_at":"2025-04-09T23:02:10.000Z","dependencies_parsed_at":"2024-10-15T02:40:59.070Z","dependency_job_id":"6b8c005b-38ad-407c-9616-6f3f50993889","html_url":"https://github.com/comby-tools/comby","commit_stats":null,"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comby-tools%2Fcomby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comby-tools%2Fcomby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comby-tools%2Fcomby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comby-tools%2Fcomby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/comby-tools","download_url":"https://codeload.github.com/comby-tools/comby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254070107,"owners_count":22009559,"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":["c","go","java","javascript","linting","parser-combinators","parsing","php","program-transformation","python","reason","refactoring","regex","rewriting","rust","search-and-replace","swift","syntax","syntax-transformation","typescript"],"created_at":"2024-07-31T15:01:01.913Z","updated_at":"2025-05-14T04:09:24.519Z","avatar_url":"https://github.com/comby-tools.png","language":"OCaml","readme":"# comby\n\n[![Apache-2.0](https://img.shields.io/badge/license-Apache-blue.svg)](LICENSE)\n[![codecov](https://codecov.io/gh/comby-tools/comby/branch/master/graph/badge.svg?token=I1F0PC32E5)](https://codecov.io/gh/comby-tools/comby)\n[![Downloads](https://img.shields.io/github/downloads/comby-tools/comby/total.svg?color=orange)](Downloads)\n[![Commit](https://img.shields.io/github/last-commit/comby-tools/comby.svg)](Commit)\n\n![](https://user-images.githubusercontent.com/888624/64916761-0b657780-d752-11e9-96e2-cd81a2681139.gif)\n\n### See the [usage documentation](https://comby.dev).\n[A short example below](https://github.com/comby-tools/comby#isnt-a-regex-approach-like-sed-good-enough) shows how comby simplifies matching and rewriting compared to regex approaches like `sed`.\n\n\u003cdetails\u003e\n  \u003csummary\u003eComby supports interactive review mode (click here to see it in action).\u003c/summary\u003e\n\n![](https://user-images.githubusercontent.com/888624/69503010-b8870980-0ed2-11ea-828d-68c152ed9def.gif)\n\n\u003c/details\u003e\n\n## Install (pre-built binaries)\n\n### Mac OS X\n\n- `brew install comby`\n\n### Ubuntu Linux\n\n- `bash \u003c(curl -sL get-comby.netlify.app)`\n\n- **Other Linux distributions**: The PCRE library is dynamically linked in the Ubuntu binary. For other distributions like Arch Linux, a fixup is needed: `sudo ln -s /usr/lib/libpcre.so /usr/lib/libpcre.so.3`. On Fedora, use `sudo ln -s /usr/lib64/libpcre.so /usr/lib64/libpcre.so.3`. Alternatively, consider [building from source](https://github.com/comby-tools/comby#build-from-source).\n\n\n### Windows\n\n- [Install the Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) and install Ubuntu. Then run `bash \u003c(curl -sL get.comby.dev)`\n\n\n### Docker\n\n- `docker pull comby/comby`\n\n\u003cdetails\u003e\n  \u003csummary\u003eclick to expand an example invocation for the docker image\u003c/summary\u003e\n\nRunning with docker on `stdin`:\n\n```bash\ndocker run -a stdin -a stdout -a stderr -i comby/comby '(:[emoji] hi)' 'bye :[emoji]' lisp -stdin \u003c\u003c\u003c '(👋 hi)'\n```\n\n\u003cimg width=\"500\" src=\"https://user-images.githubusercontent.com/888624/64924862-0edf1a00-d7b7-11e9-9c2e-cfeafde5bb4b.png\"\u003e\n\n\u003c/details\u003e\n\n\n\n### Or [try it live](https://bit.ly/2UXkonD).\n\n## Isn't a regex approach like sed good enough?\n\nSometimes, yes. But often, small changes and refactorings are complicated by nested expressions, comments, or strings. Consider the following C-like snippet. Say the challenge is to rewrite the two `if` conditions to the value `1`. Can you write a regular expression that matches the contents of the two if condition expressions, and only those two? Feel free to share your pattern with [@rvtond](https://twitter.com/rvtond) on Twitter.\n\n```c\nif (fgets(line, 128, file_pointer) == Null) // 1) if (...) returns 0\n      return 0;\n...\nif (scanf(\"%d) %d\", \u0026x, \u0026y) == 2) // 2) if (scanf(\"%d) %d\", \u0026x, \u0026y) == 2) returns 0\n      return 0;\n```\n\nTo match these with comby, all you need to write is `if (:[condition])`, and specify one flag that this language is C-like. The replacement is `if (1)`. See the [live example](https://bit.ly/30935ou).\n\n## Build from source\n\n- Install [opam](https://opam.ocaml.org/doc/Install.html). TL;DR do `sh \u003c(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)`\n\n- Run this if you don't have OCaml installed (it bootstraps the OCaml compiler):\n\n```\nopam init\nopam switch create 4.11.0 4.11.0\n```\n\n- Run `eval $(opam env)`\n\n\n- Install OS dependencies:\n\n  - **Linux:** `sudo apt-get install autoconf libpcre3-dev pkg-config zlib1g-dev m4 libgmp-dev libev4 libsqlite3-dev`\n\n  - **Mac:** `brew install pkg-config gmp pcre libev`\n\n- Then install the library dependencies:\n\n```\ngit clone https://github.com/comby-tools/comby\ncd comby \nopam install . --deps-only\n```\n\n- Build and test\n\n```\nmake\nmake test\n```\n\n- Install `comby` on your `PATH` by running\n\n```\nmake install\n```\n","funding_links":[],"categories":["OCaml","Ocaml","\u003ca name=\"core\"\u003e\u003c/a\u003ecore","Libraries and refactoring","Git Tools","c","Repositories"],"sub_categories":["Repository management tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomby-tools%2Fcomby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomby-tools%2Fcomby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomby-tools%2Fcomby/lists"}