Page
Library
Module
Module type
Parameter
Class
Class type
Source
A short example below shows how comby simplifies matching and rewriting compared to regex approaches like sed
.
Need help writing patterns or have other problems? Post them in Gitter.
brew install comby
bash <(curl -sL get.comby.dev)
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.bash <(curl -sL get.comby.dev)
docker pull comby/comby
Running with docker on stdin
:
docker run -a stdin -a stdout -a stderr -i comby/comby '(:[emoji] hi)' 'bye :[emoji]' lisp -stdin <<< '(👋 hi)'
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 0
return 0;
...
if (scanf("%d) %d", &x, &y) == 2) // 2) if (scanf("%d) %d", &x, &y) == 2) returns 0
return 0;
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.
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
opam init
opam switch create 4.11.0 4.11.0
eval $(opam env)
Install OS dependencies:
sudo apt-get install autoconf libpcre3-dev pkg-config zlib1g-dev m4 libgmp-dev libev-dev libsqlite3-dev
brew install pkg-config gmp pcre libev
git clone https://github.com/comby-tools/comby
cd comby
opam install ./comby-kernel.opam --deps-only
opam install ./comby-semantic.opam --deps-only
opam install ./comby.opam --deps-only
make
make test
comby
on your PATH
by runningmake install