1 {-# OPTIONS_GHC -fno-warn-overlapping-patterns #-} 2 {-# OPTIONS -fglasgow-exts -cpp #-} 3 module HappyParser (theHappyParser) where 4 import AbstractSyntax 5 import Lexer 6 #if __GLASGOW_HASKELL__ >= 503 7 import qualified GHC.Exts as Happy_GHC_Exts 8 #else 9 import qualified GlaExts as Happy_GHC_Exts 10 #endif 11 12 -- parser produced by Happy Version 1.18.4 13 14 data HappyAbsSyn 15 = HappyTerminal (Token') 16 | HappyErrorToken Int 17 | HappyAbsSyn4 ([Production]) 18 | HappyAbsSyn6 (Production) 19 | HappyAbsSyn11 (()) 20 21 {- to allow type-synonyms as our monads (likely 22 - with explicitly-specified bind and return) 23 - in Haskell98, it seems that with 24 - /type M a = .../, then /(HappyReduction M)/ 25 - is not allowed. But Happy is a 26 - code-generator that can just substitute it. 27 type HappyReduction m = 28 Happy_GHC_Exts.Int# 29 -> (Token') 30 -> HappyState (Token') (HappyStk HappyAbsSyn -> [(Token')] -> m HappyAbsSyn) 31 -> [HappyState (Token') (HappyStk HappyAbsSyn -> [(Token')] -> m HappyAbsSyn)] 32 -> HappyStk HappyAbsSyn 33 -> [(Token')] -> m HappyAbsSyn 34 -} 35 36 action_0, 37 action_1, 38 action_2, 39 action_3, 40 action_4, 41 action_5, 42 action_6, 43 action_7, 44 action_8, 45 action_9, 46 action_10, 47 action_11, 48 action_12, 49 action_13, 50 action_14, 51 action_15, 52 action_16, 53 action_17, 54 action_18, 55 action_19, 56 action_20, 57 action_21, 58 action_22, 59 action_23, 60 action_24, 61 action_25, 62 action_26, 63 action_27, 64 action_28, 65 action_29, 66 action_30, 67 action_31, 68 action_32, 69 action_33, 70 action_34, 71 action_35, 72 action_36, 73 action_37, 74 action_38, 75 action_39, 76 action_40, 77 action_41, 78 action_42, 79 action_43, 80 action_44, 81 action_45, 82 action_46, 83 action_47, 84 action_48, 85 action_49, 86 action_50, 87 action_51, 88 action_52, 89 action_53, 90 action_54, 91 action_55, 92 action_56, 93 action_57 :: () => Happy_GHC_Exts.Int# -> ({-HappyReduction (HappyIdentity) = -} 94 Happy_GHC_Exts.Int# 95 -> (Token') 96 -> HappyState (Token') (HappyStk HappyAbsSyn -> [(Token')] -> (HappyIdentity) HappyAbsSyn) 97 -> [HappyState (Token') (HappyStk HappyAbsSyn -> [(Token')] -> (HappyIdentity) HappyAbsSyn)] 98 -> HappyStk HappyAbsSyn 99 -> [(Token')] -> (HappyIdentity) HappyAbsSyn) 100 101 happyReduce_1, 102 happyReduce_2, 103 happyReduce_3, 104 happyReduce_4, 105 happyReduce_5, 106 happyReduce_6, 107 happyReduce_7, 108 happyReduce_8, 109 happyReduce_9, 110 happyReduce_10, 111 happyReduce_11, 112 happyReduce_12, 113 happyReduce_13, 114 happyReduce_14, 115 happyReduce_15, 116 happyReduce_16, 117 happyReduce_17, 118 happyReduce_18, 119 happyReduce_19, 120 happyReduce_20, 121 happyReduce_21, 122 happyReduce_22, 123 happyReduce_23, 124 happyReduce_24, 125 happyReduce_25, 126 happyReduce_26, 127 happyReduce_27, 128 happyReduce_28, 129 happyReduce_29, 130 happyReduce_30, 131 happyReduce_31, 132 happyReduce_32, 133 happyReduce_33, 134 happyReduce_34, 135 happyReduce_35, 136 happyReduce_36, 137 happyReduce_37 :: () => ({-HappyReduction (HappyIdentity) = -} 138 Happy_GHC_Exts.Int# 139 -> (Token') 140 -> HappyState (Token') (HappyStk HappyAbsSyn -> [(Token')] -> (HappyIdentity) HappyAbsSyn) 141 -> [HappyState (Token') (HappyStk HappyAbsSyn -> [(Token')] -> (HappyIdentity) HappyAbsSyn)] 142 -> HappyStk HappyAbsSyn 143 -> [(Token')] -> (HappyIdentity) HappyAbsSyn) 144 145 action_0 (26#) = happyShift action_4 146 action_0 (4#) = happyGoto action_5 147 action_0 (15#) = happyGoto action_2 148 action_0 (16#) = happyGoto action_3 149 action_0 x = happyTcHack x happyReduce_24 150 151 action_1 (26#) = happyShift action_4 152 action_1 (15#) = happyGoto action_2 153 action_1 (16#) = happyGoto action_3 154 action_1 x = happyTcHack x happyFail 155 156 action_2 (24#) = happyShift action_20 157 action_2 (11#) = happyGoto action_18 158 action_2 (12#) = happyGoto action_19 159 action_2 x = happyTcHack x happyFail 160 161 action_3 x = happyTcHack x happyReduce_23 162 163 action_4 (19#) = happyShift action_9 164 action_4 (20#) = happyShift action_10 165 action_4 (21#) = happyShift action_11 166 action_4 (22#) = happyShift action_12 167 action_4 (23#) = happyShift action_13 168 action_4 (24#) = happyShift action_14 169 action_4 (25#) = happyShift action_15 170 action_4 (26#) = happyShift action_4 171 action_4 (28#) = happyShift action_16 172 action_4 (29#) = happyShift action_17 173 action_4 (16#) = happyGoto action_6 174 action_4 (17#) = happyGoto action_7 175 action_4 (18#) = happyGoto action_8 176 action_4 x = happyTcHack x happyFail 177 178 action_5 (30#) = happyAccept 179 action_5 x = happyTcHack x happyFail 180 181 action_6 x = happyTcHack x happyReduce_30 182 183 action_7 (27#) = happyShift action_25 184 action_7 x = happyTcHack x happyFail 185 186 action_8 (19#) = happyShift action_9 187 action_8 (20#) = happyShift action_10 188 action_8 (21#) = happyShift action_11 189 action_8 (22#) = happyShift action_12 190 action_8 (23#) = happyShift action_13 191 action_8 (24#) = happyShift action_14 192 action_8 (25#) = happyShift action_15 193 action_8 (26#) = happyShift action_4 194 action_8 (28#) = happyShift action_16 195 action_8 (29#) = happyShift action_17 196 action_8 (16#) = happyGoto action_6 197 action_8 (17#) = happyGoto action_24 198 action_8 (18#) = happyGoto action_8 199 action_8 x = happyTcHack x happyReduce_27 200 201 action_9 x = happyTcHack x happyReduce_29 202 203 action_10 x = happyTcHack x happyReduce_32 204 205 action_11 x = happyTcHack x happyReduce_33 206 207 action_12 x = happyTcHack x happyReduce_34 208 209 action_13 x = happyTcHack x happyReduce_36 210 211 action_14 x = happyTcHack x happyReduce_37 212 213 action_15 x = happyTcHack x happyReduce_35 214 215 action_16 x = happyTcHack x happyReduce_31 216 217 action_17 x = happyTcHack x happyReduce_28 218 219 action_18 (23#) = happyShift action_23 220 action_18 x = happyTcHack x happyFail 221 222 action_19 (24#) = happyShift action_20 223 action_19 (11#) = happyGoto action_22 224 action_19 (12#) = happyGoto action_19 225 action_19 x = happyTcHack x happyReduce_15 226 227 action_20 (19#) = happyShift action_21 228 action_20 x = happyTcHack x happyFail 229 230 action_21 (19#) = happyShift action_32 231 action_21 (26#) = happyShift action_4 232 action_21 (29#) = happyShift action_33 233 action_21 (13#) = happyGoto action_29 234 action_21 (14#) = happyGoto action_30 235 action_21 (16#) = happyGoto action_31 236 action_21 x = happyTcHack x happyReduce_22 237 238 action_22 x = happyTcHack x happyReduce_14 239 240 action_23 (19#) = happyShift action_28 241 action_23 (5#) = happyGoto action_26 242 action_23 (6#) = happyGoto action_27 243 action_23 x = happyTcHack x happyFail 244 245 action_24 x = happyTcHack x happyReduce_26 246 247 action_25 x = happyTcHack x happyReduce_25 248 249 action_26 (19#) = happyShift action_28 250 action_26 (26#) = happyShift action_4 251 action_26 (6#) = happyGoto action_38 252 action_26 (15#) = happyGoto action_39 253 action_26 (16#) = happyGoto action_3 254 action_26 x = happyTcHack x happyReduce_24 255 256 action_27 x = happyTcHack x happyReduce_3 257 258 action_28 (20#) = happyShift action_36 259 action_28 (22#) = happyShift action_37 260 action_28 x = happyTcHack x happyFail 261 262 action_29 x = happyTcHack x happyReduce_16 263 264 action_30 x = happyTcHack x happyReduce_19 265 266 action_31 x = happyTcHack x happyReduce_17 267 268 action_32 (26#) = happyShift action_4 269 action_32 (16#) = happyGoto action_35 270 action_32 x = happyTcHack x happyReduce_18 271 272 action_33 (26#) = happyShift action_4 273 action_33 (16#) = happyGoto action_34 274 action_33 x = happyTcHack x happyFail 275 276 action_34 (19#) = happyShift action_48 277 action_34 (29#) = happyShift action_33 278 action_34 (14#) = happyGoto action_49 279 action_34 x = happyTcHack x happyReduce_22 280 281 action_35 (19#) = happyShift action_48 282 action_35 (29#) = happyShift action_33 283 action_35 (14#) = happyGoto action_47 284 action_35 x = happyTcHack x happyReduce_22 285 286 action_36 (19#) = happyShift action_45 287 action_36 (29#) = happyShift action_46 288 action_36 (7#) = happyGoto action_41 289 action_36 (8#) = happyGoto action_42 290 action_36 (9#) = happyGoto action_43 291 action_36 (10#) = happyGoto action_44 292 action_36 x = happyTcHack x happyReduce_11 293 294 action_37 (26#) = happyShift action_4 295 action_37 (16#) = happyGoto action_40 296 action_37 x = happyTcHack x happyFail 297 298 action_38 x = happyTcHack x happyReduce_2 299 300 action_39 x = happyTcHack x happyReduce_1 301 302 action_40 (19#) = happyShift action_53 303 action_40 x = happyTcHack x happyFail 304 305 action_41 x = happyTcHack x happyReduce_5 306 307 action_42 (25#) = happyShift action_52 308 action_42 x = happyTcHack x happyReduce_7 309 310 action_43 (26#) = happyShift action_4 311 action_43 (16#) = happyGoto action_51 312 action_43 x = happyTcHack x happyFail 313 314 action_44 (19#) = happyShift action_45 315 action_44 (29#) = happyShift action_46 316 action_44 (9#) = happyGoto action_50 317 action_44 (10#) = happyGoto action_44 318 action_44 x = happyTcHack x happyReduce_11 319 320 action_45 x = happyTcHack x happyReduce_13 321 322 action_46 x = happyTcHack x happyReduce_12 323 324 action_47 x = happyTcHack x happyReduce_20 325 326 action_48 (26#) = happyShift action_4 327 action_48 (16#) = happyGoto action_35 328 action_48 x = happyTcHack x happyFail 329 330 action_49 x = happyTcHack x happyReduce_21 331 332 action_50 x = happyTcHack x happyReduce_10 333 334 action_51 (21#) = happyShift action_56 335 action_51 x = happyTcHack x happyReduce_9 336 337 action_52 (19#) = happyShift action_45 338 action_52 (29#) = happyShift action_46 339 action_52 (7#) = happyGoto action_55 340 action_52 (8#) = happyGoto action_42 341 action_52 (9#) = happyGoto action_43 342 action_52 (10#) = happyGoto action_44 343 action_52 x = happyTcHack x happyReduce_11 344 345 action_53 (20#) = happyShift action_54 346 action_53 x = happyTcHack x happyFail 347 348 action_54 (19#) = happyShift action_45 349 action_54 (29#) = happyShift action_46 350 action_54 (7#) = happyGoto action_57 351 action_54 (8#) = happyGoto action_42 352 action_54 (9#) = happyGoto action_43 353 action_54 (10#) = happyGoto action_44 354 action_54 x = happyTcHack x happyReduce_11 355 356 action_55 x = happyTcHack x happyReduce_6 357 358 action_56 x = happyTcHack x happyReduce_8 359 360 action_57 x = happyTcHack x happyReduce_4 361 362 happyReduce_1 = happyReduce 5# 4# happyReduction_1 363 happyReduction_1 (_ `HappyStk` 364 (HappyAbsSyn4 happy_var_4) `HappyStk` 365 _ `HappyStk` 366 _ `HappyStk` 367 _ `HappyStk` 368 happyRest) 369 = HappyAbsSyn4 370 (reverse happy_var_4 371 ) `HappyStk` happyRest 372 373 happyReduce_2 = happySpecReduce_2 5# happyReduction_2 374 happyReduction_2 (HappyAbsSyn6 happy_var_2) 375 (HappyAbsSyn4 happy_var_1) 376 = HappyAbsSyn4 377 (happy_var_2 : happy_var_1 378 ) 379 happyReduction_2 _ _ = notHappyAtAll 380 381 happyReduce_3 = happySpecReduce_1 5# happyReduction_3 382 happyReduction_3 (HappyAbsSyn6 happy_var_1) 383 = HappyAbsSyn4 384 ([happy_var_1] 385 ) 386 happyReduction_3 _ = notHappyAtAll 387 388 happyReduce_4 = happyReduce 6# 6# happyReduction_4 389 happyReduction_4 ((HappyAbsSyn4 happy_var_6) `HappyStk` 390 _ `HappyStk` 391 (HappyTerminal happy_var_4) `HappyStk` 392 _ `HappyStk` 393 _ `HappyStk` 394 _ `HappyStk` 395 happyRest) 396 = HappyAbsSyn6 397 (ProdProduction (getIdent' happy_var_4) [] (ProdTerm happy_var_6) 398 ) `HappyStk` happyRest 399 400 happyReduce_5 = happySpecReduce_3 6# happyReduction_5 401 happyReduction_5 (HappyAbsSyn4 happy_var_3) 402 _ 403 (HappyTerminal happy_var_1) 404 = HappyAbsSyn6 405 (ProdProduction (getIdent' happy_var_1) [] (ProdTerm happy_var_3) 406 ) 407 happyReduction_5 _ _ _ = notHappyAtAll 408 409 happyReduce_6 = happySpecReduce_3 7# happyReduction_6 410 happyReduction_6 (HappyAbsSyn4 happy_var_3) 411 _ 412 (HappyAbsSyn6 happy_var_1) 413 = HappyAbsSyn4 414 (happy_var_1 : happy_var_3 415 ) 416 happyReduction_6 _ _ _ = notHappyAtAll 417 418 happyReduce_7 = happySpecReduce_1 7# happyReduction_7 419 happyReduction_7 (HappyAbsSyn6 happy_var_1) 420 = HappyAbsSyn4 421 ([happy_var_1] 422 ) 423 happyReduction_7 _ = notHappyAtAll 424 425 happyReduce_8 = happySpecReduce_3 8# happyReduction_8 426 happyReduction_8 _ 427 _ 428 (HappyAbsSyn4 happy_var_1) 429 = HappyAbsSyn6 430 (ProdFactor happy_var_1 431 ) 432 happyReduction_8 _ _ _ = notHappyAtAll 433 434 happyReduce_9 = happySpecReduce_2 8# happyReduction_9 435 happyReduction_9 _ 436 (HappyAbsSyn4 happy_var_1) 437 = HappyAbsSyn6 438 (ProdFactor happy_var_1 439 ) 440 happyReduction_9 _ _ = notHappyAtAll 441 442 happyReduce_10 = happySpecReduce_2 9# happyReduction_10 443 happyReduction_10 (HappyAbsSyn4 happy_var_2) 444 (HappyAbsSyn6 happy_var_1) 445 = HappyAbsSyn4 446 (happy_var_1 : happy_var_2 447 ) 448 happyReduction_10 _ _ = notHappyAtAll 449 450 happyReduce_11 = happySpecReduce_0 9# happyReduction_11 451 happyReduction_11 = HappyAbsSyn4 452 ([] 453 ) 454 455 happyReduce_12 = happySpecReduce_1 10# happyReduction_12 456 happyReduction_12 (HappyTerminal happy_var_1) 457 = HappyAbsSyn6 458 (ProdTerminal (getString' happy_var_1) 459 ) 460 happyReduction_12 _ = notHappyAtAll 461 462 happyReduce_13 = happySpecReduce_1 10# happyReduction_13 463 happyReduction_13 (HappyTerminal happy_var_1) 464 = HappyAbsSyn6 465 (ProdNonterminal (getIdent' happy_var_1) 466 ) 467 happyReduction_13 _ = notHappyAtAll 468 469 happyReduce_14 = happySpecReduce_2 11# happyReduction_14 470 happyReduction_14 _ 471 _ 472 = HappyAbsSyn11 473 (() 474 ) 475 476 happyReduce_15 = happySpecReduce_1 11# happyReduction_15 477 happyReduction_15 _ 478 = HappyAbsSyn11 479 (() 480 ) 481 482 happyReduce_16 = happySpecReduce_3 12# happyReduction_16 483 happyReduction_16 _ 484 _ 485 _ 486 = HappyAbsSyn11 487 (() 488 ) 489 490 happyReduce_17 = happySpecReduce_1 13# happyReduction_17 491 happyReduction_17 _ 492 = HappyAbsSyn11 493 (() 494 ) 495 496 happyReduce_18 = happySpecReduce_1 13# happyReduction_18 497 happyReduction_18 _ 498 = HappyAbsSyn11 499 (() 500 ) 501 502 happyReduce_19 = happySpecReduce_1 13# happyReduction_19 503 happyReduction_19 _ 504 = HappyAbsSyn11 505 (() 506 ) 507 508 happyReduce_20 = happySpecReduce_3 14# happyReduction_20 509 happyReduction_20 _ 510 _ 511 _ 512 = HappyAbsSyn11 513 (() 514 ) 515 516 happyReduce_21 = happySpecReduce_3 14# happyReduction_21 517 happyReduction_21 _ 518 _ 519 _ 520 = HappyAbsSyn11 521 (() 522 ) 523 524 happyReduce_22 = happySpecReduce_0 14# happyReduction_22 525 happyReduction_22 = HappyAbsSyn11 526 (() 527 ) 528 529 happyReduce_23 = happySpecReduce_1 15# happyReduction_23 530 happyReduction_23 _ 531 = HappyAbsSyn11 532 (() 533 ) 534 535 happyReduce_24 = happySpecReduce_0 15# happyReduction_24 536 happyReduction_24 = HappyAbsSyn11 537 (() 538 ) 539 540 happyReduce_25 = happySpecReduce_3 16# happyReduction_25 541 happyReduction_25 _ 542 _ 543 _ 544 = HappyAbsSyn11 545 (() 546 ) 547 548 happyReduce_26 = happySpecReduce_2 17# happyReduction_26 549 happyReduction_26 _ 550 _ 551 = HappyAbsSyn11 552 (() 553 ) 554 555 happyReduce_27 = happySpecReduce_1 17# happyReduction_27 556 happyReduction_27 _ 557 = HappyAbsSyn11 558 (() 559 ) 560 561 happyReduce_28 = happySpecReduce_1 18# happyReduction_28 562 happyReduction_28 _ 563 = HappyAbsSyn11 564 (() 565 ) 566 567 happyReduce_29 = happySpecReduce_1 18# happyReduction_29 568 happyReduction_29 _ 569 = HappyAbsSyn11 570 (() 571 ) 572 573 happyReduce_30 = happySpecReduce_1 18# happyReduction_30 574 happyReduction_30 _ 575 = HappyAbsSyn11 576 (() 577 ) 578 579 happyReduce_31 = happySpecReduce_1 18# happyReduction_31 580 happyReduction_31 _ 581 = HappyAbsSyn11 582 (() 583 ) 584 585 happyReduce_32 = happySpecReduce_1 18# happyReduction_32 586 happyReduction_32 _ 587 = HappyAbsSyn11 588 (() 589 ) 590 591 happyReduce_33 = happySpecReduce_1 18# happyReduction_33 592 happyReduction_33 _ 593 = HappyAbsSyn11 594 (() 595 ) 596 597 happyReduce_34 = happySpecReduce_1 18# happyReduction_34 598 happyReduction_34 _ 599 = HappyAbsSyn11 600 (() 601 ) 602 603 happyReduce_35 = happySpecReduce_1 18# happyReduction_35 604 happyReduction_35 _ 605 = HappyAbsSyn11 606 (() 607 ) 608 609 happyReduce_36 = happySpecReduce_1 18# happyReduction_36 610 happyReduction_36 _ 611 = HappyAbsSyn11 612 (() 613 ) 614 615 happyReduce_37 = happySpecReduce_1 18# happyReduction_37 616 happyReduction_37 _ 617 = HappyAbsSyn11 618 (() 619 ) 620 621 happyNewToken action sts stk [] = 622 action 30# 30# notHappyAtAll (HappyState action) sts stk [] 623 624 happyNewToken action sts stk (tk:tks) = 625 let cont i = action i i tk (HappyState action) sts stk tks in 626 case tk of { 627 Ident' _ -> cont 19#; 628 Colon -> cont 20#; 629 Semicolon -> cont 21#; 630 DoubleColon -> cont 22#; 631 DoublePercent -> cont 23#; 632 Percent -> cont 24#; 633 Bar -> cont 25#; 634 OpenBrace -> cont 26#; 635 ClosingBrace -> cont 27#; 636 Symbol' _ -> cont 28#; 637 String' _ -> cont 29#; 638 _ -> happyError' (tk:tks) 639 } 640 641 happyError_ tk tks = happyError' (tk:tks) 642 643 newtype HappyIdentity a = HappyIdentity a 644 happyIdentity = HappyIdentity 645 happyRunIdentity (HappyIdentity a) = a 646 647 instance Monad HappyIdentity where 648 return = HappyIdentity 649 (HappyIdentity p) >>= q = q p 650 651 happyThen :: () => HappyIdentity a -> (a -> HappyIdentity b) -> HappyIdentity b 652 happyThen = (>>=) 653 happyReturn :: () => a -> HappyIdentity a 654 happyReturn = (return) 655 happyThen1 m k tks = (>>=) m (\a -> k a tks) 656 happyReturn1 :: () => a -> b -> HappyIdentity a 657 happyReturn1 = \a tks -> (return) a 658 happyError' :: () => [(Token')] -> HappyIdentity a 659 happyError' = HappyIdentity . happyError 660 661 localHappyParser tks = happyRunIdentity happySomeParser where 662 happySomeParser = happyThen (happyParse action_0 tks) (\x -> case x of {HappyAbsSyn4 z -> happyReturn z; _other -> notHappyAtAll }) 663 664 happySeq = happyDontSeq 665 666 667 happyError :: [Token'] -> a 668 happyError ts = error ("Parse error in line " ++ show 0 ++ 669 case ts of 670 [] -> " (at EOF)\n" 671 _ -> "\n" ++ show (take 20 ts) ++ "\n") 672 673 674 675 unlit :: String -> String 676 unlit = unlines . map (tail.tail) . filter p . lines 677 where p ('>':' ':_) = True 678 p ('>':'\t':_) = True 679 p _ = False 680 681 682 683 data Token' = Ident' String | Symbol' String | String' String 684 | Percent | DoublePercent | OpenBrace | ClosingBrace 685 | Colon | Semicolon | DoubleColon | Bar 686 687 instance Show Token' where 688 showsPrec n (Ident' s) = showChar '[' . showString s . showString "] " 689 showsPrec n (Symbol' s) = showChar '<' . showString s . showString "> " 690 showsPrec n (String' s) = showChar '"' . showString s . showString "\" " 691 showsPrec n Percent = showString "% " 692 showsPrec n DoublePercent = showString "%% " 693 showsPrec n OpenBrace = showString "{ " 694 showsPrec n ClosingBrace = showString "} " 695 showsPrec n Colon = showString ": " 696 showsPrec n Semicolon = showString "; " 697 showsPrec n DoubleColon = showString ":: " 698 699 700 postlexer = map f 701 where f (Symbol "%%") = DoublePercent 702 f (Symbol "%") = Percent 703 f (Symbol "{") = OpenBrace 704 f (Symbol "}") = ClosingBrace 705 f (Symbol "::") = DoubleColon 706 f (Symbol ":") = Colon 707 f (Symbol ";") = Semicolon 708 f (Symbol "|") = Bar 709 f (Symbol s) = Symbol' s 710 f (Ident s) = Ident' s 711 f (String s) = String' s 712 713 getIdent' (Ident' x) = x 714 getString' (String' x) = x 715 716 theHappyParser = localHappyParser . postlexer . lexer . unlit 717 {-# LINE 1 "templates/GenericTemplate.hs" #-} 718 {-# LINE 1 "templates/GenericTemplate.hs" #-} 719 {-# LINE 1 "<built-in>" #-} 720 {-# LINE 1 "<command-line>" #-} 721 {-# LINE 1 "templates/GenericTemplate.hs" #-} 722 -- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp 723 724 {-# LINE 28 "templates/GenericTemplate.hs" #-} 725 726 727 728 729 730 731 732 733 {-# LINE 49 "templates/GenericTemplate.hs" #-} 734 735 {-# LINE 59 "templates/GenericTemplate.hs" #-} 736 737 {-# LINE 68 "templates/GenericTemplate.hs" #-} 738 739 infixr 9 `HappyStk` 740 data HappyStk a = HappyStk a (HappyStk a) 741 742 ----------------------------------------------------------------------------- 743 -- starting the parse 744 745 happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll 746 747 ----------------------------------------------------------------------------- 748 -- Accepting the parse 749 750 -- If the current token is 1#, it means we've just accepted a partial 751 -- parse (a %partial parser). We must ignore the saved token on the top of 752 -- the stack in this case. 753 happyAccept 1# tk st sts (_ `HappyStk` ans `HappyStk` _) = 754 happyReturn1 ans 755 happyAccept j tk st sts (HappyStk ans _) = 756 (happyTcHack j ) (happyReturn1 ans) 757 758 ----------------------------------------------------------------------------- 759 -- Arrays only: do the next action 760 761 {-# LINE 155 "templates/GenericTemplate.hs" #-} 762 763 ----------------------------------------------------------------------------- 764 -- HappyState data type (not arrays) 765 766 767 768 newtype HappyState b c = HappyState 769 (Happy_GHC_Exts.Int# -> -- token number 770 Happy_GHC_Exts.Int# -> -- token number (yes, again) 771 b -> -- token semantic value 772 HappyState b c -> -- current state 773 [HappyState b c] -> -- state stack 774 c) 775 776 777 778 ----------------------------------------------------------------------------- 779 -- Shifting a token 780 781 happyShift new_state 1# tk st sts stk@(x `HappyStk` _) = 782 let i = (case x of { HappyErrorToken (Happy_GHC_Exts.I# (i)) -> i }) in 783 -- trace "shifting the error token" $ 784 new_state i i tk (HappyState (new_state)) ((st):(sts)) (stk) 785 786 happyShift new_state i tk st sts stk = 787 happyNewToken new_state ((st):(sts)) ((HappyTerminal (tk))`HappyStk`stk) 788 789 -- happyReduce is specialised for the common cases. 790 791 happySpecReduce_0 i fn 1# tk st sts stk 792 = happyFail 1# tk st sts stk 793 happySpecReduce_0 nt fn j tk st@((HappyState (action))) sts stk 794 = action nt j tk st ((st):(sts)) (fn `HappyStk` stk) 795 796 happySpecReduce_1 i fn 1# tk st sts stk 797 = happyFail 1# tk st sts stk 798 happySpecReduce_1 nt fn j tk _ sts@(((st@(HappyState (action))):(_))) (v1`HappyStk`stk') 799 = let r = fn v1 in 800 happySeq r (action nt j tk st sts (r `HappyStk` stk')) 801 802 happySpecReduce_2 i fn 1# tk st sts stk 803 = happyFail 1# tk st sts stk 804 happySpecReduce_2 nt fn j tk _ ((_):(sts@(((st@(HappyState (action))):(_))))) (v1`HappyStk`v2`HappyStk`stk') 805 = let r = fn v1 v2 in 806 happySeq r (action nt j tk st sts (r `HappyStk` stk')) 807 808 happySpecReduce_3 i fn 1# tk st sts stk 809 = happyFail 1# tk st sts stk 810 happySpecReduce_3 nt fn j tk _ ((_):(((_):(sts@(((st@(HappyState (action))):(_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') 811 = let r = fn v1 v2 v3 in 812 happySeq r (action nt j tk st sts (r `HappyStk` stk')) 813 814 happyReduce k i fn 1# tk st sts stk 815 = happyFail 1# tk st sts stk 816 happyReduce k nt fn j tk st sts stk 817 = case happyDrop (k Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) sts of 818 sts1@(((st1@(HappyState (action))):(_))) -> 819 let r = fn stk in -- it doesn't hurt to always seq here... 820 happyDoSeq r (action nt j tk st1 sts1 r) 821 822 happyMonadReduce k nt fn 1# tk st sts stk 823 = happyFail 1# tk st sts stk 824 happyMonadReduce k nt fn j tk st sts stk = 825 happyThen1 (fn stk tk) (\r -> action nt j tk st1 sts1 (r `HappyStk` drop_stk)) 826 where sts1@(((st1@(HappyState (action))):(_))) = happyDrop k ((st):(sts)) 827 drop_stk = happyDropStk k stk 828 829 happyMonad2Reduce k nt fn 1# tk st sts stk 830 = happyFail 1# tk st sts stk 831 happyMonad2Reduce k nt fn j tk st sts stk = 832 happyThen1 (fn stk tk) (\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk)) 833 where sts1@(((st1@(HappyState (action))):(_))) = happyDrop k ((st):(sts)) 834 drop_stk = happyDropStk k stk 835 836 837 838 839 840 new_state = action 841 842 843 happyDrop 0# l = l 844 happyDrop n ((_):(t)) = happyDrop (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) t 845 846 happyDropStk 0# l = l 847 happyDropStk n (x `HappyStk` xs) = happyDropStk (n Happy_GHC_Exts.-# (1#::Happy_GHC_Exts.Int#)) xs 848 849 ----------------------------------------------------------------------------- 850 -- Moving to a new state after a reduction 851 852 {-# LINE 253 "templates/GenericTemplate.hs" #-} 853 happyGoto action j tk st = action j j tk (HappyState action) 854 855 856 ----------------------------------------------------------------------------- 857 -- Error recovery (1# is the error token) 858 859 -- parse error if we are in recovery and we fail again 860 happyFail 1# tk old_st _ stk = 861 -- trace "failing" $ 862 happyError_ tk 863 864 {- We don't need state discarding for our restricted implementation of 865 "error". In fact, it can cause some bogus parses, so I've disabled it 866 for now --SDM 867 868 -- discard a state 869 happyFail 1# tk old_st (((HappyState (action))):(sts)) 870 (saved_tok `HappyStk` _ `HappyStk` stk) = 871 -- trace ("discarding state, depth " ++ show (length stk)) $ 872 action 1# 1# tk (HappyState (action)) sts ((saved_tok`HappyStk`stk)) 873 -} 874 875 -- Enter error recovery: generate an error token, 876 -- save the old token and carry on. 877 happyFail i tk (HappyState (action)) sts stk = 878 -- trace "entering error recovery" $ 879 action 1# 1# tk (HappyState (action)) sts ( (HappyErrorToken (Happy_GHC_Exts.I# (i))) `HappyStk` stk) 880 881 -- Internal happy errors: 882 883 notHappyAtAll = error "Internal Happy error\n" 884 885 ----------------------------------------------------------------------------- 886 -- Hack to get the typechecker to accept our action functions 887 888 889 happyTcHack :: Happy_GHC_Exts.Int# -> a -> a 890 happyTcHack x y = y 891 {-# INLINE happyTcHack #-} 892 893 894 ----------------------------------------------------------------------------- 895 -- Seq-ing. If the --strict flag is given, then Happy emits 896 -- happySeq = happyDoSeq 897 -- otherwise it emits 898 -- happySeq = happyDontSeq 899 900 happyDoSeq, happyDontSeq :: a -> b -> b 901 happyDoSeq a b = a `seq` b 902 happyDontSeq a b = b 903 904 ----------------------------------------------------------------------------- 905 -- Don't inline any functions from the template. GHC has a nasty habit 906 -- of deciding to inline happyGoto everywhere, which increases the size of 907 -- the generated parser quite a bit. 908 909 {-# LINE 317 "templates/GenericTemplate.hs" #-} 910 {-# NOINLINE happyShift #-} 911 {-# NOINLINE happySpecReduce_0 #-} 912 {-# NOINLINE happySpecReduce_1 #-} 913 {-# NOINLINE happySpecReduce_2 #-} 914 {-# NOINLINE happySpecReduce_3 #-} 915 {-# NOINLINE happyReduce #-} 916 {-# NOINLINE happyMonadReduce #-} 917 {-# NOINLINE happyGoto #-} 918 {-# NOINLINE happyFail #-} 919 920 -- end of Happy Template.