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
19 MODULE { ID "module" }
21 EXPRESSION { ID "expression" }
24 POSITION { ID "position" }
25 FUNCTION { ID "function" }
26 INSIDE { ID "inside" }
39 Spec : Ticks Modules { Spec ($1 []) ($2 []) }
41 Modules :: { L (ModuleName,[Tick]) }
42 Modules : Modules Module { $1 . ((:) $2) }
45 Module :: { (ModuleName,[Tick]) }
46 Module : MODULE string '{' TopTicks '}'
49 TopTicks :: { L Tick }
50 TopTicks : TopTicks TopTick { $1 . ((:) $2) }
54 TopTick : Tick { ExprTick $1 }
55 | TICK FUNCTION string optQual optCat ';'
56 { TickFunction $3 $4 $5 }
57 | INSIDE string '{' TopTicks '}'
58 { InsideFunction $2 ($4 []) }
60 Ticks :: { L ExprTick }
61 Ticks : Ticks Tick { $1 . ((:) $2) }
65 Tick : TICK optString optQual optCat ';'
66 { TickExpression False $2 $3 $4 }
68 optString :: { Maybe String }
69 optString : string { Just $1 }
72 optQual :: { Maybe Qualifier }
73 optQual : ON LINE int { Just (OnLine $3) }
74 | AT POSITION int ':' int '-' int ':' int
75 { Just (AtPosition $3 $5 $7 $9) }
77 optCat :: { Maybe String }
78 optCat : cat { Just $1 }
84 type ModuleName = String
87 = Spec [ExprTick] [(ModuleName,[Tick])]
91 = TickExpression Bool (Maybe String) (Maybe Qualifier) (Maybe String)
96 | TickFunction String (Maybe Qualifier) (Maybe String)
97 | InsideFunction String [Tick]
100 data Qualifier = OnLine Int
101 | AtPosition Int Int Int Int
106 hpcParser :: String -> IO Spec
107 hpcParser filename = do
108 txt <- readFile filename
109 let tokens = initLexer txt
110 return $ parser tokens
112 happyError e = error $ show (take 10 e)