comby

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

APACHE-2.0 License

Stars
2.4K

Bot releases are hidden (Show)

comby - 1.8.1 Latest Release

Published by rvantonder over 2 years ago

  • Matches are now flushed to stdout per result (previously comby would possibly buffer more than one result).
comby - 1.8.0

Published by rvantonder over 2 years ago

  • using the -tar option now outputs file paths in results (previously null)

  • experimental: using the -omega option, whitespace between delimiters will be matched loosely instead of strictly. This gives more flexibility for pattern matching, g.g., a pattern like foo(bar) will match any of: foo( bar), foo(bar ) or something like

foo(
              bar
)

This only applies to whitespace immediately after an opening delimiter, and whitespace immediately preceding a closing delimiter.

comby - 1.7.1

Published by rvantonder over 2 years ago

Fixes JSON output of -json-lines which previously emitted double-escaped values like \\n instead of \n

comby - 1.7.0

Published by rvantonder over 3 years ago

  • update language definitions (MATLAB, R)

  • recognize Terraform file extension .tf for -lang flag (previously .hcl).

  • additional property accesses .file aliased to file.path

  • fixes behavior so that -newline-separated works with rewrite {...} rules

  • custom metasyntax is now recognized for all terms inside rules

  • custom metasyntax aliases are now applied to rules

comby - 1.6.0

Published by rvantonder over 3 years ago

Utility properties for holes. The following are introduced and recognized in rules and rewrite templates, and are substituted:

  • Length. Substitute the length of a hole in rules and rewrite templates
:[hole].length
  • String conversions. The following are recognized pattern that will substitute the value of :[hole] with the respective string processing in rewrite templates and rules
:[hole].lowercase
:[hole].UPPERCASE
:[hole].Capitalize
:[hole].uncapitalize
:[hole].UpperCamelCase
:[hole].lowerCamelCase
:[hole].UPPER_SNAKE_CASE
:[hole].lower_snake_case
  • Filepaths. Substitute the file name, file path, or directory
:[hole].file.path
:[hole].file.name
:[hole].file.directory

  • Simpler rule syntax modifications. Less strict parsing and more convenient/readable possibilities for rule syntax.
  • trailing commas for rule expressions are OK:
where :[x] == :[y],
where match :[x] {
|  :[y] -> :[z],
},
  • optional first | for pattern matching:
where match :[x] { :[y] -> :[z] }
  • convenience interpretations for _:
where match :[x] { _ -> :[z] }

implies

where match :[x] { :[_] -> :[z] }
  • convenience interpretation for regex ~:
where match :[x] { ~match-regex -> :[z] }

implies

where match :[x] { :[~match-regex] -> :[z] }
  • Single, double escapable quotes in match and rewrite cases (interprets \t, \n, \r, \\ escape sequences):
where match :[x] { '"yep"\n' -> :[z] }
  • Raw string quotes (no interpreting escape sequences)
where match :[x] { `"yep"\n` -> :[z] }
  • Heuristic parsing for patterns in match cases that require neither quotes nor recognized variable:
where match :[x] { foo(:[x]) -> :[x] }
where rewrite :[x] { foo(:[x]) -> :[x] }

Behavior looks for the first ->, so -> must be escaped if this should be matched literally. Trailing and leading spaces in pattern matches are ignored--use quotes for significant leading and trailing spaces


  • Added .hcl language definition

  • The experimental optional hole syntax is removed. Use regular expressions holes with optional modifiers ? instead.

comby - 1.5.1

Published by rvantonder over 3 years ago

  • Changed -rg option to not emit an error when no matches/files are found to process.
comby - 1.5.0

Published by rvantonder over 3 years ago

  • Support general metasyntax customization. See blog post and docs for more.

  • Fixed an issue where substituting for regex syntax required repeating the pattern in the rewrite template. E.g., if a pattern like :[x~\w+] matched, it was necessary to specify :[x~\w+] in the rewrite template, instead of just :[x]. Now you can specify just :[x].

  • It's now possible to define only match=... fields if you only want to implement a checker without rewrite=... in config files. This wasn't working correctly before (omitting rewrite would not work, or multiple match patterns would be ignored).

comby - 1.4.1

Published by rvantonder over 3 years ago

No functional changes. This is just a package split for comby the app, and comby-kernel, a minimal OCaml library.

comby - 1.4.0

Published by rvantonder over 3 years ago

  • Allow specifying custom metasyntax definitions on the commandline via -custom-metasyntax #261
comby - 1.3.0

Published by rvantonder over 3 years ago

  • Exposes Library API through comby.mli
  • Support custom metasyntax definition (internal Library API)
comby - 1.2.2

Published by rvantonder over 3 years ago

  • Minor description change for opam packaging
  • Update various tests to run sequentially
comby - 1.2.1

Published by rvantonder over 3 years ago

  • Updates dependencies to work with OCaml 4.12 and creates opam release candidate.
comby - 1.2.0

Published by rvantonder over 3 years ago

  • adds ability to build on arm systems
  • adds -parany option to use an alternative parallel library. -parany is the default parallel library on arm systems
  • undos recognizing regex delimiters in JS and TS like /.../ because this may conflict with division syntax
comby - 1.1.0

Published by rvantonder over 3 years ago

  • adds -bound-count flag

Stop running when at least num matches are
found (possibly more are returned for parallel
jobs).

  • avoids writing to file system if a file is unchanged

  • bug fix: don't parse for comments inside strings

  • bug fix: don't assume single quotes in Haskell are balanced

  • adds additional delimiters to interpret code blocks in Julia

  • adds support for Coq, Zig, Solidity, and Move languages by adding basic definitions

  • bug fix where strings should have been escaped in -match-only JSON output

  • bug fix where carriage returns\r were not escaped in match output

  • fresh variable generation via :[id()] in -sequential mode increment sequentially

  • add experimental nested matching via where nested

comby - 1.0.0

Published by rvantonder about 4 years ago

Breaking change:

  • :[hole] will only match across newlines If they are inside delimiters for a language. Otherwise, it will match at most to the end of line, rather than across multiple lines or to the end of file. To disable this behavior and force matching across newlines for any language, add the flag -match-newline-at-toplevel. There is one exception to this change: The following languages/file extensions are unaffected and will continue to match across newlines outside delimiters:
    • .tsx, .jsx, .html, .xml, .tex, .txt
      This is because tags like <p>...</p> are not yet considered proper delimiters, and other textual inputs do not typically contain delimiters.

Additions:

  • The ellipses ... alias can now be used instead of :[_] in rules. Example:
where match :[args] {                                                                                                                                                                                                                                                                                                                                                                                      
| "..., foo, ..." -> true                                                                                                                                                                                      
| "..." -> false                                                                                                                                                                                               
}
comby - 0.18.4

Published by rvantonder about 4 years ago

  • Unbreaks a breaking change introduced in 0.18.0. It undos:
    • Simplify matching for :[hole]: If they are not inside nested delimiters, only match until it's suffix, or end of line (rather than end of file).
  • The above behavior can be set with the flag -cut-off-newline
comby - 0.18.3

Published by rvantonder about 4 years ago

  • ... in templates alias to :[_]
comby - 0.18.2

Published by rvantonder about 4 years ago

  • Make identifier optional in regex holes.
comby - 0.18.1

Published by rvantonder about 4 years ago

  • Fixes a regression where paths would not be matched in zip files.
comby - 0.18.0

Published by rvantonder about 4 years ago

  • Add support for regex holes
  • Fuzzy match whitespace inside strings
  • Simplify matching for :[hole]: If they are not inside nested delimiters, only match until it's suffix, or end of line (rather than end of file).
  • Fix: comments in template imply whitespace
  • Add definitions for GraphQL, Dhall, JSONC