9 %error { \ e -> error $ show (take 10 e) }
12 MODULE { ID "module" }
14 EXPRESSION { ID "expression" }
17 POSITION { ID "position" }
18 FUNCTION { ID "function" }
19 INSIDE { ID "inside" }
32 Spec : Ticks Modules { Spec ($1 []) ($2 []) }
34 Modules :: { L (ModuleName,[Tick]) }
35 Modules : Modules Module { $1 . ((:) $2) }
38 Module :: { (ModuleName,[Tick]) }
39 Module : MODULE string '{' TopTicks '}'
42 TopTicks :: { L Tick }
43 TopTicks : TopTicks TopTick { $1 . ((:) $2) }
47 TopTick : Tick { ExprTick $1 }
48 | TICK FUNCTION string optQual optCat ';'
49 { TickFunction $3 $4 $5 }
50 | INSIDE string '{' TopTicks '}'
51 { InsideFunction $2 ($4 []) }
53 Ticks :: { L ExprTick }
54 Ticks : Ticks Tick { $1 . ((:) $2) }
58 Tick : TICK optString optQual optCat ';'
59 { TickExpression False $2 $3 $4 }
61 optString :: { Maybe String }
62 optString : string { Just $1 }
65 optQual :: { Maybe Qualifier }
66 optQual : ON LINE int { Just (OnLine $3) }
67 | AT POSITION int ':' int '-' int ':' int
68 { Just (AtPosition $3 $5 $7 $9) }
70 optCat :: { Maybe String }
71 optCat : cat { Just $1 }
77 type ModuleName = String
80 = Spec [ExprTick] [(ModuleName,[Tick])]
84 = TickExpression Bool (Maybe String) (Maybe Qualifier) (Maybe String)
89 | TickFunction String (Maybe Qualifier) (Maybe String)
90 | InsideFunction String [Tick]
93 data Qualifier = OnLine Int
94 | AtPosition Int Int Int Int
99 hpcParser :: String -> IO Spec
100 hpcParser filename = do
101 txt <- readFile filename
102 let tokens = initLexer txt
103 return $ parser tokens