On 11/18/11 14:03, Patrick Haller wrote:
On 2011-11-18 11:40, pancake wrote:
$ cat dwm.c | sed -e 's,;,ROFL\n,g' |grep ROFL |wc -l
use cpp to deal with the includes, defines, comments.
__sloc()
{
grep -v '^#include.*<' "$1" | cpp - | grep -v '^#' | grep -v '^$'
}
sloc()
{
__sloc "$1" | wc -l
__sloc "$1" | sed -e 's,;,ROFL\n,g' |grep ROFL |wc -l
__sloc "$1" | sed -e 's,(,ROFL\n,g' |grep ROFL |wc -l
}
worrying about stuff like the next seems tree/forest-y
if (error)
return printf("boot->head => missed?"), -1;
you can use gcc -E or cpp output to parse
btw, anyone recommend a suckless AST tool for C?
Patrick
i wrote ALT a while ago. its not C specific, but can be used for basic
c-like syntaxes.
a part from that, parsing C sucks a lot, and the only solution i could
imagine is
by using tcc or sparse, but both solutions sucks in some way or other.
--pancake