CGrep: a context-aware grep for source codes
awgn.github.io
awgn.github.io
On top of that, everything above applied to syntax-driven rewrites and refactorings.
void foo(item *x)
{
x->blah(1, 2, 3);
x->blah (4, 5,
6);
blah (7, 5, 1);
foo (4, 5, 6);
x->blah (4,
5, 6);
}
void foo2(item y, item *x)
{
y.blah(1, 2, 3);
y.blah (4, 5,
6);
blah (7, 5, 1);
foo (4, 5, 6);
x->blah (4,
5, 6);
}
search in blah.c for a call to blah() with 5 as 2nd argument from any structure or pointer. cgrep --code --semantic '_1 . OR -> blah ( _2 , 5, _3 )' blah.c
output: blah.c:6: x->blah (4, 5,
blah.c:7: 6);
blah.c:10: x->blah (4,
blah.c:11: 5, 6);
blah.c:18: y.blah (4, 5,
blah.c:19: 6);
blah.c:22: x->blah (4,
blah.c:23: 5, 6);[0] http://www1.bell-labs.com/project/wwexptools/cgrep/
[1] https://web.archive.org/web/20080513225010/http://www1.bell-...
(Non-snarky follow-up: Haskell code is often woefully under-documented, for whatever reason. Possibly because people think that the type signatures are sufficient, or possibly because Haskell code lends itself to concision and documentation runs counter to that, or possibly because Haskell projects are often the result of one person's work, diminishing the need to explain oneself. In any case, it's an unfortunate fact of many Haskell apps and libraries.)
sudo apt-get install haskell-platform
download and extract the tarball
cd awgn-cgrep-8af1beb
cabal cgrep.cabal
Unfortunately what stops me using it on a large codebase is that I can't exclude directories like .repo (not sure about .git).
I'm surprised there isn't a tool that can do this already.. perhaps under the guise of refactoring?
On my machine it is significantly slower than `ag` (Silver Searcher) for basic searches, but it should install and run.
$cgrep -r --identifier VARname to search for a variable
etc..
Why does everyone hate Microsoft's languages and love Apples?
Languages support for Awk, C, Cpp, Chapel, Csharp, Css,