summaryrefslogtreecommitdiff
path: root/utils/hpc/HpcLexer.hs
diff options
context:
space:
mode:
authorandy@galois.com <unknown>2007-09-08 05:16:00 +0000
committerandy@galois.com <unknown>2007-09-08 05:16:00 +0000
commitc8742f253f0c0b38f977530eceaaecac55578b4b (patch)
tree2e724db5ca6d1b359512e00bfb415848661b9f15 /utils/hpc/HpcLexer.hs
parent5f4e77a5a2ea03286b795da4051272ac7c774bd7 (diff)
downloadhaskell-c8742f253f0c0b38f977530eceaaecac55578b4b.tar.gz
updating hpc toolkit
The hpc overlay has been ported from hpc-0.4 The new API for readMix is now used.
Diffstat (limited to 'utils/hpc/HpcLexer.hs')
-rw-r--r--utils/hpc/HpcLexer.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/utils/hpc/HpcLexer.hs b/utils/hpc/HpcLexer.hs
index 74bec5dd4c..3d1a640b3c 100644
--- a/utils/hpc/HpcLexer.hs
+++ b/utils/hpc/HpcLexer.hs
@@ -7,6 +7,7 @@ data Token
| SYM Char
| INT Int
| STR String
+ | CAT String
deriving (Eq,Show)
initLexer :: String -> [Token]
@@ -16,6 +17,7 @@ lexer :: String -> Int -> Int -> [(Int,Int,Token)]
lexer (c:cs) line column
| c == '\n' = lexer cs (succ line) 0
| c == '\"' = lexerSTR cs line (succ column)
+ | c == '[' = lexerCAT cs "" line (succ column)
| c `elem` "{};-:"
= (line,column,SYM c) : lexer cs line (succ column)
| isSpace c = lexer cs line (succ column)
@@ -35,10 +37,15 @@ lexerINT other s line column = (line,column,INT (read s)) : lexer other line co
-- not technically correct for the new column count, but a good approximation.
lexerSTR cs line column
= case lex ('"' : cs) of
- [(str,rest)] -> (line,succ column,STR str)
+ [(str,rest)] -> (line,succ column,STR (read str))
: lexer rest line (length (show str) + column + 1)
_ -> error "bad string"
+lexerCAT (c:cs) s line column
+ | c == ']' = (line,column,CAT s) : lexer cs line (succ column)
+ | otherwise = lexerCAT cs (s ++ [c]) line (succ column)
+lexerCAT other s line column = error "lexer failure in CAT"
+
test = do
t <- readFile "EXAMPLE.tc"
print (initLexer t)