3 -- The above warning supression flag is a temporary kludge.
4 -- While working on this module you are encouraged to remove it and fix
5 -- any warnings in the module. See
6 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
18 MODULE { ID "module" }
20 EXPRESSION { ID "expression" }
23 POSITION { ID "position" }
24 FUNCTION { ID "function" }
25 INSIDE { ID "inside" }
38 Spec : Ticks Modules { Spec ($1 []) ($2 []) }
40 Modules :: { L (ModuleName,[Tick]) }
41 Modules : Modules Module { $1 . ((:) $2) }
44 Module :: { (ModuleName,[Tick]) }
45 Module : MODULE string '{' TopTicks '}'
48 TopTicks :: { L Tick }
49 TopTicks : TopTicks TopTick { $1 . ((:) $2) }
53 TopTick : Tick { ExprTick $1 }
54 | TICK FUNCTION string optQual optCat ';'
55 { TickFunction $3 $4 $5 }
56 | INSIDE string '{' TopTicks '}'
57 { InsideFunction $2 ($4 []) }
59 Ticks :: { L ExprTick }
60 Ticks : Ticks Tick { $1 . ((:) $2) }
64 Tick : TICK optString optQual optCat ';'
65 { TickExpression False $2 $3 $4 }
67 optString :: { Maybe String }
68 optString : string { Just $1 }
71 optQual :: { Maybe Qualifier }
72 optQual : ON LINE int { Just (OnLine $3) }
73 | AT POSITION int ':' int '-' int ':' int
74 { Just (AtPosition $3 $5 $7 $9) }
76 optCat :: { Maybe String }
77 optCat : cat { Just $1 }
83 type ModuleName = String
86 = Spec [ExprTick] [(ModuleName,[Tick])]
90 = TickExpression Bool (Maybe String) (Maybe Qualifier) (Maybe String)
95 | TickFunction String (Maybe Qualifier) (Maybe String)
96 | InsideFunction String [Tick]
99 data Qualifier = OnLine Int
100 | AtPosition Int Int Int Int
105 hpcParser :: String -> IO Spec
106 hpcParser filename = do
107 txt <- readFile filename
108 let tokens = initLexer txt
109 return $ parser tokens
111 happyError e = error $ show (take 10 e)