TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

CGrep: a context-aware grep for source codes

109 pointsby psibialmost 11 years ago

18 comments

gingerlimealmost 11 years ago
This looks like a cool idea. I think a couple of (neat!) examples, stuff you can't easily do with normal grep, will go a very long way. The list of features is secondary in my opinion.
评论 #7922465 未加载
评论 #7921590 未加载
评论 #7920677 未加载
bogoliskalmost 11 years ago
blah.c:<p><pre><code> void foo(item *x) { x-&gt;blah(1, 2, 3); x-&gt;blah (4, 5, 6); blah (7, 5, 1); foo (4, 5, 6); x-&gt;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-&gt;blah (4, 5, 6); } </code></pre> search in blah.c for a call to <i>blah()</i> with <i>5</i> as 2nd argument from any structure or pointer.<p><pre><code> cgrep --code --semantic &#x27;_1 . OR -&gt; blah ( _2 , 5, _3 )&#x27; blah.c </code></pre> output:<p><pre><code> blah.c:6: x-&gt;blah (4, 5, blah.c:7: 6); blah.c:10: x-&gt;blah (4, blah.c:11: 5, 6); blah.c:18: y.blah (4, 5, blah.c:19: 6); blah.c:22: x-&gt;blah (4, blah.c:23: 5, 6);</code></pre>
egonschielealmost 11 years ago
I&#x27;ve thought about something like this before, and I&#x27;m really excited to see how fully-featured it is. Written in Haskell is also a big plus.
ushialmost 11 years ago
Funny, there was a bell-labs project with same name. It seems to be dead[0], but when we travel the time a few years back, we get a wonderful project homepage[1].<p>[0] <a href="http://www1.bell-labs.com/project/wwexptools/cgrep/" rel="nofollow">http:&#x2F;&#x2F;www1.bell-labs.com&#x2F;project&#x2F;wwexptools&#x2F;cgrep&#x2F;</a><p>[1] <a href="https://web.archive.org/web/20080513225010/http://www1.bell-labs.com/project/wwexptools/cgrep/" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20080513225010&#x2F;http:&#x2F;&#x2F;www1.bell-...</a>
chris_wotalmost 11 years ago
I&#x27;m not sure where the documentation is.
评论 #7923157 未加载
评论 #7920483 未加载
评论 #7920561 未加载
edderlyalmost 11 years ago
I was curious, but had no idea how to use this on Ubuntu<p>sudo apt-get install haskell-platform<p>download and extract the tarball<p>cd awgn-cgrep-8af1beb<p>cabal cgrep.cabal<p>Unfortunately what stops me using it on a large codebase is that I can&#x27;t exclude directories like .repo (not sure about .git).
githulhualmost 11 years ago
Darn, no SQL support. I often find myself wishing something like this existed for SQL, so I could, say, find all places where field X in table Y is updated, or referenced in a WHERE clause predicate, etc.
评论 #7921118 未加载
yawniekalmost 11 years ago
a binary for os x would be nice, since installing cabal&#x2F;ghc currently is a bit of a pain
评论 #7920621 未加载
cheezalmost 11 years ago
How do I build this for Windows? I think I have something Haskell related installed because I see lambda as an icon on the .hs files.
jasonlfunkalmost 11 years ago
What is the difference between this and ack?<p><a href="http://beyondgrep.com" rel="nofollow">http:&#x2F;&#x2F;beyondgrep.com</a>
评论 #7921463 未加载
mcrideralmost 11 years ago
Would love a UI for this and an editor -- I still use TextWrangler&#x2F;BBEdit daily to grep large chunks of source code and then edit in place (e.g. for refactoring). Just getting the search results requires opening up each file individually then editing, which is just too slow.
michaelmioralmost 11 years ago
JSON output is incredibly useful in combination with jq[1] for processing the output. Some things become much easier than with standard *nix tools IMO.<p>[1] <a href="http://stedolan.github.io/jq/" rel="nofollow">http:&#x2F;&#x2F;stedolan.github.io&#x2F;jq&#x2F;</a>
nodivbyzeroalmost 11 years ago
Have you tried <a href="https://github.com/zeux/qgrep" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;zeux&#x2F;qgrep</a> ??? Fast regular expression grep for source code with incremental index updates
res0nat0ralmost 11 years ago
Any examples or reasons why I should use this over the_silver_searcher?
volunealmost 11 years ago
How does this compare with Ack?
kumarishanalmost 11 years ago
can it be integrated with sublime text ?
wangweijalmost 11 years ago
Examples or it didn&#x27;t happen.
评论 #7921233 未加载
WorldWideWaynealmost 11 years ago
It really sucks that 15 languages that people use <i>less</i> than C# are supported before anyone thinks of adding support for C#.<p>Why does everyone hate Microsoft&#x27;s languages and love Apples?
评论 #7921983 未加载
评论 #7922199 未加载