GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - comby-tools/comby: A code rewrite tool for structural search and replace that supports ~every language.

BranchesTags
Open more actions menu

Latest commit

 

History

518 Commits
518 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
dockerfiles
dockerfiles
 
 
docs
docs
 
 
lib
lib
 
 
scripts
scripts
 
 
src
src
 
 
test
test
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
.ocamlformat
.ocamlformat
 
 
.ocamlformat-ignore
.ocamlformat-ignore
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
comby-kernel.opam
comby-kernel.opam
 
 
comby-semantic.opam
comby-semantic.opam
 
 
comby.opam
comby.opam
 
 
dune
dune
 
 
dune-project
dune-project
 
 
push-coverage-report.sh
push-coverage-report.sh
 
 

Repository files navigation

comby

Apache-2.0 codecov Downloads Commit

See the usage documentation.

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: Releases up to 1.8.1 dynamically link the PCRE library, which newer distributions no longer ship. For those releases, consider building from source instead. Comby no longer depends on PCRE as of this source tree.

Windows

  • Install the Windows Subsystem for Linux and install Ubuntu. Then run bash <(curl -sL get.comby.dev)

Docker

  • docker pull comby/comby
click to expand an example invocation for the docker image

Running with docker on stdin:

docker run -a stdin -a stdout -a stderr -i comby/comby '(:[emoji] hi)' 'bye :[emoji]' lisp -stdin <<< '(👋 hi)'

Or try it live.

Isn't a regex approach like sed good enough?

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.

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 an OCaml 5 switch installed (it bootstraps the OCaml compiler):

opam init
opam switch create 5.1.0 5.1.0
  • Run eval $(opam env)

  • Install OS dependencies:

    • Linux: sudo apt-get install autoconf pkg-config zlib1g-dev m4 libgmp-dev libev4 libsqlite3-dev

    • Mac: brew install pkg-config gmp libev

  • Then install the library dependencies:

git clone https://github.com/comby-tools/comby
cd comby 
opam install . --deps-only
  • Build and test
make
make test
  • Install comby on your PATH by running
make install

About

A code rewrite tool for structural search and replace that supports ~every language.

comby.dev

Topics

cgojavajavascriptlintingparser-combinatorsparsingphpprogram-transformationpythonreasonrefactoringregexrewritingrustsearch-and-replaceswiftsyntaxsyntax-transformationtypescript

Resources

Readme
Apache-2.0 license

Code of conduct

Code of conduct

Contributing

Contributing
Activity
Custom properties

Stars

2.7k stars

Watchers

22 watching

Forks

75 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.