All Projects → comby-tools → Comby

comby-tools / Comby

Licence: apache-2.0
A tool for structural code search and replace that supports ~every language.

Programming Languages

javascript
184084 projects - #8 most used programming language
python
139335 projects - #7 most used programming language
java
68154 projects - #9 most used programming language
c
50402 projects - #5 most used programming language
go
31211 projects - #10 most used programming language
typescript
32286 projects
swift
15916 projects
rust
11053 projects
ocaml
1615 projects
reason
219 projects

Projects that are alternatives of or similar to Comby

comby-rust
Rust refactoring templates for comby, the structural find-and-replace tool.
Stars: ✭ 23 (-97.48%)
Mutual labels:  refactoring, parsing, linting
librxvm
non-backtracking NFA-based regular expression library, for C and Python
Stars: ✭ 57 (-93.75%)
Mutual labels:  parsing, regex
CVparser
CVparser is software for parsing or extracting data out of CV/resumes.
Stars: ✭ 28 (-96.93%)
Mutual labels:  parsing, regex
php.json
A library for simplifying JSON linting and validation.
Stars: ✭ 59 (-93.53%)
Mutual labels:  parsing, linting
parser-lang
A parser combinator library with declarative superpowers
Stars: ✭ 25 (-97.26%)
Mutual labels:  parsing, parser-combinators
es6-template-regex
Regular expression for matching es6 template delimiters in a string.
Stars: ✭ 15 (-98.36%)
Mutual labels:  syntax, regex
parser-combinators
Lightweight package providing commonly useful parser combinators
Stars: ✭ 41 (-95.5%)
Mutual labels:  parsing, parser-combinators
rita-dsl
A Domain Specific Language (DSL) for building language patterns. These can be later compiled into spaCy patterns, pure regex, or any other format
Stars: ✭ 60 (-93.42%)
Mutual labels:  parsing, regex
Idiosyncratic Ruby.com
Documenting All Ruby Specialities 💎︎
Stars: ✭ 292 (-67.98%)
Mutual labels:  regex, syntax
Pom
PEG parser combinators using operator overloading without macros.
Stars: ✭ 310 (-66.01%)
Mutual labels:  parser-combinators, parsing
Kgt
BNF wrangling and railroad diagrams
Stars: ✭ 312 (-65.79%)
Mutual labels:  parsing, syntax
Ramble
A R parser based on combinatory parsers.
Stars: ✭ 19 (-97.92%)
Mutual labels:  parsing, parser-combinators
ParsecSharp
The faster monadic parser combinator library for C#
Stars: ✭ 23 (-97.48%)
Mutual labels:  parsing, parser-combinators
metal
A Java library for parsing binary data formats, using declarative descriptions.
Stars: ✭ 13 (-98.57%)
Mutual labels:  parsing, parser-combinators
Pidgin
C#'s fastest parser combinator library
Stars: ✭ 469 (-48.57%)
Mutual labels:  parser-combinators, parsing
loquat
Monadic parser combinators for JavaScript / TypeScript
Stars: ✭ 47 (-94.85%)
Mutual labels:  parsing, parser-combinators
postcss-jsx
PostCSS syntax for parsing CSS in JS literals
Stars: ✭ 73 (-92%)
Mutual labels:  syntax, parsing
Syntax
Write value-driven parsers quickly in Swift with an intuitive SwiftUI-like DSL
Stars: ✭ 134 (-85.31%)
Mutual labels:  parsing, parser-combinators
python-hslog
Python module to parse Hearthstone Power.log files
Stars: ✭ 37 (-95.94%)
Mutual labels:  parsing, regex
Angstrom
Parser combinators built for speed and memory efficiency
Stars: ✭ 434 (-52.41%)
Mutual labels:  parser-combinators, parsing

comby

Apache-2.0 Build Status Coverage Status codecov Downloads Commit Gitter

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).

Need help writing patterns or have other problems? Post them in Gitter.

Install (pre-built binaries)

Mac OS X

  • brew install comby

Ubuntu Linux

  • bash <(curl -sL get.comby.dev)

  • 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.

Windows

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

  • Create a new switch if you don't have OCaml installed:

opam init
opam switch create 4.11.0 4.11.0
  • Install OS dependencies:

    • Linux: sudo apt-get install pkg-config libpcre3-dev

    • Mac: brew install pkg-config pcre

  • Then install the library dependencies:

git clone https://github.com/comby-tools/comby
cd comby && opam install . --deps-only -y
  • Run eval $(opam env)

  • Build and test

make
make test
  • If you want to install comby on your PATH, run
make install
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].