You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A short example below shows how comby simplifies matching and rewriting compared to regex approaches like sed.
Comby supports interactive review mode (click here to see it in action).
Install (pre-built binaries)
Mac OS X
brew install comby
Ubuntu Linux
bash <(curl -sL get-comby.netlify.app)
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.
Sometimes, 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 on Twitter.
if (fgets(line, 128, file_pointer) ==Null) // 1) if (...) returns 0return0;
...
if (scanf("%d) %d", &x, &y) ==2) // 2) if (scanf("%d) %d", &x, &y) == 2) returns 0return0;
To 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.
Build from source
Install opam. TL;DR do sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
Run this if you don't have OCaml installed (it bootstraps the OCaml compiler):