11 MODULE { ID "module" }
13 EXPRESSION { ID "expression" }
16 POSITION { ID "position" }
17 FUNCTION { ID "function" }
18 INSIDE { ID "inside" }
31 Spec : Ticks Modules { Spec ($1 []) ($2 []) }
33 Modules :: { L (ModuleName,[Tick]) }
34 Modules : Modules Module { $1 . ((:) $2) }
37 Module :: { (ModuleName,[Tick]) }
38 Module : MODULE string '{' TopTicks '}'
41 TopTicks :: { L Tick }
42 TopTicks : TopTicks TopTick { $1 . ((:) $2) }
46 TopTick : Tick { ExprTick $1 }
47 | TICK FUNCTION string optQual optCat ';'
48 { TickFunction $3 $4 $5 }
49 | INSIDE string '{' TopTicks '}'
50 { InsideFunction $2 ($4 []) }
52 Ticks :: { L ExprTick }
53 Ticks : Ticks Tick { $1 . ((:) $2) }
57 Tick : TICK optString optQual optCat ';'
58 { TickExpression False $2 $3 $4 }
60 optString :: { Maybe String }
61 optString : string { Just $1 }
64 optQual :: { Maybe Qualifier }
65 optQual : ON LINE int { Just (OnLine $3) }
66 | AT POSITION int ':' int '-' int ':' int
67 { Just (AtPosition $3 $5 $7 $9) }
69 optCat :: { Maybe String }
70 optCat : cat { Just $1 }
76 type ModuleName = String
79 = Spec [ExprTick] [(ModuleName,[Tick])]
83 = TickExpression Bool (Maybe String) (Maybe Qualifier) (Maybe String)
88 | TickFunction String (Maybe Qualifier) (Maybe String)
89 | InsideFunction String [Tick]
92 data Qualifier = OnLine Int
93 | AtPosition Int Int Int Int
98 hpcParser :: String -> IO Spec
99 hpcParser filename = do
100 txt <- readFile filename
101 let tokens = initLexer txt
102 return $ parser tokens
104 happyError e = error $ show (take 10 e)