1{-# OPTIONS_GHC -w #-} 2{-# OPTIONS -XMagicHash -XBangPatterns -XTypeSynonymInstances -XFlexibleInstances -cpp #-} 3#if __GLASGOW_HASKELL__ >= 710 4{-# OPTIONS_GHC -XPartialTypeSignatures #-} 5#endif 6module HpcParser where 7 8import HpcLexer 9import qualified Data.Array as Happy_Data_Array 10import qualified Data.Bits as Bits 11import qualified GHC.Exts as Happy_GHC_Exts 12import Control.Applicative(Applicative(..)) 13import Control.Monad (ap) 14 15-- parser produced by Happy Version 1.19.12 16 17newtype HappyAbsSyn = HappyAbsSyn HappyAny 18#if __GLASGOW_HASKELL__ >= 607 19type HappyAny = Happy_GHC_Exts.Any 20#else 21type HappyAny = forall a . a 22#endif 23newtype HappyWrap4 = HappyWrap4 (Spec) 24happyIn4 :: (Spec) -> (HappyAbsSyn ) 25happyIn4 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap4 x) 26{-# INLINE happyIn4 #-} 27happyOut4 :: (HappyAbsSyn ) -> HappyWrap4 28happyOut4 x = Happy_GHC_Exts.unsafeCoerce# x 29{-# INLINE happyOut4 #-} 30newtype HappyWrap5 = HappyWrap5 (L (ModuleName,[Tick])) 31happyIn5 :: (L (ModuleName,[Tick])) -> (HappyAbsSyn ) 32happyIn5 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap5 x) 33{-# INLINE happyIn5 #-} 34happyOut5 :: (HappyAbsSyn ) -> HappyWrap5 35happyOut5 x = Happy_GHC_Exts.unsafeCoerce# x 36{-# INLINE happyOut5 #-} 37newtype HappyWrap6 = HappyWrap6 ((ModuleName,[Tick])) 38happyIn6 :: ((ModuleName,[Tick])) -> (HappyAbsSyn ) 39happyIn6 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap6 x) 40{-# INLINE happyIn6 #-} 41happyOut6 :: (HappyAbsSyn ) -> HappyWrap6 42happyOut6 x = Happy_GHC_Exts.unsafeCoerce# x 43{-# INLINE happyOut6 #-} 44newtype HappyWrap7 = HappyWrap7 (L Tick) 45happyIn7 :: (L Tick) -> (HappyAbsSyn ) 46happyIn7 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap7 x) 47{-# INLINE happyIn7 #-} 48happyOut7 :: (HappyAbsSyn ) -> HappyWrap7 49happyOut7 x = Happy_GHC_Exts.unsafeCoerce# x 50{-# INLINE happyOut7 #-} 51newtype HappyWrap8 = HappyWrap8 (Tick) 52happyIn8 :: (Tick) -> (HappyAbsSyn ) 53happyIn8 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap8 x) 54{-# INLINE happyIn8 #-} 55happyOut8 :: (HappyAbsSyn ) -> HappyWrap8 56happyOut8 x = Happy_GHC_Exts.unsafeCoerce# x 57{-# INLINE happyOut8 #-} 58newtype HappyWrap9 = HappyWrap9 (L ExprTick) 59happyIn9 :: (L ExprTick) -> (HappyAbsSyn ) 60happyIn9 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap9 x) 61{-# INLINE happyIn9 #-} 62happyOut9 :: (HappyAbsSyn ) -> HappyWrap9 63happyOut9 x = Happy_GHC_Exts.unsafeCoerce# x 64{-# INLINE happyOut9 #-} 65newtype HappyWrap10 = HappyWrap10 (ExprTick) 66happyIn10 :: (ExprTick) -> (HappyAbsSyn ) 67happyIn10 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap10 x) 68{-# INLINE happyIn10 #-} 69happyOut10 :: (HappyAbsSyn ) -> HappyWrap10 70happyOut10 x = Happy_GHC_Exts.unsafeCoerce# x 71{-# INLINE happyOut10 #-} 72newtype HappyWrap11 = HappyWrap11 (Maybe String) 73happyIn11 :: (Maybe String) -> (HappyAbsSyn ) 74happyIn11 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap11 x) 75{-# INLINE happyIn11 #-} 76happyOut11 :: (HappyAbsSyn ) -> HappyWrap11 77happyOut11 x = Happy_GHC_Exts.unsafeCoerce# x 78{-# INLINE happyOut11 #-} 79newtype HappyWrap12 = HappyWrap12 (Maybe Qualifier) 80happyIn12 :: (Maybe Qualifier) -> (HappyAbsSyn ) 81happyIn12 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap12 x) 82{-# INLINE happyIn12 #-} 83happyOut12 :: (HappyAbsSyn ) -> HappyWrap12 84happyOut12 x = Happy_GHC_Exts.unsafeCoerce# x 85{-# INLINE happyOut12 #-} 86newtype HappyWrap13 = HappyWrap13 (Maybe String) 87happyIn13 :: (Maybe String) -> (HappyAbsSyn ) 88happyIn13 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap13 x) 89{-# INLINE happyIn13 #-} 90happyOut13 :: (HappyAbsSyn ) -> HappyWrap13 91happyOut13 x = Happy_GHC_Exts.unsafeCoerce# x 92{-# INLINE happyOut13 #-} 93happyInTok :: (Token) -> (HappyAbsSyn ) 94happyInTok x = Happy_GHC_Exts.unsafeCoerce# x 95{-# INLINE happyInTok #-} 96happyOutTok :: (HappyAbsSyn ) -> (Token) 97happyOutTok x = Happy_GHC_Exts.unsafeCoerce# x 98{-# INLINE happyOutTok #-} 99 100 101happyExpList :: HappyAddr 102happyExpList = HappyA# "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x42\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x40\x00\x00\x00\x00\x02\x00\x10\x00\x00\x00\x10\x00\x00\x00\x00\x10\x00\x00\x00\x08\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x41\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x20\x00\x00\x80\x00\x00\x00\x00\x04\x00\x40\x08\x00\x00\x00\x00\x00\x00\x04\x41\x00\x00\x00\x00\x01\x00\x00\x01\x00\x00\x00\x10\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# 103 104{-# NOINLINE happyExpListPerState #-} 105happyExpListPerState st = 106 token_strs_expected 107 where token_strs = ["error","%dummy","%start_parser","Spec","Modules","Module","TopTicks","TopTick","Ticks","Tick","optString","optQual","optCat","MODULE","TICK","EXPRESSION","ON","LINE","POSITION","FUNCTION","INSIDE","AT","':'","'-'","';'","'{'","'}'","int","string","cat","%eof"] 108 bit_start = st * 31 109 bit_end = (st + 1) * 31 110 read_bit = readArrayBit happyExpList 111 bits = map read_bit [bit_start..bit_end - 1] 112 bits_indexed = zip bits [0..30] 113 token_strs_expected = concatMap f bits_indexed 114 f (False, _) = [] 115 f (True, nr) = [token_strs !! nr] 116 117happyActOffsets :: HappyAddr 118happyActOffsets = HappyA# "\x00\x00\x00\x00\x0e\x00\xf2\xff\x11\x00\x00\x00\x04\x00\x08\x00\x00\x00\x00\x00\x06\x00\x0a\x00\x07\x00\x10\x00\x13\x00\x0b\x00\x0c\x00\x12\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x15\x00\x14\x00\x00\x00\x00\x00\xfb\xff\x16\x00\x00\x00\x0f\x00\x17\x00\x19\x00\x1a\x00\x08\x00\x00\x00\x01\x00\x1b\x00\x18\x00\x1c\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00"# 119 120happyGotoOffsets :: HappyAddr 121happyGotoOffsets = HappyA# "\x05\x00\x20\x00\x0d\x00\x00\x00\x1f\x00\x00\x00\x21\x00\x25\x00\x00\x00\x00\x00\x00\x00\x00\x00\x26\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1d\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x27\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x28\x00\x2e\x00\x02\x00\x29\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# 122 123happyAdjustOffset :: Happy_GHC_Exts.Int# -> Happy_GHC_Exts.Int# 124happyAdjustOffset off = off 125 126happyDefActions :: HappyAddr 127happyDefActions = HappyA# "\xf4\xff\x00\x00\xfc\xff\x00\x00\xfe\xff\xf5\xff\xf1\xff\xee\xff\xf2\xff\xfd\xff\x00\x00\x00\x00\xec\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xed\xff\xf9\xff\x00\x00\xf3\xff\xf0\xff\x00\x00\x00\x00\xfa\xff\xf8\xff\xf1\xff\x00\x00\xfb\xff\x00\x00\x00\x00\x00\x00\x00\x00\xee\xff\xf9\xff\x00\x00\xec\xff\x00\x00\x00\x00\x00\x00\xf6\xff\xf7\xff\xef\xff"# 128 129happyCheck :: HappyAddr 130happyCheck = HappyA# "\xff\xff\x02\x00\x07\x00\x02\x00\x12\x00\x00\x00\x04\x00\x08\x00\x06\x00\x08\x00\x05\x00\x10\x00\x04\x00\x0e\x00\x01\x00\x0e\x00\x02\x00\x09\x00\x01\x00\x06\x00\x10\x00\x05\x00\x10\x00\x0d\x00\x11\x00\x06\x00\x0f\x00\x0f\x00\x0d\x00\xff\xff\x0c\x00\x0a\x00\x03\x00\x02\x00\x0a\x00\x0f\x00\x0b\x00\x05\x00\x10\x00\x10\x00\x07\x00\x0f\x00\x0c\x00\x0f\x00\x11\x00\x08\x00\x07\x00\x09\x00\x08\x00\x03\x00\x09\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"# 131 132happyTable :: HappyAddr 133happyTable = HappyA# "\x00\x00\x1c\x00\x20\x00\x1c\x00\xff\xff\x03\x00\x19\x00\x1d\x00\x1a\x00\x1d\x00\x02\x00\x09\x00\x0e\x00\x1e\x00\x04\x00\x2a\x00\x07\x00\x0f\x00\x0b\x00\x05\x00\x09\x00\x11\x00\x0c\x00\x14\x00\x13\x00\x10\x00\x18\x00\x17\x00\x24\x00\x00\x00\x16\x00\x19\x00\x14\x00\x09\x00\x28\x00\x21\x00\x22\x00\x02\x00\x1f\x00\x23\x00\x07\x00\x27\x00\x2b\x00\x2c\x00\x13\x00\x0c\x00\x07\x00\x11\x00\x25\x00\x24\x00\x28\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"# 134 135happyReduceArr = Happy_Data_Array.array (1, 19) [ 136 (1 , happyReduce_1), 137 (2 , happyReduce_2), 138 (3 , happyReduce_3), 139 (4 , happyReduce_4), 140 (5 , happyReduce_5), 141 (6 , happyReduce_6), 142 (7 , happyReduce_7), 143 (8 , happyReduce_8), 144 (9 , happyReduce_9), 145 (10 , happyReduce_10), 146 (11 , happyReduce_11), 147 (12 , happyReduce_12), 148 (13 , happyReduce_13), 149 (14 , happyReduce_14), 150 (15 , happyReduce_15), 151 (16 , happyReduce_16), 152 (17 , happyReduce_17), 153 (18 , happyReduce_18), 154 (19 , happyReduce_19) 155 ] 156 157happy_n_terms = 19 :: Int 158happy_n_nonterms = 10 :: Int 159 160happyReduce_1 = happySpecReduce_2 0# happyReduction_1 161happyReduction_1 happy_x_2 162 happy_x_1 163 = case happyOut9 happy_x_1 of { (HappyWrap9 happy_var_1) -> 164 case happyOut5 happy_x_2 of { (HappyWrap5 happy_var_2) -> 165 happyIn4 166 (Spec (happy_var_1 []) (happy_var_2 []) 167 )}} 168 169happyReduce_2 = happySpecReduce_2 1# happyReduction_2 170happyReduction_2 happy_x_2 171 happy_x_1 172 = case happyOut5 happy_x_1 of { (HappyWrap5 happy_var_1) -> 173 case happyOut6 happy_x_2 of { (HappyWrap6 happy_var_2) -> 174 happyIn5 175 (happy_var_1 . ((:) happy_var_2) 176 )}} 177 178happyReduce_3 = happySpecReduce_0 1# happyReduction_3 179happyReduction_3 = happyIn5 180 (id 181 ) 182 183happyReduce_4 = happyReduce 5# 2# happyReduction_4 184happyReduction_4 (happy_x_5 `HappyStk` 185 happy_x_4 `HappyStk` 186 happy_x_3 `HappyStk` 187 happy_x_2 `HappyStk` 188 happy_x_1 `HappyStk` 189 happyRest) 190 = case happyOutTok happy_x_2 of { (STR happy_var_2) -> 191 case happyOut7 happy_x_4 of { (HappyWrap7 happy_var_4) -> 192 happyIn6 193 ((happy_var_2,happy_var_4 []) 194 ) `HappyStk` happyRest}} 195 196happyReduce_5 = happySpecReduce_2 3# happyReduction_5 197happyReduction_5 happy_x_2 198 happy_x_1 199 = case happyOut7 happy_x_1 of { (HappyWrap7 happy_var_1) -> 200 case happyOut8 happy_x_2 of { (HappyWrap8 happy_var_2) -> 201 happyIn7 202 (happy_var_1 . ((:) happy_var_2) 203 )}} 204 205happyReduce_6 = happySpecReduce_0 3# happyReduction_6 206happyReduction_6 = happyIn7 207 (id 208 ) 209 210happyReduce_7 = happySpecReduce_1 4# happyReduction_7 211happyReduction_7 happy_x_1 212 = case happyOut10 happy_x_1 of { (HappyWrap10 happy_var_1) -> 213 happyIn8 214 (ExprTick happy_var_1 215 )} 216 217happyReduce_8 = happyReduce 6# 4# happyReduction_8 218happyReduction_8 (happy_x_6 `HappyStk` 219 happy_x_5 `HappyStk` 220 happy_x_4 `HappyStk` 221 happy_x_3 `HappyStk` 222 happy_x_2 `HappyStk` 223 happy_x_1 `HappyStk` 224 happyRest) 225 = case happyOutTok happy_x_3 of { (STR happy_var_3) -> 226 case happyOut12 happy_x_4 of { (HappyWrap12 happy_var_4) -> 227 case happyOut13 happy_x_5 of { (HappyWrap13 happy_var_5) -> 228 happyIn8 229 (TickFunction happy_var_3 happy_var_4 happy_var_5 230 ) `HappyStk` happyRest}}} 231 232happyReduce_9 = happyReduce 5# 4# happyReduction_9 233happyReduction_9 (happy_x_5 `HappyStk` 234 happy_x_4 `HappyStk` 235 happy_x_3 `HappyStk` 236 happy_x_2 `HappyStk` 237 happy_x_1 `HappyStk` 238 happyRest) 239 = case happyOutTok happy_x_2 of { (STR happy_var_2) -> 240 case happyOut7 happy_x_4 of { (HappyWrap7 happy_var_4) -> 241 happyIn8 242 (InsideFunction happy_var_2 (happy_var_4 []) 243 ) `HappyStk` happyRest}} 244 245happyReduce_10 = happySpecReduce_2 5# happyReduction_10 246happyReduction_10 happy_x_2 247 happy_x_1 248 = case happyOut9 happy_x_1 of { (HappyWrap9 happy_var_1) -> 249 case happyOut10 happy_x_2 of { (HappyWrap10 happy_var_2) -> 250 happyIn9 251 (happy_var_1 . ((:) happy_var_2) 252 )}} 253 254happyReduce_11 = happySpecReduce_0 5# happyReduction_11 255happyReduction_11 = happyIn9 256 (id 257 ) 258 259happyReduce_12 = happyReduce 5# 6# happyReduction_12 260happyReduction_12 (happy_x_5 `HappyStk` 261 happy_x_4 `HappyStk` 262 happy_x_3 `HappyStk` 263 happy_x_2 `HappyStk` 264 happy_x_1 `HappyStk` 265 happyRest) 266 = case happyOut11 happy_x_2 of { (HappyWrap11 happy_var_2) -> 267 case happyOut12 happy_x_3 of { (HappyWrap12 happy_var_3) -> 268 case happyOut13 happy_x_4 of { (HappyWrap13 happy_var_4) -> 269 happyIn10 270 (TickExpression False happy_var_2 happy_var_3 happy_var_4 271 ) `HappyStk` happyRest}}} 272 273happyReduce_13 = happySpecReduce_1 7# happyReduction_13 274happyReduction_13 happy_x_1 275 = case happyOutTok happy_x_1 of { (STR happy_var_1) -> 276 happyIn11 277 (Just happy_var_1 278 )} 279 280happyReduce_14 = happySpecReduce_0 7# happyReduction_14 281happyReduction_14 = happyIn11 282 (Nothing 283 ) 284 285happyReduce_15 = happySpecReduce_3 8# happyReduction_15 286happyReduction_15 happy_x_3 287 happy_x_2 288 happy_x_1 289 = case happyOutTok happy_x_3 of { (INT happy_var_3) -> 290 happyIn12 291 (Just (OnLine happy_var_3) 292 )} 293 294happyReduce_16 = happyReduce 9# 8# happyReduction_16 295happyReduction_16 (happy_x_9 `HappyStk` 296 happy_x_8 `HappyStk` 297 happy_x_7 `HappyStk` 298 happy_x_6 `HappyStk` 299 happy_x_5 `HappyStk` 300 happy_x_4 `HappyStk` 301 happy_x_3 `HappyStk` 302 happy_x_2 `HappyStk` 303 happy_x_1 `HappyStk` 304 happyRest) 305 = case happyOutTok happy_x_3 of { (INT happy_var_3) -> 306 case happyOutTok happy_x_5 of { (INT happy_var_5) -> 307 case happyOutTok happy_x_7 of { (INT happy_var_7) -> 308 case happyOutTok happy_x_9 of { (INT happy_var_9) -> 309 happyIn12 310 (Just (AtPosition happy_var_3 happy_var_5 happy_var_7 happy_var_9) 311 ) `HappyStk` happyRest}}}} 312 313happyReduce_17 = happySpecReduce_0 8# happyReduction_17 314happyReduction_17 = happyIn12 315 (Nothing 316 ) 317 318happyReduce_18 = happySpecReduce_1 9# happyReduction_18 319happyReduction_18 happy_x_1 320 = case happyOutTok happy_x_1 of { (CAT happy_var_1) -> 321 happyIn13 322 (Just happy_var_1 323 )} 324 325happyReduce_19 = happySpecReduce_0 9# happyReduction_19 326happyReduction_19 = happyIn13 327 (Nothing 328 ) 329 330happyNewToken action sts stk [] = 331 happyDoAction 18# notHappyAtAll action sts stk [] 332 333happyNewToken action sts stk (tk:tks) = 334 let cont i = happyDoAction i tk action sts stk tks in 335 case tk of { 336 ID "module" -> cont 1#; 337 ID "tick" -> cont 2#; 338 ID "expression" -> cont 3#; 339 ID "on" -> cont 4#; 340 ID "line" -> cont 5#; 341 ID "position" -> cont 6#; 342 ID "function" -> cont 7#; 343 ID "inside" -> cont 8#; 344 ID "at" -> cont 9#; 345 SYM ':' -> cont 10#; 346 SYM '-' -> cont 11#; 347 SYM ';' -> cont 12#; 348 SYM '{' -> cont 13#; 349 SYM '}' -> cont 14#; 350 INT happy_dollar_dollar -> cont 15#; 351 STR happy_dollar_dollar -> cont 16#; 352 CAT happy_dollar_dollar -> cont 17#; 353 _ -> happyError' ((tk:tks), []) 354 } 355 356happyError_ explist 18# tk tks = happyError' (tks, explist) 357happyError_ explist _ tk tks = happyError' ((tk:tks), explist) 358 359newtype HappyIdentity a = HappyIdentity a 360happyIdentity = HappyIdentity 361happyRunIdentity (HappyIdentity a) = a 362 363instance Functor HappyIdentity where 364 fmap f (HappyIdentity a) = HappyIdentity (f a) 365 366instance Applicative HappyIdentity where 367 pure = HappyIdentity 368 (<*>) = ap 369instance Monad HappyIdentity where 370 return = pure 371 (HappyIdentity p) >>= q = q p 372 373happyThen :: () => HappyIdentity a -> (a -> HappyIdentity b) -> HappyIdentity b 374happyThen = (>>=) 375happyReturn :: () => a -> HappyIdentity a 376happyReturn = (return) 377happyThen1 m k tks = (>>=) m (\a -> k a tks) 378happyReturn1 :: () => a -> b -> HappyIdentity a 379happyReturn1 = \a tks -> (return) a 380happyError' :: () => ([(Token)], [String]) -> HappyIdentity a 381happyError' = HappyIdentity . (\(tokens, _) -> happyError tokens) 382parser tks = happyRunIdentity happySomeParser where 383 happySomeParser = happyThen (happyParse 0# tks) (\x -> happyReturn (let {(HappyWrap4 x') = happyOut4 x} in x')) 384 385happySeq = happyDoSeq 386 387 388type L a = [a] -> [a] 389 390type ModuleName = String 391 392data Spec 393 = Spec [ExprTick] [(ModuleName,[Tick])] 394 deriving (Show) 395 396data ExprTick 397 = TickExpression Bool (Maybe String) (Maybe Qualifier) (Maybe String) 398 deriving (Show) 399 400data Tick 401 = ExprTick ExprTick 402 | TickFunction String (Maybe Qualifier) (Maybe String) 403 | InsideFunction String [Tick] 404 deriving (Show) 405 406data Qualifier = OnLine Int 407 | AtPosition Int Int Int Int 408 deriving (Show) 409 410 411 412hpcParser :: String -> IO Spec 413hpcParser filename = do 414 txt <- readFile filename 415 let tokens = initLexer txt 416 return $ parser tokens 417 418happyError e = error $ show (take 10 e) 419{-# LINE 1 "templates/GenericTemplate.hs" #-} 420-- $Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp $ 421 422 423 424 425 426 427 428 429 430 431 432 433 434-- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex. 435#if __GLASGOW_HASKELL__ > 706 436#define LT(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.<# m)) :: Bool) 437#define GTE(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.>=# m)) :: Bool) 438#define EQ(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.==# m)) :: Bool) 439#else 440#define LT(n,m) (n Happy_GHC_Exts.<# m) 441#define GTE(n,m) (n Happy_GHC_Exts.>=# m) 442#define EQ(n,m) (n Happy_GHC_Exts.==# m) 443#endif 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504infixr 9 `HappyStk` 505data HappyStk a = HappyStk a (HappyStk a) 506 507----------------------------------------------------------------------------- 508-- starting the parse 509 510happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll 511 512----------------------------------------------------------------------------- 513-- Accepting the parse 514 515-- If the current token is ERROR_TOK, it means we've just accepted a partial 516-- parse (a %partial parser). We must ignore the saved token on the top of 517-- the stack in this case. 518happyAccept 0# tk st sts (_ `HappyStk` ans `HappyStk` _) = 519 happyReturn1 ans 520happyAccept j tk st sts (HappyStk ans _) = 521 (happyTcHack j (happyTcHack st)) (happyReturn1 ans) 522 523----------------------------------------------------------------------------- 524-- Arrays only: do the next action 525 526 527 528happyDoAction i tk st 529 = {- nothing -} 530 case action of 531 0# -> {- nothing -} 532 happyFail (happyExpListPerState ((Happy_GHC_Exts.I# (st)) :: Int)) i tk st 533 -1# -> {- nothing -} 534 happyAccept i tk st 535 n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -} 536 (happyReduceArr Happy_Data_Array.! rule) i tk st 537 where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#)))))) 538 n -> {- nothing -} 539 happyShift new_state i tk st 540 where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) 541 where off = happyAdjustOffset (indexShortOffAddr happyActOffsets st) 542 off_i = (off Happy_GHC_Exts.+# i) 543 check = if GTE(off_i,(0# :: Happy_GHC_Exts.Int#)) 544 then EQ(indexShortOffAddr happyCheck off_i, i) 545 else False 546 action 547 | check = indexShortOffAddr happyTable off_i 548 | otherwise = indexShortOffAddr happyDefActions st 549 550 551 552 553indexShortOffAddr (HappyA# arr) off = 554 Happy_GHC_Exts.narrow16Int# i 555 where 556 i = Happy_GHC_Exts.word2Int# (Happy_GHC_Exts.or# (Happy_GHC_Exts.uncheckedShiftL# high 8#) low) 557 high = Happy_GHC_Exts.int2Word# (Happy_GHC_Exts.ord# (Happy_GHC_Exts.indexCharOffAddr# arr (off' Happy_GHC_Exts.+# 1#))) 558 low = Happy_GHC_Exts.int2Word# (Happy_GHC_Exts.ord# (Happy_GHC_Exts.indexCharOffAddr# arr off')) 559 off' = off Happy_GHC_Exts.*# 2# 560 561 562 563 564{-# INLINE happyLt #-} 565happyLt x y = LT(x,y) 566 567 568readArrayBit arr bit = 569 Bits.testBit (Happy_GHC_Exts.I# (indexShortOffAddr arr ((unbox_int bit) `Happy_GHC_Exts.iShiftRA#` 4#))) (bit `mod` 16) 570 where unbox_int (Happy_GHC_Exts.I# x) = x 571 572 573 574 575 576 577data HappyAddr = HappyA# Happy_GHC_Exts.Addr# 578 579 580----------------------------------------------------------------------------- 581-- HappyState data type (not arrays) 582 583 584 585 586 587 588 589 590 591 592 593 594 595----------------------------------------------------------------------------- 596-- Shifting a token 597 598happyShift new_state 0# tk st sts stk@(x `HappyStk` _) = 599 let i = (case Happy_GHC_Exts.unsafeCoerce# x of { (Happy_GHC_Exts.I# (i)) -> i }) in 600-- trace "shifting the error token" $ 601 happyDoAction i tk new_state (HappyCons (st) (sts)) (stk) 602 603happyShift new_state i tk st sts stk = 604 happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk) 605 606-- happyReduce is specialised for the common cases. 607 608happySpecReduce_0 i fn 0# tk st sts stk 609 = happyFail [] 0# tk st sts stk 610happySpecReduce_0 nt fn j tk st@((action)) sts stk 611 = happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk) 612 613happySpecReduce_1 i fn 0# tk st sts stk 614 = happyFail [] 0# tk st sts stk 615happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk') 616 = let r = fn v1 in 617 happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) 618 619happySpecReduce_2 i fn 0# tk st sts stk 620 = happyFail [] 0# tk st sts stk 621happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk') 622 = let r = fn v1 v2 in 623 happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) 624 625happySpecReduce_3 i fn 0# tk st sts stk 626 = happyFail [] 0# tk st sts stk 627happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') 628 = let r = fn v1 v2 v3 in 629 happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk')) 630 631happyReduce k i fn 0# tk st sts stk 632 = happyFail [] 0# tk st sts stk 633happyReduce k nt fn j tk st sts stk 634 = case happyDrop (k Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) sts of 635 sts1@((HappyCons (st1@(action)) (_))) -> 636 let r = fn stk in -- it doesn't hurt to always seq here... 637 happyDoSeq r (happyGoto nt j tk st1 sts1 r) 638 639happyMonadReduce k nt fn 0# tk st sts stk 640 = happyFail [] 0# tk st sts stk 641happyMonadReduce k nt fn j tk st sts stk = 642 case happyDrop k (HappyCons (st) (sts)) of 643 sts1@((HappyCons (st1@(action)) (_))) -> 644 let drop_stk = happyDropStk k stk in 645 happyThen1 (fn stk tk) (\r -> happyGoto nt j tk st1 sts1 (r `HappyStk` drop_stk)) 646 647happyMonad2Reduce k nt fn 0# tk st sts stk 648 = happyFail [] 0# tk st sts stk 649happyMonad2Reduce k nt fn j tk st sts stk = 650 case happyDrop k (HappyCons (st) (sts)) of 651 sts1@((HappyCons (st1@(action)) (_))) -> 652 let drop_stk = happyDropStk k stk 653 654 off = happyAdjustOffset (indexShortOffAddr happyGotoOffsets st1) 655 off_i = (off Happy_GHC_Exts.+# nt) 656 new_state = indexShortOffAddr happyTable off_i 657 658 659 660 661 in 662 happyThen1 (fn stk tk) (\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk)) 663 664happyDrop 0# l = l 665happyDrop n (HappyCons (_) (t)) = happyDrop (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) t 666 667happyDropStk 0# l = l 668happyDropStk n (x `HappyStk` xs) = happyDropStk (n Happy_GHC_Exts.-# (1#::Happy_GHC_Exts.Int#)) xs 669 670----------------------------------------------------------------------------- 671-- Moving to a new state after a reduction 672 673 674happyGoto nt j tk st = 675 {- nothing -} 676 happyDoAction j tk new_state 677 where off = happyAdjustOffset (indexShortOffAddr happyGotoOffsets st) 678 off_i = (off Happy_GHC_Exts.+# nt) 679 new_state = indexShortOffAddr happyTable off_i 680 681 682 683 684----------------------------------------------------------------------------- 685-- Error recovery (ERROR_TOK is the error token) 686 687-- parse error if we are in recovery and we fail again 688happyFail explist 0# tk old_st _ stk@(x `HappyStk` _) = 689 let i = (case Happy_GHC_Exts.unsafeCoerce# x of { (Happy_GHC_Exts.I# (i)) -> i }) in 690-- trace "failing" $ 691 happyError_ explist i tk 692 693{- We don't need state discarding for our restricted implementation of 694 "error". In fact, it can cause some bogus parses, so I've disabled it 695 for now --SDM 696 697-- discard a state 698happyFail ERROR_TOK tk old_st CONS(HAPPYSTATE(action),sts) 699 (saved_tok `HappyStk` _ `HappyStk` stk) = 700-- trace ("discarding state, depth " ++ show (length stk)) $ 701 DO_ACTION(action,ERROR_TOK,tk,sts,(saved_tok`HappyStk`stk)) 702-} 703 704-- Enter error recovery: generate an error token, 705-- save the old token and carry on. 706happyFail explist i tk (action) sts stk = 707-- trace "entering error recovery" $ 708 happyDoAction 0# tk action sts ((Happy_GHC_Exts.unsafeCoerce# (Happy_GHC_Exts.I# (i))) `HappyStk` stk) 709 710-- Internal happy errors: 711 712notHappyAtAll :: a 713notHappyAtAll = error "Internal Happy error\n" 714 715----------------------------------------------------------------------------- 716-- Hack to get the typechecker to accept our action functions 717 718 719happyTcHack :: Happy_GHC_Exts.Int# -> a -> a 720happyTcHack x y = y 721{-# INLINE happyTcHack #-} 722 723 724----------------------------------------------------------------------------- 725-- Seq-ing. If the --strict flag is given, then Happy emits 726-- happySeq = happyDoSeq 727-- otherwise it emits 728-- happySeq = happyDontSeq 729 730happyDoSeq, happyDontSeq :: a -> b -> b 731happyDoSeq a b = a `seq` b 732happyDontSeq a b = b 733 734----------------------------------------------------------------------------- 735-- Don't inline any functions from the template. GHC has a nasty habit 736-- of deciding to inline happyGoto everywhere, which increases the size of 737-- the generated parser quite a bit. 738 739 740{-# NOINLINE happyDoAction #-} 741{-# NOINLINE happyTable #-} 742{-# NOINLINE happyCheck #-} 743{-# NOINLINE happyActOffsets #-} 744{-# NOINLINE happyGotoOffsets #-} 745{-# NOINLINE happyDefActions #-} 746 747{-# NOINLINE happyShift #-} 748{-# NOINLINE happySpecReduce_0 #-} 749{-# NOINLINE happySpecReduce_1 #-} 750{-# NOINLINE happySpecReduce_2 #-} 751{-# NOINLINE happySpecReduce_3 #-} 752{-# NOINLINE happyReduce #-} 753{-# NOINLINE happyMonadReduce #-} 754{-# NOINLINE happyGoto #-} 755{-# NOINLINE happyFail #-} 756 757-- end of Happy Template. 758