her-lexer 0.1 → 0.1.1
raw patch · 5 files changed
+30/−6 lines, 5 filessetup-changed
Files
- Setup.hs +0/−2
- Setup.lhs +4/−0
- her-lexer.cabal +1/−1
- src/Language/Haskell/Her/FromClutterToLines.lhs +2/−1
- src/Language/Haskell/Her/HaLay.lhs +23/−2
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
+ Setup.lhs view
@@ -0,0 +1,4 @@+#! /usr/bin/env runhaskell++> import Distribution.Simple+> main = defaultMain
her-lexer.cabal view
@@ -1,5 +1,5 @@ name: her-lexer-version: 0.1+version: 0.1.1 homepage: http://personal.cis.strath.ac.uk/~conor/pub/she synopsis: A lexer for Haskell source code. description:
src/Language/Haskell/Her/FromClutterToLines.lhs view
@@ -1,8 +1,9 @@ >module Language.Haskell.Her.FromClutterToLines where+ >import Language.Haskell.Her.HaLay >import Data.List.Split -| When we get the tokss from her-parser's ready, they're a bit cluttered. I'm not sure what Dr. McBride had in mind when he made that mess. But this doesn't mater, from this clutter we can create a list of lines which is aware of haskell's brackets. If a multi-line clause is inside brackets, then we keep the whole section in the same "line".+> -- | When we get the tokss from her-parser's ready, they're a bit cluttered. I'm not sure what Dr. McBride had in mind when he made that mess. But this doesn't mater, from this clutter we can create a list of lines which is aware of haskell's brackets. If a multi-line clause is inside brackets, then we keep the whole section in the same "line". >fromClutterToLines :: [[Tok]] -> [[Tok]] >fromClutterToLines tokss =
src/Language/Haskell/Her/HaLay.lhs view
@@ -144,9 +144,30 @@ > (Bra b, Clo b') | b == b' -> (reverse acss, its') > (m, Ope b) -> case getChunks (Bra b) [] its' of > (cs, its) -> getChunks m (B b cs : acss) its-> (m, KW e) | elem e lakeys -> case getLines (Seek m e) [] its' of-> (css, its) -> getChunks m ((L e css) : acss) its+> (m, KW e) | elem e lakeys ->+> -- First, we test if our new block starts with some { curlies.+> case searchCurlies [] its' of+> -- If so, we read these in as brackets. ++ Just (css,its) -> case getLines (Seek (Bra Crl) e) [] its of+ (css',its'') -> getChunks m ((L e (css:css')) : acss) its''++> Just (css,its) -> case getChunks (Bra Crl) [] its of+> (css',its'') -> getChunks m ((L e ((css++((B Crl css'):[])):[])) : acss) its''++> -- Otherwise, we read normally.+> Nothing -> case getLines (Seek m e) [] its' of+> (css, its) -> getChunks m ((L e css) : acss) its > _ -> getChunks m (t : acss) its'++> searchCurlies :: [Tok] -> [(Int,Tok)] -> Maybe ([Tok],[(Int,Tok)])+> searchCurlies toks ((_,upTok):unprocessedToks) =+> case upTok of+> (Spc _) -> searchCurlies (upTok:toks) unprocessedToks+> (NL _) -> searchCurlies (upTok:toks) unprocessedToks+> (Com _) -> searchCurlies (upTok:toks) unprocessedToks+> (Ope Crl) -> Just (toks,unprocessedToks)+> _ -> Nothing getChunks :: ChunkMode -> [Tok] -> [(Int, Tok)] -> ([Tok], [(Int, Tok)]) getChunks _ acc [] = (reverse acc, [])