-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsloc_count.sh
More file actions
executable file
·46 lines (37 loc) · 1.53 KB
/
sloc_count.sh
File metadata and controls
executable file
·46 lines (37 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
SRC="Base.hs Closure.hs CodeGen.hs Containers.hs Core.hs DataCon.hs Dependency.hs Eval.hs Inliner.hs Nano.hs Parser.hs PrimOps.hs ScopeCheck.hs Syntax.hs Types.hs"
FULL=`cat $SRC | wc -l | sed -E 's/[ ]*([1-9]+)/\1/g'`
ANNT=`grep "::" $SRC | wc -l | sed -E 's/[ ]*([1-9]+)/\1/g'`
TYPE=`grep "^type " $SRC | wc -l | sed -E 's/[ ]*([1-9]+)/\1/g'`
DATA=`grep "^data " $SRC | wc -l | sed -E 's/[ ]*([1-9]+)/\1/g'`
DCON=`grep "^ |" $SRC | wc -l | sed -E 's/[ ]*([1-9]+)/\1/g'`
DERV=`grep "^ deriving" $SRC | wc -l | sed -E 's/[ ]*([1-9]+)/\1/g'`
HASKELL_CLOC=`cloc --quiet --csv $SRC | grep Haskell`
ASM_CLOC=`cloc --quiet --csv rts.asm sys_macos.asm | grep Assembly`
C_CLOC=`cloc --quiet --csv rts.c | grep C`
IFS=',' #setting comma as delimiter
read -a arr <<< "$HASKELL_CLOC"
BLNK=${arr[2]}
CMMT=${arr[3]}
HSLN=${arr[4]}
read -a arr <<< "$ASM_CLOC"
ASML=${arr[4]}
read -a arr <<< "$C_CLOC"
CRTS=${arr[4]}
echo "raw lines = $FULL"
echo "blank = $BLNK"
echo "comment = $CMMT"
echo "haskell lines = $HSLN"
echo "type annotations = $ANNT"
echo "type aliases = $TYPE"
echo "data declarations = $DATA"
echo "data constructors = $DCON"
echo "deriving = $DERV"
IGNORED=`expr $ANNT + $TYPE + $DATA + $DCON + $DERV`
ESSENTIAL=`expr $HSLN - $IGNORED`
echo "============================"
echo "haskell lines = $HSLN"
echo "from this ignored = $IGNORED"
echo "essential lines = $ESSENTIAL"
echo "C runtime = $CRTS"
echo "assembly runtime = $ASML"