Commit 4c6c7f6b authored by Etienne Renault's avatar Etienne Renault
Browse files

src: regenerate parser

* src/Parse.hs: here.
parent 63dd4313
-- parser produced by Happy Version 1.13
{-# OPTIONS_GHC -w #-}
module Parse (parse)
where
......@@ -9,22 +8,33 @@ import Ir
import Token
import Location (merge)
import Annotation (Ann (NoAnn, LevelAnn, LocationAnn), annExp, locationAnn)
import Control.Applicative(Applicative(..))
import Control.Monad (ap)
-- parser produced by Happy Version 1.19.5
data HappyAbsSyn
= HappyTerminal Tok
= HappyTerminal (Tok)
| HappyErrorToken Int
| HappyAbsSyn4 ([Stm Ann])
| HappyAbsSyn5 (Exp Ann)
| HappyAbsSyn6 (Stm Ann)
| HappyAbsSyn7 ([Exp Ann])
type HappyReduction =
{- to allow type-synonyms as our monads (likely
- with explicitly-specified bind and return)
- in Haskell98, it seems that with
- /type M a = .../, then /(HappyReduction M)/
- is not allowed. But Happy is a
- code-generator that can just substitute it.
type HappyReduction m =
Int
-> (Tok)
-> HappyState (Tok) (HappyStk HappyAbsSyn -> [(Tok)] -> HappyAbsSyn)
-> [HappyState (Tok) (HappyStk HappyAbsSyn -> [(Tok)] -> HappyAbsSyn)]
-> HappyState (Tok) (HappyStk HappyAbsSyn -> [(Tok)] -> m HappyAbsSyn)
-> [HappyState (Tok) (HappyStk HappyAbsSyn -> [(Tok)] -> m HappyAbsSyn)]
-> HappyStk HappyAbsSyn
-> [(Tok)] -> HappyAbsSyn
-> [(Tok)] -> m HappyAbsSyn
-}
action_0,
action_1,
......@@ -72,7 +82,13 @@ action_0,
action_43,
action_44,
action_45,
action_46 :: Int -> HappyReduction
action_46 :: () => Int -> ({-HappyReduction (HappyIdentity) = -}
Int
-> (Tok)
-> HappyState (Tok) (HappyStk HappyAbsSyn -> [(Tok)] -> (HappyIdentity) HappyAbsSyn)
-> [HappyState (Tok) (HappyStk HappyAbsSyn -> [(Tok)] -> (HappyIdentity) HappyAbsSyn)]
-> HappyStk HappyAbsSyn
-> [(Tok)] -> (HappyIdentity) HappyAbsSyn)
happyReduce_1,
happyReduce_2,
......@@ -93,7 +109,13 @@ happyReduce_1,
happyReduce_17,
happyReduce_18,
happyReduce_19,
happyReduce_20 :: HappyReduction
happyReduce_20 :: () => ({-HappyReduction (HappyIdentity) = -}
Int
-> (Tok)
-> HappyState (Tok) (HappyStk HappyAbsSyn -> [(Tok)] -> (HappyIdentity) HappyAbsSyn)
-> [HappyState (Tok) (HappyStk HappyAbsSyn -> [(Tok)] -> (HappyIdentity) HappyAbsSyn)]
-> HappyStk HappyAbsSyn
-> [(Tok)] -> (HappyIdentity) HappyAbsSyn)
action_0 (12) = happyShift action_4
action_0 (15) = happyShift action_5
......@@ -366,14 +388,14 @@ action_45 _ = happyReduce_5
action_46 _ = happyReduce_12
happyReduce_1 = happySpecReduce_1 4 happyReduction_1
happyReduce_1 = happySpecReduce_1 4 happyReduction_1
happyReduction_1 (HappyAbsSyn4 happy_var_1)
= HappyAbsSyn4
(happy_var_1
)
happyReduction_1 _ = notHappyAtAll
happyReduce_2 = happySpecReduce_2 5 happyReduction_2
happyReduce_2 = happySpecReduce_2 5 happyReduction_2
happyReduction_2 (HappyTerminal (TokInt happy_var_2))
(HappyTerminal (TokConst happy_var_1))
= HappyAbsSyn5
......@@ -381,7 +403,7 @@ happyReduction_2 (HappyTerminal (TokInt happy_var_2))
)
happyReduction_2 _ _ = notHappyAtAll
happyReduce_3 = happySpecReduce_2 5 happyReduction_3
happyReduce_3 = happySpecReduce_2 5 happyReduction_3
happyReduction_3 (HappyTerminal (TokString happy_var_2))
(HappyTerminal (TokName happy_var_1))
= HappyAbsSyn5
......@@ -389,7 +411,7 @@ happyReduction_3 (HappyTerminal (TokString happy_var_2))
)
happyReduction_3 _ _ = notHappyAtAll
happyReduce_4 = happySpecReduce_2 5 happyReduction_4
happyReduce_4 = happySpecReduce_2 5 happyReduction_4
happyReduction_4 (HappyTerminal (TokString happy_var_2))
(HappyTerminal (TokTemp happy_var_1))
= HappyAbsSyn5
......@@ -407,7 +429,7 @@ happyReduction_5 ((HappyAbsSyn5 happy_var_4) `HappyStk`
(Binop (LocationAnn $ merge happy_var_1 (locationAnn $ annExp happy_var_4)) (fst happy_var_2) happy_var_3 happy_var_4
) `HappyStk` happyRest
happyReduce_6 = happySpecReduce_2 5 happyReduction_6
happyReduce_6 = happySpecReduce_2 5 happyReduction_6
happyReduction_6 (HappyAbsSyn5 happy_var_2)
(HappyTerminal (TokMem happy_var_1))
= HappyAbsSyn5
......@@ -425,7 +447,7 @@ happyReduction_7 ((HappyTerminal (TokCallEnd happy_var_4)) `HappyStk`
(Call (LocationAnn $ merge happy_var_1 happy_var_4) happy_var_2 happy_var_3
) `HappyStk` happyRest
happyReduce_8 = happySpecReduce_3 5 happyReduction_8
happyReduce_8 = happySpecReduce_3 5 happyReduction_8
happyReduction_8 (HappyAbsSyn5 happy_var_3)
(HappyAbsSyn6 happy_var_2)
(HappyTerminal (TokESeq happy_var_1))
......@@ -434,7 +456,7 @@ happyReduction_8 (HappyAbsSyn5 happy_var_3)
)
happyReduction_8 _ _ _ = notHappyAtAll
happyReduce_9 = happySpecReduce_3 6 happyReduction_9
happyReduce_9 = happySpecReduce_3 6 happyReduction_9
happyReduction_9 (HappyAbsSyn5 happy_var_3)
(HappyAbsSyn5 happy_var_2)
(HappyTerminal (TokMove happy_var_1))
......@@ -443,7 +465,7 @@ happyReduction_9 (HappyAbsSyn5 happy_var_3)
)
happyReduction_9 _ _ _ = notHappyAtAll
happyReduce_10 = happySpecReduce_2 6 happyReduction_10
happyReduce_10 = happySpecReduce_2 6 happyReduction_10
happyReduction_10 (HappyAbsSyn5 happy_var_2)
(HappyTerminal (TokExp happy_var_1))
= HappyAbsSyn6
......@@ -451,7 +473,7 @@ happyReduction_10 (HappyAbsSyn5 happy_var_2)
)
happyReduction_10 _ _ = notHappyAtAll
happyReduce_11 = happySpecReduce_2 6 happyReduction_11
happyReduce_11 = happySpecReduce_2 6 happyReduction_11
happyReduction_11 (HappyAbsSyn5 happy_var_2)
(HappyTerminal (TokJump happy_var_1))
= HappyAbsSyn6
......@@ -471,7 +493,7 @@ happyReduction_12 ((HappyAbsSyn5 happy_var_6) `HappyStk`
(CJump (LocationAnn $ merge happy_var_1 (locationAnn $ annExp happy_var_6)) (fst happy_var_2) happy_var_3 happy_var_4 happy_var_5 happy_var_6
) `HappyStk` happyRest
happyReduce_13 = happySpecReduce_3 6 happyReduction_13
happyReduce_13 = happySpecReduce_3 6 happyReduction_13
happyReduction_13 (HappyTerminal (TokSeqEnd happy_var_3))
(HappyAbsSyn4 happy_var_2)
(HappyTerminal (TokSeq happy_var_1))
......@@ -480,7 +502,7 @@ happyReduction_13 (HappyTerminal (TokSeqEnd happy_var_3))
)
happyReduction_13 _ _ _ = notHappyAtAll
happyReduce_14 = happySpecReduce_2 6 happyReduction_14
happyReduce_14 = happySpecReduce_2 6 happyReduction_14
happyReduction_14 (HappyTerminal (TokString happy_var_2))
(HappyTerminal (TokLabel happy_var_1))
= HappyAbsSyn6
......@@ -488,7 +510,7 @@ happyReduction_14 (HappyTerminal (TokString happy_var_2))
)
happyReduction_14 _ _ = notHappyAtAll
happyReduce_15 = happySpecReduce_3 6 happyReduction_15
happyReduce_15 = happySpecReduce_3 6 happyReduction_15
happyReduction_15 (HappyTerminal (TokLiteral happy_var_3))
(HappyTerminal (TokString happy_var_2))
(HappyTerminal (TokLabel happy_var_1))
......@@ -497,19 +519,19 @@ happyReduction_15 (HappyTerminal (TokLiteral happy_var_3))
)
happyReduction_15 _ _ _ = notHappyAtAll
happyReduce_16 = happySpecReduce_1 6 happyReduction_16
happyReduce_16 = happySpecReduce_1 6 happyReduction_16
happyReduction_16 (HappyTerminal (TokLabelEnd happy_var_1))
= HappyAbsSyn6
(LabelEnd $ LocationAnn happy_var_1
)
happyReduction_16 _ = notHappyAtAll
happyReduce_17 = happySpecReduce_0 7 happyReduction_17
happyReduce_17 = happySpecReduce_0 7 happyReduction_17
happyReduction_17 = HappyAbsSyn7
([]
)
happyReduce_18 = happySpecReduce_2 7 happyReduction_18
happyReduce_18 = happySpecReduce_2 7 happyReduction_18
happyReduction_18 (HappyAbsSyn7 happy_var_2)
(HappyAbsSyn5 happy_var_1)
= HappyAbsSyn7
......@@ -517,12 +539,12 @@ happyReduction_18 (HappyAbsSyn7 happy_var_2)
)
happyReduction_18 _ _ = notHappyAtAll
happyReduce_19 = happySpecReduce_0 8 happyReduction_19
happyReduce_19 = happySpecReduce_0 8 happyReduction_19
happyReduction_19 = HappyAbsSyn4
([]
)
happyReduce_20 = happySpecReduce_2 8 happyReduction_20
happyReduce_20 = happySpecReduce_2 8 happyReduction_20
happyReduction_20 (HappyAbsSyn4 happy_var_2)
(HappyAbsSyn6 happy_var_1)
= HappyAbsSyn4
......@@ -531,7 +553,7 @@ happyReduction_20 (HappyAbsSyn4 happy_var_2)
happyReduction_20 _ _ = notHappyAtAll
happyNewToken action sts stk [] =
action 31 31 (error "reading EOF!") (HappyState action) sts stk []
action 31 31 notHappyAtAll (HappyState action) sts stk []
happyNewToken action sts stk (tk:tks) =
let cont i = action i i tk (HappyState action) sts stk tks in
......@@ -558,29 +580,67 @@ happyNewToken action sts stk (tk:tks) =
TokSeqEnd happy_dollar_dollar -> cont 28;
TokString happy_dollar_dollar -> cont 29;
TokTemp happy_dollar_dollar -> cont 30;
_ -> happyError tks
_ -> happyError' (tk:tks)
}
happyThen = \m k -> k m
happyReturn = \a -> a
happyThen1 = happyThen
happyReturn1 = \a tks -> a
happyError_ 31 tk tks = happyError' tks
happyError_ _ tk tks = happyError' (tk:tks)
newtype HappyIdentity a = HappyIdentity a
happyIdentity = HappyIdentity
happyRunIdentity (HappyIdentity a) = a
instance Functor HappyIdentity where
fmap f (HappyIdentity a) = HappyIdentity (f a)
parse tks = happyThen (happyParse action_0 tks) (\x -> case x of {HappyAbsSyn4 z -> happyReturn z; _other -> notHappyAtAll })
instance Applicative HappyIdentity where
pure = return
(<*>) = ap
instance Monad HappyIdentity where
return = HappyIdentity
(HappyIdentity p) >>= q = q p
happyThen :: () => HappyIdentity a -> (a -> HappyIdentity b) -> HappyIdentity b
happyThen = (>>=)
happyReturn :: () => a -> HappyIdentity a
happyReturn = (return)
happyThen1 m k tks = (>>=) m (\a -> k a tks)
happyReturn1 :: () => a -> b -> HappyIdentity a
happyReturn1 = \a tks -> (return) a
happyError' :: () => [(Tok)] -> HappyIdentity a
happyError' = HappyIdentity . happyError
parse tks = happyRunIdentity happySomeParser where
happySomeParser = happyThen (happyParse action_0 tks) (\x -> case x of {HappyAbsSyn4 z -> happyReturn z; _other -> notHappyAtAll })
happySeq = happyDontSeq
happyError :: [Tok] -> a
happyError (tok : toks) = error $ "Parse error before " ++ (show tok)
happyError [] = error $ "Parse error at end of file."
{-# LINE 1 "GenericTemplate.hs" #-}
{-# LINE 1 "templates/GenericTemplate.hs" #-}
{-# LINE 1 "templates/GenericTemplate.hs" #-}
{-# LINE 1 "<built-in>" #-}
{-# LINE 1 "<command line>" #-}
{-# LINE 1 "GenericTemplate.hs" #-}
-- $Id: GenericTemplate.hs,v 1.23 2002/05/23 09:24:27 simonmar Exp $
{-# LINE 1 "<command-line>" #-}
{-# LINE 8 "<command-line>" #-}
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 17 "/usr/include/stdc-predef.h" 3 4
{-# LINE 16 "GenericTemplate.hs" #-}
{-# LINE 28 "GenericTemplate.hs" #-}
......@@ -609,6 +669,8 @@ happyError [] = error $ "Parse error at end of file."
{-# LINE 8 "<command-line>" #-}
{-# LINE 1 "/usr/lib/ghc/include/ghcversion.h" #-}
......@@ -622,6 +684,31 @@ happyError [] = error $ "Parse error at end of file."
{-# LINE 8 "<command-line>" #-}
{-# LINE 1 "templates/GenericTemplate.hs" #-}
-- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
{-# LINE 13 "templates/GenericTemplate.hs" #-}
{-# LINE 46 "templates/GenericTemplate.hs" #-}
{-# LINE 67 "templates/GenericTemplate.hs" #-}
{-# LINE 77 "templates/GenericTemplate.hs" #-}
{-# LINE 86 "templates/GenericTemplate.hs" #-}
infixr 9 `HappyStk`
data HappyStk a = HappyStk a (HappyStk a)
......@@ -633,14 +720,18 @@ happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll
-----------------------------------------------------------------------------
-- Accepting the parse
-- If the current token is (1), it means we've just accepted a partial
-- parse (a %partial parser). We must ignore the saved token on the top of
-- the stack in this case.
happyAccept (1) tk st sts (_ `HappyStk` ans `HappyStk` _) =
happyReturn1 ans
happyAccept j tk st sts (HappyStk ans _) =
(happyReturn1 ans)
(happyReturn1 ans)
-----------------------------------------------------------------------------
-- Arrays only: do the next action
{-# LINE 151 "GenericTemplate.hs" #-}
{-# LINE 155 "templates/GenericTemplate.hs" #-}
-----------------------------------------------------------------------------
-- HappyState data type (not arrays)
......@@ -697,16 +788,33 @@ happyReduce k i fn (1) tk st sts stk
= happyFail (1) tk st sts stk
happyReduce k nt fn j tk st sts stk
= case happyDrop (k - ((1) :: Int)) sts of
sts1@(((st1@(HappyState (action))):(_))) ->
let r = fn stk in -- it doesn't hurt to always seq here...
happyDoSeq r (action nt j tk st1 sts1 r)
sts1@(((st1@(HappyState (action))):(_))) ->
let r = fn stk in -- it doesn't hurt to always seq here...
happyDoSeq r (action nt j tk st1 sts1 r)
happyMonadReduce k nt fn (1) tk st sts stk
= happyFail (1) tk st sts stk
happyMonadReduce k nt fn j tk st sts stk =
happyThen1 (fn stk) (\r -> action nt j tk st1 sts1 (r `HappyStk` drop_stk))
where sts1@(((st1@(HappyState (action))):(_))) = happyDrop k ((st):(sts))
drop_stk = happyDropStk k stk
case happyDrop k ((st):(sts)) of
sts1@(((st1@(HappyState (action))):(_))) ->
let drop_stk = happyDropStk k stk in
happyThen1 (fn stk tk) (\r -> action nt j tk st1 sts1 (r `HappyStk` drop_stk))
happyMonad2Reduce k nt fn (1) tk st sts stk
= happyFail (1) tk st sts stk
happyMonad2Reduce k nt fn j tk st sts stk =
case happyDrop k ((st):(sts)) of
sts1@(((st1@(HappyState (action))):(_))) ->
let drop_stk = happyDropStk k stk
new_state = action
in
happyThen1 (fn stk tk) (\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk))
happyDrop (0) l = l
happyDrop n ((_):(t)) = happyDrop (n - ((1) :: Int)) t
......@@ -717,7 +825,7 @@ happyDropStk n (x `HappyStk` xs) = happyDropStk (n - ((1)::Int)) xs
-----------------------------------------------------------------------------
-- Moving to a new state after a reduction
{-# LINE 235 "GenericTemplate.hs" #-}
{-# LINE 256 "templates/GenericTemplate.hs" #-}
happyGoto action j tk st = action j j tk (HappyState action)
......@@ -725,10 +833,10 @@ happyGoto action j tk st = action j j tk (HappyState action)
-- Error recovery ((1) is the error token)
-- parse error if we are in recovery and we fail again
happyFail (1) tk old_st _ stk =
-- trace "failing" $
happyError
happyFail (1) tk old_st _ stk@(x `HappyStk` _) =
let i = (case x of { HappyErrorToken (i) -> i }) in
-- trace "failing" $
happyError_ i tk
{- We don't need state discarding for our restricted implementation of
"error". In fact, it can cause some bogus parses, so I've disabled it
......@@ -736,19 +844,20 @@ happyFail (1) tk old_st _ stk =
-- discard a state
happyFail (1) tk old_st (((HappyState (action))):(sts))
(saved_tok `HappyStk` _ `HappyStk` stk) =
-- trace ("discarding state, depth " ++ show (length stk)) $
action (1) (1) tk (HappyState (action)) sts ((saved_tok`HappyStk`stk))
(saved_tok `HappyStk` _ `HappyStk` stk) =
-- trace ("discarding state, depth " ++ show (length stk)) $
action (1) (1) tk (HappyState (action)) sts ((saved_tok`HappyStk`stk))
-}
-- Enter error recovery: generate an error token,
-- save the old token and carry on.
happyFail i tk (HappyState (action)) sts stk =
-- trace "entering error recovery" $
action (1) (1) tk (HappyState (action)) sts ( (HappyErrorToken (i)) `HappyStk` stk)
action (1) (1) tk (HappyState (action)) sts ( (HappyErrorToken (i)) `HappyStk` stk)
-- Internal happy errors:
notHappyAtAll :: a
notHappyAtAll = error "Internal Happy error\n"
-----------------------------------------------------------------------------
......@@ -762,9 +871,9 @@ notHappyAtAll = error "Internal Happy error\n"
-----------------------------------------------------------------------------
-- Seq-ing. If the --strict flag is given, then Happy emits
-- happySeq = happyDoSeq
-- happySeq = happyDoSeq
-- otherwise it emits
-- happySeq = happyDontSeq
-- happySeq = happyDontSeq
happyDoSeq, happyDontSeq :: a -> b -> b
happyDoSeq a b = a `seq` b
......@@ -775,7 +884,7 @@ happyDontSeq a b = b
-- of deciding to inline happyGoto everywhere, which increases the size of
-- the generated parser quite a bit.
{-# LINE 300 "GenericTemplate.hs" #-}
{-# LINE 322 "templates/GenericTemplate.hs" #-}
{-# NOINLINE happyShift #-}
{-# NOINLINE happySpecReduce_0 #-}
{-# NOINLINE happySpecReduce_1 #-}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment