diff options
author | dwheeler <dwheeler@d762cc98-fd17-0410-9a0d-d09172385bc5> | 2006-07-07 13:36:27 +0000 |
---|---|---|
committer | dwheeler <dwheeler@d762cc98-fd17-0410-9a0d-d09172385bc5> | 2006-07-07 13:36:27 +0000 |
commit | 05095851346f52c8e918176e8e2abdf0b21de5ec (patch) | |
tree | 8de964f5eea4c7d80faf34d5d744e215a053ba8f /testcode/test2.lhs | |
download | sloccount-master.tar.gz |
git-svn-id: svn://svn.code.sf.net/p/sloccount/code/trunk@1 d762cc98-fd17-0410-9a0d-d09172385bc5
Diffstat (limited to 'testcode/test2.lhs')
-rw-r--r-- | testcode/test2.lhs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/testcode/test2.lhs b/testcode/test2.lhs new file mode 100644 index 0000000..6e39905 --- /dev/null +++ b/testcode/test2.lhs @@ -0,0 +1,44 @@ + +This is an extract of a larger literate Haskell file for testing +SLOCCount. It should have 21 lines of code. + +This dumps the tree in dot format, which is very handy for visualizing +the trees. + +> dotTree name t = "digraph " ++ filter dotChars name ++ " { " ++ (dotTree' t 0) ++ " }" + +> dotTree' Empty _ = "" +> dotTree' t i | is_leaf t = "n"++(show i)++" [label=\""++(show $ x_span t)++ +> "\",shape=box]; " +> | otherwise = "n"++(show i)++" [label=\""++(show $ x_span t)++"\"]; " ++ +> "n"++(show i)++" -> n"++(show (2*i+1))++"; "++ +> "n"++(show i)++" -> n"++(show (2*i+2))++"; "++ +> dotTree' (left t) (2*i+1) ++ +> dotTree' (right t) (2*i+2) +> where is_leaf Node { left = Empty, right = Empty } = True +> is_leaf _ = False +> {- this is a comment + +foo bar baz + +> that +> spans literate blocks -} + +> dotChars '.' = False +> dotChars '/' = False +> dotChars _ = True + +These functions fill in the monotonically increasing index values for +the lines in the finite map. They also do appropriate things to combine +the world values. + +> idxList [] n = [] +> idxList (x:xs) n = (x {idx=n}):(idxList xs (n+1)) + +> idxFM' fm (x,k) = addToFM (delFromFM fm k) k (y {idx=toInteger x}) +> where y = case lookupFM fm k of +> Just foo -> foo +> Nothing -> error $ "No such key: " ++ show k + +> idxFM fm = foldl idxFM' fm (zip [1..sizeFM fm] $ keysFM fm) + |