Added support for subtraction
This commit is contained in:
parent
f8d320bb6d
commit
026949ae7e
25 changed files with 864 additions and 4511 deletions
|
|
@ -6,6 +6,7 @@ EId. Exp3 ::= Ident ;
|
|||
EInt. Exp3 ::= Integer ;
|
||||
EApp. Exp2 ::= Exp2 Exp3 ;
|
||||
EAdd. Exp1 ::= Exp1 "+" Exp2 ;
|
||||
ESub. Exp1 ::= Exp1 "-" Exp2 ;
|
||||
EAbs. Exp ::= "\\" Ident "->" Exp ;
|
||||
|
||||
coercions Exp 3 ;
|
||||
|
|
|
|||
25
Makefile
Normal file
25
Makefile
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
.PHONY : sdist clean
|
||||
|
||||
language : src/Grammar/Test
|
||||
cabal install --installdir=. --overwrite-policy=always
|
||||
|
||||
src/Grammar/Test.hs src/Grammar/Lex.x src/Grammar/Par.y : Grammar.cf
|
||||
bnfc -o src -d $<
|
||||
|
||||
src/Grammar/Par.hs : src/Grammar/Par.y
|
||||
happy --ghc --coerce --array --info $<
|
||||
|
||||
src/Grammar/Lex.hs : src/Grammar/Lex.x
|
||||
alex --ghc $<
|
||||
|
||||
src/Grammar/%.y : Grammar.cf
|
||||
bnfc -o src -d $<
|
||||
|
||||
src/Grammar/Test : src/Grammar/Test.hs src/Grammar/Par.hs src/Grammar/Lex.hs
|
||||
ghc src/Grammar/Test.hs src/Grammar/Par.hs src/Grammar/Lex.hs src/Grammar/Abs.hs src/Grammar/Skel.hs src/Grammar/Print.hs -o src/Grammar/test
|
||||
|
||||
clean :
|
||||
rm -r src/Grammar
|
||||
rm language
|
||||
|
||||
# EOF
|
||||
1
language
Symbolic link
1
language
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/home/samuel/.cabal/store/ghc-9.4.4/language-0.1.0.0-e-language-80436b2c1d93bf52fad22442b35609fca17123af17fcd9d9251ea49ce5440bf0/bin/language
|
||||
|
|
@ -65,6 +65,7 @@ data LLVMIr = Define Type Ident Params
|
|||
| Declare Type Ident Params
|
||||
| Variable Ident
|
||||
| Add Type Value Value
|
||||
| Sub Type Value Value
|
||||
| Call Type Ident Args
|
||||
| Alloca Type
|
||||
| Store Type Ident Type Ident
|
||||
|
|
@ -80,6 +81,7 @@ printLLVMIr DefineEnd = "}\n"
|
|||
printLLVMIr (Declare t (Ident i) params) = undefined
|
||||
printLLVMIr (Variable (Ident i)) = concat ["%", i, " = "]
|
||||
printLLVMIr (Add t v1 v2) = concat ["add ", show t, " ", show v1, ", ", show v2, "\n"]
|
||||
printLLVMIr (Sub t v1 v2) = concat ["sub ", show t, " ", show v1, ", ", show v2, "\n"]
|
||||
printLLVMIr (Call t (Ident i) arg) = concat ["call ", show t, " @", i, "("
|
||||
, concatMap (\(x,y) -> show x <> " " <> show y) arg
|
||||
, ")\n"]
|
||||
|
|
@ -126,6 +128,7 @@ compile (Program prgE) = do
|
|||
go :: Exp -> CompilerState
|
||||
go (EInt int) = emitInt int
|
||||
go (EAdd e1 e2) = emitAdd e1 e2
|
||||
go (ESub e1 e2) = emitSub e1 e2
|
||||
go (EId id) = undefined
|
||||
go (EApp e1 e2) = undefined
|
||||
go (EAbs id e) = undefined
|
||||
|
|
@ -144,7 +147,22 @@ compile (Program prgE) = do
|
|||
emitAdd e1 e2 = do
|
||||
-- instead of declaring variables for adding ints,
|
||||
-- we can directly pass them to add.
|
||||
(v1,v2) <- case (e1, e2) of
|
||||
(v1,v2) <- evalToValues e1 e2
|
||||
increaseVarCount
|
||||
v <- gets variableCount
|
||||
emit $ Variable $ Ident $ show v
|
||||
emit $ Add I64 v1 v2
|
||||
|
||||
emitSub :: Exp -> Exp -> CompilerState
|
||||
emitSub e1 e2 = do
|
||||
(v1,v2) <- evalToValues e1 e2
|
||||
increaseVarCount
|
||||
v <- gets variableCount
|
||||
emit $ Variable $ Ident $ show v
|
||||
emit $ Sub I64 v1 v2
|
||||
|
||||
evalToValues :: Exp -> Exp -> State CodeGenerator (Value, Value)
|
||||
evalToValues e1 e2 = case (e1, e2) of
|
||||
(EInt i1, EInt i2) -> return (VInteger i1, VInteger i2)
|
||||
(EInt i, e) -> do
|
||||
go e
|
||||
|
|
@ -160,8 +178,3 @@ compile (Program prgE) = do
|
|||
go e2
|
||||
v2 <- gets variableCount
|
||||
return (VIdent (Ident $ show v1),VIdent (Ident $ show v2))
|
||||
increaseVarCount
|
||||
v <- gets variableCount
|
||||
emit $ Variable $ Ident $ show v
|
||||
emit $ Add I64 v1 v2
|
||||
|
||||
|
|
|
|||
BIN
src/Grammar/Abs.hi
Normal file
BIN
src/Grammar/Abs.hi
Normal file
Binary file not shown.
|
|
@ -18,6 +18,7 @@ data Exp
|
|||
| EInt Integer
|
||||
| EApp Exp Exp
|
||||
| EAdd Exp Exp
|
||||
| ESub Exp Exp
|
||||
| EAbs Ident Exp
|
||||
deriving (C.Eq, C.Ord, C.Show, C.Read)
|
||||
|
||||
|
|
|
|||
BIN
src/Grammar/Abs.o
Normal file
BIN
src/Grammar/Abs.o
Normal file
Binary file not shown.
|
|
@ -28,8 +28,8 @@ The reserved words used in Grammar are the following:
|
|||
| ``main`` | | |
|
||||
|
||||
The symbols used in Grammar are the following:
|
||||
| = | + | \ | ->
|
||||
| ( | ) | |
|
||||
| = | + | - | \
|
||||
| -> | ( | ) |
|
||||
|
||||
===Comments===
|
||||
Single-line comments begin with --.Multiple-line comments are enclosed with {- and -}.
|
||||
|
|
@ -47,6 +47,7 @@ All other symbols are terminals.
|
|||
| //Exp2// | -> | //Exp2// //Exp3//
|
||||
| | **|** | //Exp3//
|
||||
| //Exp1// | -> | //Exp1// ``+`` //Exp2//
|
||||
| | **|** | //Exp1// ``-`` //Exp2//
|
||||
| | **|** | //Exp2//
|
||||
| //Exp// | -> | ``\`` //Ident// ``->`` //Exp//
|
||||
| | **|** | //Exp1//
|
||||
|
|
|
|||
BIN
src/Grammar/Lex.hi
Normal file
BIN
src/Grammar/Lex.hi
Normal file
Binary file not shown.
4077
src/Grammar/Lex.hs
4077
src/Grammar/Lex.hs
File diff suppressed because one or more lines are too long
BIN
src/Grammar/Lex.o
Normal file
BIN
src/Grammar/Lex.o
Normal file
Binary file not shown.
BIN
src/Grammar/Par.hi
Normal file
BIN
src/Grammar/Par.hi
Normal file
Binary file not shown.
|
|
@ -1,4 +1,8 @@
|
|||
{-# OPTIONS_GHC -w #-}
|
||||
{-# OPTIONS -XMagicHash -XBangPatterns -XTypeSynonymInstances -XFlexibleInstances -cpp #-}
|
||||
#if __GLASGOW_HASKELL__ >= 710
|
||||
{-# OPTIONS_GHC -XPartialTypeSignatures #-}
|
||||
#endif
|
||||
{-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-}
|
||||
{-# LANGUAGE PatternSynonyms #-}
|
||||
|
||||
|
|
@ -14,389 +18,260 @@ module Grammar.Par
|
|||
|
||||
import Prelude
|
||||
|
||||
import qualified Grammar.Abs as Abs
|
||||
--import qualified Grammar.Lex as Lex
|
||||
import Grammar.Lex ( pattern TS, prToken, tokenPos, tokens, Tok(TI, TV), Token(..) )
|
||||
import qualified Grammar.Abs
|
||||
import Grammar.Lex
|
||||
import qualified Data.Array as Happy_Data_Array
|
||||
import qualified Data.Bits as Bits
|
||||
import qualified GHC.Exts as Happy_GHC_Exts
|
||||
import Control.Applicative(Applicative(..))
|
||||
import Control.Monad (ap)
|
||||
|
||||
-- parser produced by Happy Version 1.20.0
|
||||
|
||||
data HappyAbsSyn
|
||||
= HappyTerminal (Token)
|
||||
| HappyErrorToken Prelude.Int
|
||||
| HappyAbsSyn8 (Abs.Ident)
|
||||
| HappyAbsSyn9 (Integer)
|
||||
| HappyAbsSyn10 (Abs.Program)
|
||||
| HappyAbsSyn11 (Abs.Exp)
|
||||
newtype HappyAbsSyn = HappyAbsSyn HappyAny
|
||||
#if __GLASGOW_HASKELL__ >= 607
|
||||
type HappyAny = Happy_GHC_Exts.Any
|
||||
#else
|
||||
type HappyAny = forall a . a
|
||||
#endif
|
||||
newtype HappyWrap8 = HappyWrap8 (Grammar.Abs.Ident)
|
||||
happyIn8 :: (Grammar.Abs.Ident) -> (HappyAbsSyn )
|
||||
happyIn8 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap8 x)
|
||||
{-# INLINE happyIn8 #-}
|
||||
happyOut8 :: (HappyAbsSyn ) -> HappyWrap8
|
||||
happyOut8 x = Happy_GHC_Exts.unsafeCoerce# x
|
||||
{-# INLINE happyOut8 #-}
|
||||
newtype HappyWrap9 = HappyWrap9 (Integer)
|
||||
happyIn9 :: (Integer) -> (HappyAbsSyn )
|
||||
happyIn9 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap9 x)
|
||||
{-# INLINE happyIn9 #-}
|
||||
happyOut9 :: (HappyAbsSyn ) -> HappyWrap9
|
||||
happyOut9 x = Happy_GHC_Exts.unsafeCoerce# x
|
||||
{-# INLINE happyOut9 #-}
|
||||
newtype HappyWrap10 = HappyWrap10 (Grammar.Abs.Program)
|
||||
happyIn10 :: (Grammar.Abs.Program) -> (HappyAbsSyn )
|
||||
happyIn10 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap10 x)
|
||||
{-# INLINE happyIn10 #-}
|
||||
happyOut10 :: (HappyAbsSyn ) -> HappyWrap10
|
||||
happyOut10 x = Happy_GHC_Exts.unsafeCoerce# x
|
||||
{-# INLINE happyOut10 #-}
|
||||
newtype HappyWrap11 = HappyWrap11 (Grammar.Abs.Exp)
|
||||
happyIn11 :: (Grammar.Abs.Exp) -> (HappyAbsSyn )
|
||||
happyIn11 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap11 x)
|
||||
{-# INLINE happyIn11 #-}
|
||||
happyOut11 :: (HappyAbsSyn ) -> HappyWrap11
|
||||
happyOut11 x = Happy_GHC_Exts.unsafeCoerce# x
|
||||
{-# INLINE happyOut11 #-}
|
||||
newtype HappyWrap12 = HappyWrap12 (Grammar.Abs.Exp)
|
||||
happyIn12 :: (Grammar.Abs.Exp) -> (HappyAbsSyn )
|
||||
happyIn12 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap12 x)
|
||||
{-# INLINE happyIn12 #-}
|
||||
happyOut12 :: (HappyAbsSyn ) -> HappyWrap12
|
||||
happyOut12 x = Happy_GHC_Exts.unsafeCoerce# x
|
||||
{-# INLINE happyOut12 #-}
|
||||
newtype HappyWrap13 = HappyWrap13 (Grammar.Abs.Exp)
|
||||
happyIn13 :: (Grammar.Abs.Exp) -> (HappyAbsSyn )
|
||||
happyIn13 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap13 x)
|
||||
{-# INLINE happyIn13 #-}
|
||||
happyOut13 :: (HappyAbsSyn ) -> HappyWrap13
|
||||
happyOut13 x = Happy_GHC_Exts.unsafeCoerce# x
|
||||
{-# INLINE happyOut13 #-}
|
||||
newtype HappyWrap14 = HappyWrap14 (Grammar.Abs.Exp)
|
||||
happyIn14 :: (Grammar.Abs.Exp) -> (HappyAbsSyn )
|
||||
happyIn14 x = Happy_GHC_Exts.unsafeCoerce# (HappyWrap14 x)
|
||||
{-# INLINE happyIn14 #-}
|
||||
happyOut14 :: (HappyAbsSyn ) -> HappyWrap14
|
||||
happyOut14 x = Happy_GHC_Exts.unsafeCoerce# x
|
||||
{-# INLINE happyOut14 #-}
|
||||
happyInTok :: (Token) -> (HappyAbsSyn )
|
||||
happyInTok x = Happy_GHC_Exts.unsafeCoerce# x
|
||||
{-# INLINE happyInTok #-}
|
||||
happyOutTok :: (HappyAbsSyn ) -> (Token)
|
||||
happyOutTok x = Happy_GHC_Exts.unsafeCoerce# x
|
||||
{-# INLINE happyOutTok #-}
|
||||
|
||||
{- 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 =
|
||||
Prelude.Int
|
||||
-> (Token)
|
||||
-> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> m HappyAbsSyn)
|
||||
-> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> m HappyAbsSyn)]
|
||||
-> HappyStk HappyAbsSyn
|
||||
-> [(Token)] -> m HappyAbsSyn
|
||||
-}
|
||||
|
||||
action_0,
|
||||
action_1,
|
||||
action_2,
|
||||
action_3,
|
||||
action_4,
|
||||
action_5,
|
||||
action_6,
|
||||
action_7,
|
||||
action_8,
|
||||
action_9,
|
||||
action_10,
|
||||
action_11,
|
||||
action_12,
|
||||
action_13,
|
||||
action_14,
|
||||
action_15,
|
||||
action_16,
|
||||
action_17,
|
||||
action_18,
|
||||
action_19,
|
||||
action_20,
|
||||
action_21,
|
||||
action_22,
|
||||
action_23,
|
||||
action_24,
|
||||
action_25,
|
||||
action_26,
|
||||
action_27,
|
||||
action_28,
|
||||
action_29,
|
||||
action_30 :: () => Prelude.Int -> ({-HappyReduction (Err) = -}
|
||||
Prelude.Int
|
||||
-> (Token)
|
||||
-> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn)
|
||||
-> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn)]
|
||||
-> HappyStk HappyAbsSyn
|
||||
-> [(Token)] -> (Err) HappyAbsSyn)
|
||||
|
||||
happyReduce_5,
|
||||
happyReduce_6,
|
||||
happyReduce_7,
|
||||
happyReduce_8,
|
||||
happyReduce_9,
|
||||
happyReduce_10,
|
||||
happyReduce_11,
|
||||
happyReduce_12,
|
||||
happyReduce_13,
|
||||
happyReduce_14,
|
||||
happyReduce_15,
|
||||
happyReduce_16 :: () => ({-HappyReduction (Err) = -}
|
||||
Prelude.Int
|
||||
-> (Token)
|
||||
-> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn)
|
||||
-> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn)]
|
||||
-> HappyStk HappyAbsSyn
|
||||
-> [(Token)] -> (Err) HappyAbsSyn)
|
||||
|
||||
happyExpList :: Happy_Data_Array.Array Prelude.Int Prelude.Int
|
||||
happyExpList = Happy_Data_Array.listArray (0,76) ([0,16,24640,16384,96,24640,16384,104,8192,0,0,0,0,0,0,16384,96,256,0,0,26688,0,32,0,0,1,24640,0,0,0,0,4,26688,0,0,24640,0,2,128,0,0,26688,16384,96,0,0,0,0
|
||||
])
|
||||
happyExpList :: HappyAddr
|
||||
happyExpList = HappyA# "\x00\x00\x20\x00\x80\x80\x01\x00\x01\x03\x00\x02\x06\x00\x04\x0d\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x18\x00\x00\x00\x00\x00\x08\x1a\x00\x00\x10\x00\x00\x00\x00\x00\x03\x00\x80\x80\x01\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x08\x1a\x00\x00\x00\x00\x20\x60\x00\x40\xc0\x00\x00\x08\x00\x00\x02\x00\x00\x00\x00\x00\x04\x0d\x00\x08\x18\x00\x10\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00"#
|
||||
|
||||
{-# NOINLINE happyExpListPerState #-}
|
||||
happyExpListPerState st =
|
||||
token_strs_expected
|
||||
where token_strs = ["error","%dummy","%start_pProgram","%start_pExp3","%start_pExp2","%start_pExp1","%start_pExp","Ident","Integer","Program","Exp3","Exp2","Exp1","Exp","'('","')'","'+'","'->'","'='","'\\\\'","'main'","L_Ident","L_integ","%eof"]
|
||||
bit_start = st Prelude.* 24
|
||||
bit_end = (st Prelude.+ 1) Prelude.* 24
|
||||
where token_strs = ["error","%dummy","%start_pProgram","%start_pExp3","%start_pExp2","%start_pExp1","%start_pExp","Ident","Integer","Program","Exp3","Exp2","Exp1","Exp","'('","')'","'+'","'-'","'->'","'='","'\\\\'","'main'","L_Ident","L_integ","%eof"]
|
||||
bit_start = st Prelude.* 25
|
||||
bit_end = (st Prelude.+ 1) Prelude.* 25
|
||||
read_bit = readArrayBit happyExpList
|
||||
bits = Prelude.map read_bit [bit_start..bit_end Prelude.- 1]
|
||||
bits_indexed = Prelude.zip bits [0..23]
|
||||
bits_indexed = Prelude.zip bits [0..24]
|
||||
token_strs_expected = Prelude.concatMap f bits_indexed
|
||||
f (Prelude.False, _) = []
|
||||
f (Prelude.True, nr) = [token_strs Prelude.!! nr]
|
||||
|
||||
action_0 (21) = happyShift action_20
|
||||
action_0 (10) = happyGoto action_19
|
||||
action_0 _ = happyFail (happyExpListPerState 0)
|
||||
happyActOffsets :: HappyAddr
|
||||
happyActOffsets = HappyA# "\xf9\xff\x08\x00\x08\x00\x08\x00\x06\x00\xfc\xff\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x47\x00\xfd\xff\x06\x00\x05\x00\x00\x00\x10\x00\x01\x00\x0c\x00\x0c\x00\x1c\x00\x06\x00\x00\x00\x08\x00\x08\x00\x24\x00\x4a\x00\x00\x00\x06\x00\x08\x00\x08\x00\x00\x00\x00\x00\x00\x00"#
|
||||
|
||||
action_1 (15) = happyShift action_13
|
||||
action_1 (22) = happyShift action_6
|
||||
action_1 (23) = happyShift action_15
|
||||
action_1 (8) = happyGoto action_7
|
||||
action_1 (9) = happyGoto action_8
|
||||
action_1 (11) = happyGoto action_18
|
||||
action_1 _ = happyFail (happyExpListPerState 1)
|
||||
happyGotoOffsets :: HappyAddr
|
||||
happyGotoOffsets = HappyA# "\x4b\x00\x03\x00\x3b\x00\x35\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15\x00\x00\x00\x00\x00\x20\x00\x30\x00\x00\x00\x00\x00\x15\x00\x00\x00\x00\x00\x00\x00\x27\x00\x00\x00\x40\x00\x45\x00\x00\x00\x00\x00\x00\x00\x2e\x00\x15\x00\x15\x00\x00\x00\x00\x00\x00\x00"#
|
||||
|
||||
action_2 (15) = happyShift action_13
|
||||
action_2 (22) = happyShift action_6
|
||||
action_2 (23) = happyShift action_15
|
||||
action_2 (8) = happyGoto action_7
|
||||
action_2 (9) = happyGoto action_8
|
||||
action_2 (11) = happyGoto action_9
|
||||
action_2 (12) = happyGoto action_17
|
||||
action_2 _ = happyFail (happyExpListPerState 2)
|
||||
happyAdjustOffset :: Happy_GHC_Exts.Int# -> Happy_GHC_Exts.Int#
|
||||
happyAdjustOffset off = off
|
||||
|
||||
action_3 (15) = happyShift action_13
|
||||
action_3 (22) = happyShift action_6
|
||||
action_3 (23) = happyShift action_15
|
||||
action_3 (8) = happyGoto action_7
|
||||
action_3 (9) = happyGoto action_8
|
||||
action_3 (11) = happyGoto action_9
|
||||
action_3 (12) = happyGoto action_10
|
||||
action_3 (13) = happyGoto action_16
|
||||
action_3 _ = happyFail (happyExpListPerState 3)
|
||||
happyDefActions :: HappyAddr
|
||||
happyDefActions = HappyA# "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfa\xff\xf7\xff\xf6\xff\xf3\xff\xf0\xff\xee\xff\x00\x00\x00\x00\x00\x00\xf9\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\xff\x00\x00\x00\x00\x00\x00\x00\x00\xf5\xff\x00\x00\xf1\xff\xf2\xff\xf8\xff\xef\xff"#
|
||||
|
||||
action_4 (15) = happyShift action_13
|
||||
action_4 (20) = happyShift action_14
|
||||
action_4 (22) = happyShift action_6
|
||||
action_4 (23) = happyShift action_15
|
||||
action_4 (8) = happyGoto action_7
|
||||
action_4 (9) = happyGoto action_8
|
||||
action_4 (11) = happyGoto action_9
|
||||
action_4 (12) = happyGoto action_10
|
||||
action_4 (13) = happyGoto action_11
|
||||
action_4 (14) = happyGoto action_12
|
||||
action_4 _ = happyFail (happyExpListPerState 4)
|
||||
happyCheck :: HappyAddr
|
||||
happyCheck = HappyA# "\xff\xff\x08\x00\x01\x00\x00\x00\x01\x00\x09\x00\x03\x00\x01\x00\x0b\x00\x01\x00\x09\x00\x0a\x00\x0b\x00\x07\x00\x09\x00\x09\x00\x0a\x00\x09\x00\x0a\x00\x03\x00\x04\x00\x00\x00\x01\x00\x0b\x00\x03\x00\x00\x00\x01\x00\x0b\x00\x03\x00\x04\x00\x05\x00\x06\x00\x00\x00\x01\x00\x06\x00\x03\x00\x04\x00\x05\x00\x06\x00\x00\x00\x01\x00\x05\x00\x03\x00\x04\x00\x05\x00\x06\x00\x00\x00\x01\x00\x00\x00\x03\x00\x04\x00\x05\x00\x06\x00\x00\x00\x01\x00\xff\xff\x03\x00\x04\x00\x05\x00\x00\x00\x01\x00\xff\xff\x03\x00\x04\x00\x00\x00\x01\x00\xff\xff\x03\x00\x04\x00\x00\x00\x01\x00\xff\xff\x03\x00\x04\x00\x03\x00\x04\x00\x02\x00\x02\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"#
|
||||
|
||||
action_5 (22) = happyShift action_6
|
||||
action_5 _ = happyFail (happyExpListPerState 5)
|
||||
happyTable :: HappyAddr
|
||||
happyTable = HappyA# "\x00\x00\x15\x00\x0e\x00\x07\x00\x08\x00\x07\x00\x12\x00\x0e\x00\xff\xff\x0e\x00\x07\x00\x10\x00\xff\xff\x0f\x00\x07\x00\x07\x00\x10\x00\x07\x00\x10\x00\x18\x00\x19\x00\x07\x00\x08\x00\xff\xff\x16\x00\x07\x00\x08\x00\xff\xff\x09\x00\x0a\x00\x0b\x00\x0c\x00\x07\x00\x08\x00\x16\x00\x09\x00\x0a\x00\x0b\x00\x1a\x00\x07\x00\x08\x00\x1d\x00\x09\x00\x0a\x00\x0b\x00\x1f\x00\x07\x00\x08\x00\x19\x00\x09\x00\x0a\x00\x0b\x00\x20\x00\x07\x00\x08\x00\x00\x00\x09\x00\x0a\x00\x10\x00\x07\x00\x08\x00\x00\x00\x09\x00\x11\x00\x07\x00\x08\x00\x00\x00\x09\x00\x1e\x00\x07\x00\x08\x00\x00\x00\x09\x00\x1d\x00\x18\x00\x19\x00\x1c\x00\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"#
|
||||
|
||||
action_6 _ = happyReduce_5
|
||||
happyReduceArr = Happy_Data_Array.array (5, 17) [
|
||||
(5 , happyReduce_5),
|
||||
(6 , happyReduce_6),
|
||||
(7 , happyReduce_7),
|
||||
(8 , happyReduce_8),
|
||||
(9 , happyReduce_9),
|
||||
(10 , happyReduce_10),
|
||||
(11 , happyReduce_11),
|
||||
(12 , happyReduce_12),
|
||||
(13 , happyReduce_13),
|
||||
(14 , happyReduce_14),
|
||||
(15 , happyReduce_15),
|
||||
(16 , happyReduce_16),
|
||||
(17 , happyReduce_17)
|
||||
]
|
||||
|
||||
action_7 _ = happyReduce_8
|
||||
happy_n_terms = 12 :: Prelude.Int
|
||||
happy_n_nonterms = 7 :: Prelude.Int
|
||||
|
||||
action_8 _ = happyReduce_9
|
||||
happyReduce_5 = happySpecReduce_1 0# happyReduction_5
|
||||
happyReduction_5 happy_x_1
|
||||
= case happyOutTok happy_x_1 of { (PT _ (TV happy_var_1)) ->
|
||||
happyIn8
|
||||
(Grammar.Abs.Ident happy_var_1
|
||||
)}
|
||||
|
||||
action_9 _ = happyReduce_12
|
||||
|
||||
action_10 (15) = happyShift action_13
|
||||
action_10 (22) = happyShift action_6
|
||||
action_10 (23) = happyShift action_15
|
||||
action_10 (8) = happyGoto action_7
|
||||
action_10 (9) = happyGoto action_8
|
||||
action_10 (11) = happyGoto action_22
|
||||
action_10 _ = happyReduce_14
|
||||
|
||||
action_11 (17) = happyShift action_23
|
||||
action_11 _ = happyReduce_16
|
||||
|
||||
action_12 (24) = happyAccept
|
||||
action_12 _ = happyFail (happyExpListPerState 12)
|
||||
|
||||
action_13 (15) = happyShift action_13
|
||||
action_13 (20) = happyShift action_14
|
||||
action_13 (22) = happyShift action_6
|
||||
action_13 (23) = happyShift action_15
|
||||
action_13 (8) = happyGoto action_7
|
||||
action_13 (9) = happyGoto action_8
|
||||
action_13 (11) = happyGoto action_9
|
||||
action_13 (12) = happyGoto action_10
|
||||
action_13 (13) = happyGoto action_11
|
||||
action_13 (14) = happyGoto action_25
|
||||
action_13 _ = happyFail (happyExpListPerState 13)
|
||||
|
||||
action_14 (22) = happyShift action_6
|
||||
action_14 (8) = happyGoto action_24
|
||||
action_14 _ = happyFail (happyExpListPerState 14)
|
||||
|
||||
action_15 _ = happyReduce_6
|
||||
|
||||
action_16 (17) = happyShift action_23
|
||||
action_16 (24) = happyAccept
|
||||
action_16 _ = happyFail (happyExpListPerState 16)
|
||||
|
||||
action_17 (15) = happyShift action_13
|
||||
action_17 (22) = happyShift action_6
|
||||
action_17 (23) = happyShift action_15
|
||||
action_17 (24) = happyAccept
|
||||
action_17 (8) = happyGoto action_7
|
||||
action_17 (9) = happyGoto action_8
|
||||
action_17 (11) = happyGoto action_22
|
||||
action_17 _ = happyFail (happyExpListPerState 17)
|
||||
|
||||
action_18 (24) = happyAccept
|
||||
action_18 _ = happyFail (happyExpListPerState 18)
|
||||
|
||||
action_19 (24) = happyAccept
|
||||
action_19 _ = happyFail (happyExpListPerState 19)
|
||||
|
||||
action_20 (19) = happyShift action_21
|
||||
action_20 _ = happyFail (happyExpListPerState 20)
|
||||
|
||||
action_21 (15) = happyShift action_13
|
||||
action_21 (20) = happyShift action_14
|
||||
action_21 (22) = happyShift action_6
|
||||
action_21 (23) = happyShift action_15
|
||||
action_21 (8) = happyGoto action_7
|
||||
action_21 (9) = happyGoto action_8
|
||||
action_21 (11) = happyGoto action_9
|
||||
action_21 (12) = happyGoto action_10
|
||||
action_21 (13) = happyGoto action_11
|
||||
action_21 (14) = happyGoto action_29
|
||||
action_21 _ = happyFail (happyExpListPerState 21)
|
||||
|
||||
action_22 _ = happyReduce_11
|
||||
|
||||
action_23 (15) = happyShift action_13
|
||||
action_23 (22) = happyShift action_6
|
||||
action_23 (23) = happyShift action_15
|
||||
action_23 (8) = happyGoto action_7
|
||||
action_23 (9) = happyGoto action_8
|
||||
action_23 (11) = happyGoto action_9
|
||||
action_23 (12) = happyGoto action_28
|
||||
action_23 _ = happyFail (happyExpListPerState 23)
|
||||
|
||||
action_24 (18) = happyShift action_27
|
||||
action_24 _ = happyFail (happyExpListPerState 24)
|
||||
|
||||
action_25 (16) = happyShift action_26
|
||||
action_25 _ = happyFail (happyExpListPerState 25)
|
||||
|
||||
action_26 _ = happyReduce_10
|
||||
|
||||
action_27 (15) = happyShift action_13
|
||||
action_27 (20) = happyShift action_14
|
||||
action_27 (22) = happyShift action_6
|
||||
action_27 (23) = happyShift action_15
|
||||
action_27 (8) = happyGoto action_7
|
||||
action_27 (9) = happyGoto action_8
|
||||
action_27 (11) = happyGoto action_9
|
||||
action_27 (12) = happyGoto action_10
|
||||
action_27 (13) = happyGoto action_11
|
||||
action_27 (14) = happyGoto action_30
|
||||
action_27 _ = happyFail (happyExpListPerState 27)
|
||||
|
||||
action_28 (15) = happyShift action_13
|
||||
action_28 (22) = happyShift action_6
|
||||
action_28 (23) = happyShift action_15
|
||||
action_28 (8) = happyGoto action_7
|
||||
action_28 (9) = happyGoto action_8
|
||||
action_28 (11) = happyGoto action_22
|
||||
action_28 _ = happyReduce_13
|
||||
|
||||
action_29 _ = happyReduce_7
|
||||
|
||||
action_30 _ = happyReduce_15
|
||||
|
||||
happyReduce_5 = happySpecReduce_1 8 happyReduction_5
|
||||
happyReduction_5 (HappyTerminal (PT _ (TV happy_var_1)))
|
||||
= HappyAbsSyn8
|
||||
(Abs.Ident happy_var_1
|
||||
)
|
||||
happyReduction_5 _ = notHappyAtAll
|
||||
|
||||
happyReduce_6 = happySpecReduce_1 9 happyReduction_6
|
||||
happyReduction_6 (HappyTerminal (PT _ (TI happy_var_1)))
|
||||
= HappyAbsSyn9
|
||||
happyReduce_6 = happySpecReduce_1 1# happyReduction_6
|
||||
happyReduction_6 happy_x_1
|
||||
= case happyOutTok happy_x_1 of { (PT _ (TI happy_var_1)) ->
|
||||
happyIn9
|
||||
((read happy_var_1) :: Integer
|
||||
)
|
||||
happyReduction_6 _ = notHappyAtAll
|
||||
)}
|
||||
|
||||
happyReduce_7 = happySpecReduce_3 10 happyReduction_7
|
||||
happyReduction_7 (HappyAbsSyn11 happy_var_3)
|
||||
_
|
||||
_
|
||||
= HappyAbsSyn10
|
||||
(Abs.Program happy_var_3
|
||||
)
|
||||
happyReduction_7 _ _ _ = notHappyAtAll
|
||||
happyReduce_7 = happySpecReduce_3 2# happyReduction_7
|
||||
happyReduction_7 happy_x_3
|
||||
happy_x_2
|
||||
happy_x_1
|
||||
= case happyOut14 happy_x_3 of { (HappyWrap14 happy_var_3) ->
|
||||
happyIn10
|
||||
(Grammar.Abs.Program happy_var_3
|
||||
)}
|
||||
|
||||
happyReduce_8 = happySpecReduce_1 11 happyReduction_8
|
||||
happyReduction_8 (HappyAbsSyn8 happy_var_1)
|
||||
= HappyAbsSyn11
|
||||
(Abs.EId happy_var_1
|
||||
)
|
||||
happyReduction_8 _ = notHappyAtAll
|
||||
happyReduce_8 = happySpecReduce_1 3# happyReduction_8
|
||||
happyReduction_8 happy_x_1
|
||||
= case happyOut8 happy_x_1 of { (HappyWrap8 happy_var_1) ->
|
||||
happyIn11
|
||||
(Grammar.Abs.EId happy_var_1
|
||||
)}
|
||||
|
||||
happyReduce_9 = happySpecReduce_1 11 happyReduction_9
|
||||
happyReduction_9 (HappyAbsSyn9 happy_var_1)
|
||||
= HappyAbsSyn11
|
||||
(Abs.EInt happy_var_1
|
||||
)
|
||||
happyReduction_9 _ = notHappyAtAll
|
||||
happyReduce_9 = happySpecReduce_1 3# happyReduction_9
|
||||
happyReduction_9 happy_x_1
|
||||
= case happyOut9 happy_x_1 of { (HappyWrap9 happy_var_1) ->
|
||||
happyIn11
|
||||
(Grammar.Abs.EInt happy_var_1
|
||||
)}
|
||||
|
||||
happyReduce_10 = happySpecReduce_3 11 happyReduction_10
|
||||
happyReduction_10 _
|
||||
(HappyAbsSyn11 happy_var_2)
|
||||
_
|
||||
= HappyAbsSyn11
|
||||
happyReduce_10 = happySpecReduce_3 3# happyReduction_10
|
||||
happyReduction_10 happy_x_3
|
||||
happy_x_2
|
||||
happy_x_1
|
||||
= case happyOut14 happy_x_2 of { (HappyWrap14 happy_var_2) ->
|
||||
happyIn11
|
||||
(happy_var_2
|
||||
)
|
||||
happyReduction_10 _ _ _ = notHappyAtAll
|
||||
)}
|
||||
|
||||
happyReduce_11 = happySpecReduce_2 12 happyReduction_11
|
||||
happyReduction_11 (HappyAbsSyn11 happy_var_2)
|
||||
(HappyAbsSyn11 happy_var_1)
|
||||
= HappyAbsSyn11
|
||||
(Abs.EApp happy_var_1 happy_var_2
|
||||
)
|
||||
happyReduction_11 _ _ = notHappyAtAll
|
||||
happyReduce_11 = happySpecReduce_2 4# happyReduction_11
|
||||
happyReduction_11 happy_x_2
|
||||
happy_x_1
|
||||
= case happyOut12 happy_x_1 of { (HappyWrap12 happy_var_1) ->
|
||||
case happyOut11 happy_x_2 of { (HappyWrap11 happy_var_2) ->
|
||||
happyIn12
|
||||
(Grammar.Abs.EApp happy_var_1 happy_var_2
|
||||
)}}
|
||||
|
||||
happyReduce_12 = happySpecReduce_1 12 happyReduction_12
|
||||
happyReduction_12 (HappyAbsSyn11 happy_var_1)
|
||||
= HappyAbsSyn11
|
||||
happyReduce_12 = happySpecReduce_1 4# happyReduction_12
|
||||
happyReduction_12 happy_x_1
|
||||
= case happyOut11 happy_x_1 of { (HappyWrap11 happy_var_1) ->
|
||||
happyIn12
|
||||
(happy_var_1
|
||||
)
|
||||
happyReduction_12 _ = notHappyAtAll
|
||||
)}
|
||||
|
||||
happyReduce_13 = happySpecReduce_3 13 happyReduction_13
|
||||
happyReduction_13 (HappyAbsSyn11 happy_var_3)
|
||||
_
|
||||
(HappyAbsSyn11 happy_var_1)
|
||||
= HappyAbsSyn11
|
||||
(Abs.EAdd happy_var_1 happy_var_3
|
||||
)
|
||||
happyReduction_13 _ _ _ = notHappyAtAll
|
||||
happyReduce_13 = happySpecReduce_3 5# happyReduction_13
|
||||
happyReduction_13 happy_x_3
|
||||
happy_x_2
|
||||
happy_x_1
|
||||
= case happyOut13 happy_x_1 of { (HappyWrap13 happy_var_1) ->
|
||||
case happyOut12 happy_x_3 of { (HappyWrap12 happy_var_3) ->
|
||||
happyIn13
|
||||
(Grammar.Abs.EAdd happy_var_1 happy_var_3
|
||||
)}}
|
||||
|
||||
happyReduce_14 = happySpecReduce_1 13 happyReduction_14
|
||||
happyReduction_14 (HappyAbsSyn11 happy_var_1)
|
||||
= HappyAbsSyn11
|
||||
happyReduce_14 = happySpecReduce_3 5# happyReduction_14
|
||||
happyReduction_14 happy_x_3
|
||||
happy_x_2
|
||||
happy_x_1
|
||||
= case happyOut13 happy_x_1 of { (HappyWrap13 happy_var_1) ->
|
||||
case happyOut12 happy_x_3 of { (HappyWrap12 happy_var_3) ->
|
||||
happyIn13
|
||||
(Grammar.Abs.ESub happy_var_1 happy_var_3
|
||||
)}}
|
||||
|
||||
happyReduce_15 = happySpecReduce_1 5# happyReduction_15
|
||||
happyReduction_15 happy_x_1
|
||||
= case happyOut12 happy_x_1 of { (HappyWrap12 happy_var_1) ->
|
||||
happyIn13
|
||||
(happy_var_1
|
||||
)
|
||||
happyReduction_14 _ = notHappyAtAll
|
||||
)}
|
||||
|
||||
happyReduce_15 = happyReduce 4 14 happyReduction_15
|
||||
happyReduction_15 ((HappyAbsSyn11 happy_var_4) `HappyStk`
|
||||
_ `HappyStk`
|
||||
(HappyAbsSyn8 happy_var_2) `HappyStk`
|
||||
_ `HappyStk`
|
||||
happyReduce_16 = happyReduce 4# 6# happyReduction_16
|
||||
happyReduction_16 (happy_x_4 `HappyStk`
|
||||
happy_x_3 `HappyStk`
|
||||
happy_x_2 `HappyStk`
|
||||
happy_x_1 `HappyStk`
|
||||
happyRest)
|
||||
= HappyAbsSyn11
|
||||
(Abs.EAbs happy_var_2 happy_var_4
|
||||
) `HappyStk` happyRest
|
||||
= case happyOut8 happy_x_2 of { (HappyWrap8 happy_var_2) ->
|
||||
case happyOut14 happy_x_4 of { (HappyWrap14 happy_var_4) ->
|
||||
happyIn14
|
||||
(Grammar.Abs.EAbs happy_var_2 happy_var_4
|
||||
) `HappyStk` happyRest}}
|
||||
|
||||
happyReduce_16 = happySpecReduce_1 14 happyReduction_16
|
||||
happyReduction_16 (HappyAbsSyn11 happy_var_1)
|
||||
= HappyAbsSyn11
|
||||
happyReduce_17 = happySpecReduce_1 6# happyReduction_17
|
||||
happyReduction_17 happy_x_1
|
||||
= case happyOut13 happy_x_1 of { (HappyWrap13 happy_var_1) ->
|
||||
happyIn14
|
||||
(happy_var_1
|
||||
)
|
||||
happyReduction_16 _ = notHappyAtAll
|
||||
)}
|
||||
|
||||
happyNewToken action sts stk [] =
|
||||
action 24 24 notHappyAtAll (HappyState action) sts stk []
|
||||
happyDoAction 11# notHappyAtAll action sts stk []
|
||||
|
||||
happyNewToken action sts stk (tk:tks) =
|
||||
let cont i = action i i tk (HappyState action) sts stk tks in
|
||||
let cont i = happyDoAction i tk action sts stk tks in
|
||||
case tk of {
|
||||
PT _ (TS _ 1) -> cont 15;
|
||||
PT _ (TS _ 2) -> cont 16;
|
||||
PT _ (TS _ 3) -> cont 17;
|
||||
PT _ (TS _ 4) -> cont 18;
|
||||
PT _ (TS _ 5) -> cont 19;
|
||||
PT _ (TS _ 6) -> cont 20;
|
||||
PT _ (TS _ 7) -> cont 21;
|
||||
PT _ (TV happy_dollar_dollar) -> cont 22;
|
||||
PT _ (TI happy_dollar_dollar) -> cont 23;
|
||||
PT _ (TS _ 1) -> cont 1#;
|
||||
PT _ (TS _ 2) -> cont 2#;
|
||||
PT _ (TS _ 3) -> cont 3#;
|
||||
PT _ (TS _ 4) -> cont 4#;
|
||||
PT _ (TS _ 5) -> cont 5#;
|
||||
PT _ (TS _ 6) -> cont 6#;
|
||||
PT _ (TS _ 7) -> cont 7#;
|
||||
PT _ (TS _ 8) -> cont 8#;
|
||||
PT _ (TV happy_dollar_dollar) -> cont 9#;
|
||||
PT _ (TI happy_dollar_dollar) -> cont 10#;
|
||||
_ -> happyError' ((tk:tks), [])
|
||||
}
|
||||
|
||||
happyError_ explist 24 tk tks = happyError' (tks, explist)
|
||||
happyError_ explist 11# tk tks = happyError' (tks, explist)
|
||||
happyError_ explist _ tk tks = happyError' ((tk:tks), explist)
|
||||
|
||||
happyThen :: () => Err a -> (a -> Err b) -> Err b
|
||||
|
|
@ -409,19 +284,19 @@ happyReturn1 = \a tks -> (return) a
|
|||
happyError' :: () => ([(Token)], [Prelude.String]) -> Err a
|
||||
happyError' = (\(tokens, _) -> happyError tokens)
|
||||
pProgram tks = happySomeParser where
|
||||
happySomeParser = happyThen (happyParse action_0 tks) (\x -> case x of {HappyAbsSyn10 z -> happyReturn z; _other -> notHappyAtAll })
|
||||
happySomeParser = happyThen (happyParse 0# tks) (\x -> happyReturn (let {(HappyWrap10 x') = happyOut10 x} in x'))
|
||||
|
||||
pExp3 tks = happySomeParser where
|
||||
happySomeParser = happyThen (happyParse action_1 tks) (\x -> case x of {HappyAbsSyn11 z -> happyReturn z; _other -> notHappyAtAll })
|
||||
happySomeParser = happyThen (happyParse 1# tks) (\x -> happyReturn (let {(HappyWrap11 x') = happyOut11 x} in x'))
|
||||
|
||||
pExp2 tks = happySomeParser where
|
||||
happySomeParser = happyThen (happyParse action_2 tks) (\x -> case x of {HappyAbsSyn11 z -> happyReturn z; _other -> notHappyAtAll })
|
||||
happySomeParser = happyThen (happyParse 2# tks) (\x -> happyReturn (let {(HappyWrap12 x') = happyOut12 x} in x'))
|
||||
|
||||
pExp1 tks = happySomeParser where
|
||||
happySomeParser = happyThen (happyParse action_3 tks) (\x -> case x of {HappyAbsSyn11 z -> happyReturn z; _other -> notHappyAtAll })
|
||||
happySomeParser = happyThen (happyParse 3# tks) (\x -> happyReturn (let {(HappyWrap13 x') = happyOut13 x} in x'))
|
||||
|
||||
pExp tks = happySomeParser where
|
||||
happySomeParser = happyThen (happyParse action_4 tks) (\x -> case x of {HappyAbsSyn11 z -> happyReturn z; _other -> notHappyAtAll })
|
||||
happySomeParser = happyThen (happyParse 4# tks) (\x -> happyReturn (let {(HappyWrap14 x') = happyOut14 x} in x'))
|
||||
|
||||
happySeq = happyDontSeq
|
||||
|
||||
|
|
@ -453,6 +328,16 @@ myLexer = tokens
|
|||
|
||||
|
||||
|
||||
-- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.
|
||||
#if __GLASGOW_HASKELL__ > 706
|
||||
#define LT(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.<# m)) :: Prelude.Bool)
|
||||
#define GTE(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.>=# m)) :: Prelude.Bool)
|
||||
#define EQ(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.==# m)) :: Prelude.Bool)
|
||||
#else
|
||||
#define LT(n,m) (n Happy_GHC_Exts.<# m)
|
||||
#define GTE(n,m) (n Happy_GHC_Exts.>=# m)
|
||||
#define EQ(n,m) (n Happy_GHC_Exts.==# m)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
@ -472,17 +357,7 @@ myLexer = tokens
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data Happy_IntList = HappyCons Prelude.Int Happy_IntList
|
||||
data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
|
||||
|
||||
|
||||
|
||||
|
|
@ -537,183 +412,178 @@ happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll
|
|||
-- If the current token is ERROR_TOK, 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` _) =
|
||||
happyAccept 0# tk st sts (_ `HappyStk` ans `HappyStk` _) =
|
||||
happyReturn1 ans
|
||||
happyAccept j tk st sts (HappyStk ans _) =
|
||||
(happyReturn1 ans)
|
||||
(happyTcHack j (happyTcHack st)) (happyReturn1 ans)
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Arrays only: do the next action
|
||||
|
||||
|
||||
|
||||
happyDoAction i tk st
|
||||
= {- nothing -}
|
||||
case action of
|
||||
0# -> {- nothing -}
|
||||
happyFail (happyExpListPerState ((Happy_GHC_Exts.I# (st)) :: Prelude.Int)) i tk st
|
||||
-1# -> {- nothing -}
|
||||
happyAccept i tk st
|
||||
n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}
|
||||
(happyReduceArr Happy_Data_Array.! rule) i tk st
|
||||
where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))
|
||||
n -> {- nothing -}
|
||||
happyShift new_state i tk st
|
||||
where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#))
|
||||
where off = happyAdjustOffset (indexShortOffAddr happyActOffsets st)
|
||||
off_i = (off Happy_GHC_Exts.+# i)
|
||||
check = if GTE(off_i,(0# :: Happy_GHC_Exts.Int#))
|
||||
then EQ(indexShortOffAddr happyCheck off_i, i)
|
||||
else Prelude.False
|
||||
action
|
||||
| check = indexShortOffAddr happyTable off_i
|
||||
| Prelude.otherwise = indexShortOffAddr happyDefActions st
|
||||
|
||||
|
||||
|
||||
|
||||
indexShortOffAddr (HappyA# arr) off =
|
||||
Happy_GHC_Exts.narrow16Int# i
|
||||
where
|
||||
i = Happy_GHC_Exts.word2Int# (Happy_GHC_Exts.or# (Happy_GHC_Exts.uncheckedShiftL# high 8#) low)
|
||||
high = Happy_GHC_Exts.int2Word# (Happy_GHC_Exts.ord# (Happy_GHC_Exts.indexCharOffAddr# arr (off' Happy_GHC_Exts.+# 1#)))
|
||||
low = Happy_GHC_Exts.int2Word# (Happy_GHC_Exts.ord# (Happy_GHC_Exts.indexCharOffAddr# arr off'))
|
||||
off' = off Happy_GHC_Exts.*# 2#
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
indexShortOffAddr arr off = arr Happy_Data_Array.! off
|
||||
|
||||
|
||||
{-# INLINE happyLt #-}
|
||||
happyLt x y = (x Prelude.< y)
|
||||
|
||||
|
||||
|
||||
|
||||
happyLt x y = LT(x,y)
|
||||
|
||||
|
||||
readArrayBit arr bit =
|
||||
Bits.testBit (indexShortOffAddr arr (bit `Prelude.div` 16)) (bit `Prelude.mod` 16)
|
||||
Bits.testBit (Happy_GHC_Exts.I# (indexShortOffAddr arr ((unbox_int bit) `Happy_GHC_Exts.iShiftRA#` 4#))) (bit `Prelude.mod` 16)
|
||||
where unbox_int (Happy_GHC_Exts.I# x) = x
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data HappyAddr = HappyA# Happy_GHC_Exts.Addr#
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- HappyState data type (not arrays)
|
||||
|
||||
|
||||
|
||||
newtype HappyState b c = HappyState
|
||||
(Prelude.Int -> -- token number
|
||||
Prelude.Int -> -- token number (yes, again)
|
||||
b -> -- token semantic value
|
||||
HappyState b c -> -- current state
|
||||
[HappyState b c] -> -- state stack
|
||||
c)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Shifting a token
|
||||
|
||||
happyShift new_state (1) tk st sts stk@(x `HappyStk` _) =
|
||||
let i = (case x of { HappyErrorToken (i) -> i }) in
|
||||
happyShift new_state 0# tk st sts stk@(x `HappyStk` _) =
|
||||
let i = (case Happy_GHC_Exts.unsafeCoerce# x of { (Happy_GHC_Exts.I# (i)) -> i }) in
|
||||
-- trace "shifting the error token" $
|
||||
new_state i i tk (HappyState (new_state)) ((st):(sts)) (stk)
|
||||
happyDoAction i tk new_state (HappyCons (st) (sts)) (stk)
|
||||
|
||||
happyShift new_state i tk st sts stk =
|
||||
happyNewToken new_state ((st):(sts)) ((HappyTerminal (tk))`HappyStk`stk)
|
||||
happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk)
|
||||
|
||||
-- happyReduce is specialised for the common cases.
|
||||
|
||||
happySpecReduce_0 i fn (1) tk st sts stk
|
||||
= happyFail [] (1) tk st sts stk
|
||||
happySpecReduce_0 nt fn j tk st@((HappyState (action))) sts stk
|
||||
= action nt j tk st ((st):(sts)) (fn `HappyStk` stk)
|
||||
happySpecReduce_0 i fn 0# tk st sts stk
|
||||
= happyFail [] 0# tk st sts stk
|
||||
happySpecReduce_0 nt fn j tk st@((action)) sts stk
|
||||
= happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk)
|
||||
|
||||
happySpecReduce_1 i fn (1) tk st sts stk
|
||||
= happyFail [] (1) tk st sts stk
|
||||
happySpecReduce_1 nt fn j tk _ sts@(((st@(HappyState (action))):(_))) (v1`HappyStk`stk')
|
||||
happySpecReduce_1 i fn 0# tk st sts stk
|
||||
= happyFail [] 0# tk st sts stk
|
||||
happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk')
|
||||
= let r = fn v1 in
|
||||
happySeq r (action nt j tk st sts (r `HappyStk` stk'))
|
||||
happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk'))
|
||||
|
||||
happySpecReduce_2 i fn (1) tk st sts stk
|
||||
= happyFail [] (1) tk st sts stk
|
||||
happySpecReduce_2 nt fn j tk _ ((_):(sts@(((st@(HappyState (action))):(_))))) (v1`HappyStk`v2`HappyStk`stk')
|
||||
happySpecReduce_2 i fn 0# tk st sts stk
|
||||
= happyFail [] 0# tk st sts stk
|
||||
happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk')
|
||||
= let r = fn v1 v2 in
|
||||
happySeq r (action nt j tk st sts (r `HappyStk` stk'))
|
||||
happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk'))
|
||||
|
||||
happySpecReduce_3 i fn (1) tk st sts stk
|
||||
= happyFail [] (1) tk st sts stk
|
||||
happySpecReduce_3 nt fn j tk _ ((_):(((_):(sts@(((st@(HappyState (action))):(_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk')
|
||||
happySpecReduce_3 i fn 0# tk st sts stk
|
||||
= happyFail [] 0# tk st sts stk
|
||||
happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk')
|
||||
= let r = fn v1 v2 v3 in
|
||||
happySeq r (action nt j tk st sts (r `HappyStk` stk'))
|
||||
happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk'))
|
||||
|
||||
happyReduce k i fn (1) tk st sts stk
|
||||
= happyFail [] (1) tk st sts stk
|
||||
happyReduce k i fn 0# tk st sts stk
|
||||
= happyFail [] 0# tk st sts stk
|
||||
happyReduce k nt fn j tk st sts stk
|
||||
= case happyDrop (k Prelude.- ((1) :: Prelude.Int)) sts of
|
||||
sts1@(((st1@(HappyState (action))):(_))) ->
|
||||
= case happyDrop (k Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) sts of
|
||||
sts1@((HappyCons (st1@(action)) (_))) ->
|
||||
let r = fn stk in -- it doesn't hurt to always seq here...
|
||||
happyDoSeq r (action nt j tk st1 sts1 r)
|
||||
happyDoSeq r (happyGoto 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 0# tk st sts stk
|
||||
= happyFail [] 0# tk st sts stk
|
||||
happyMonadReduce k nt fn j tk st sts stk =
|
||||
case happyDrop k ((st):(sts)) of
|
||||
sts1@(((st1@(HappyState (action))):(_))) ->
|
||||
case happyDrop k (HappyCons (st) (sts)) of
|
||||
sts1@((HappyCons (st1@(action)) (_))) ->
|
||||
let drop_stk = happyDropStk k stk in
|
||||
happyThen1 (fn stk tk) (\r -> action nt j tk st1 sts1 (r `HappyStk` drop_stk))
|
||||
happyThen1 (fn stk tk) (\r -> happyGoto 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 0# tk st sts stk
|
||||
= happyFail [] 0# tk st sts stk
|
||||
happyMonad2Reduce k nt fn j tk st sts stk =
|
||||
case happyDrop k ((st):(sts)) of
|
||||
sts1@(((st1@(HappyState (action))):(_))) ->
|
||||
case happyDrop k (HappyCons (st) (sts)) of
|
||||
sts1@((HappyCons (st1@(action)) (_))) ->
|
||||
let drop_stk = happyDropStk k stk
|
||||
|
||||
off = happyAdjustOffset (indexShortOffAddr happyGotoOffsets st1)
|
||||
off_i = (off Happy_GHC_Exts.+# nt)
|
||||
new_state = indexShortOffAddr happyTable off_i
|
||||
|
||||
|
||||
|
||||
|
||||
_ = nt :: Prelude.Int
|
||||
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 Prelude.- ((1) :: Prelude.Int)) t
|
||||
happyDrop 0# l = l
|
||||
happyDrop n (HappyCons (_) (t)) = happyDrop (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) t
|
||||
|
||||
happyDropStk (0) l = l
|
||||
happyDropStk n (x `HappyStk` xs) = happyDropStk (n Prelude.- ((1)::Prelude.Int)) xs
|
||||
happyDropStk 0# l = l
|
||||
happyDropStk n (x `HappyStk` xs) = happyDropStk (n Happy_GHC_Exts.-# (1#::Happy_GHC_Exts.Int#)) xs
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Moving to a new state after a reduction
|
||||
|
||||
|
||||
happyGoto nt j tk st =
|
||||
{- nothing -}
|
||||
happyDoAction j tk new_state
|
||||
where off = happyAdjustOffset (indexShortOffAddr happyGotoOffsets st)
|
||||
off_i = (off Happy_GHC_Exts.+# nt)
|
||||
new_state = indexShortOffAddr happyTable off_i
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
happyGoto action j tk st = action j j tk (HappyState action)
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Error recovery (ERROR_TOK is the error token)
|
||||
|
||||
-- parse error if we are in recovery and we fail again
|
||||
happyFail explist (1) tk old_st _ stk@(x `HappyStk` _) =
|
||||
let i = (case x of { HappyErrorToken (i) -> i }) in
|
||||
happyFail explist 0# tk old_st _ stk@(x `HappyStk` _) =
|
||||
let i = (case Happy_GHC_Exts.unsafeCoerce# x of { (Happy_GHC_Exts.I# (i)) -> i }) in
|
||||
-- trace "failing" $
|
||||
happyError_ explist i tk
|
||||
|
||||
|
|
@ -730,9 +600,9 @@ happyFail ERROR_TOK tk old_st CONS(HAPPYSTATE(action),sts)
|
|||
|
||||
-- Enter error recovery: generate an error token,
|
||||
-- save the old token and carry on.
|
||||
happyFail explist i tk (HappyState (action)) sts stk =
|
||||
happyFail explist i tk (action) sts stk =
|
||||
-- trace "entering error recovery" $
|
||||
action (1) (1) tk (HappyState (action)) sts ((HappyErrorToken (i)) `HappyStk` stk)
|
||||
happyDoAction 0# tk action sts ((Happy_GHC_Exts.unsafeCoerce# (Happy_GHC_Exts.I# (i))) `HappyStk` stk)
|
||||
|
||||
-- Internal happy errors:
|
||||
|
||||
|
|
@ -743,9 +613,9 @@ notHappyAtAll = Prelude.error "Internal Happy error\n"
|
|||
-- Hack to get the typechecker to accept our action functions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
happyTcHack :: Happy_GHC_Exts.Int# -> a -> a
|
||||
happyTcHack x y = y
|
||||
{-# INLINE happyTcHack #-}
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
|
@ -764,12 +634,12 @@ happyDontSeq a b = b
|
|||
-- the generated parser quite a bit.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{-# NOINLINE happyDoAction #-}
|
||||
{-# NOINLINE happyTable #-}
|
||||
{-# NOINLINE happyCheck #-}
|
||||
{-# NOINLINE happyActOffsets #-}
|
||||
{-# NOINLINE happyGotoOffsets #-}
|
||||
{-# NOINLINE happyDefActions #-}
|
||||
|
||||
{-# NOINLINE happyShift #-}
|
||||
{-# NOINLINE happySpecReduce_0 #-}
|
||||
|
|
|
|||
456
src/Grammar/Par.info
Normal file
456
src/Grammar/Par.info
Normal file
|
|
@ -0,0 +1,456 @@
|
|||
-----------------------------------------------------------------------------
|
||||
Info file generated by Happy Version 1.20.0 from src/Grammar/Par.y
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Grammar
|
||||
-----------------------------------------------------------------------------
|
||||
%start_pProgram -> Program (0)
|
||||
%start_pExp3 -> Exp3 (1)
|
||||
%start_pExp2 -> Exp2 (2)
|
||||
%start_pExp1 -> Exp1 (3)
|
||||
%start_pExp -> Exp (4)
|
||||
Ident -> L_Ident (5)
|
||||
Integer -> L_integ (6)
|
||||
Program -> 'main' '=' Exp (7)
|
||||
Exp3 -> Ident (8)
|
||||
Exp3 -> Integer (9)
|
||||
Exp3 -> '(' Exp ')' (10)
|
||||
Exp2 -> Exp2 Exp3 (11)
|
||||
Exp2 -> Exp3 (12)
|
||||
Exp1 -> Exp1 '+' Exp2 (13)
|
||||
Exp1 -> Exp1 '-' Exp2 (14)
|
||||
Exp1 -> Exp2 (15)
|
||||
Exp -> '\\' Ident '->' Exp (16)
|
||||
Exp -> Exp1 (17)
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Terminals
|
||||
-----------------------------------------------------------------------------
|
||||
'(' { PT _ (TS _ 1) }
|
||||
')' { PT _ (TS _ 2) }
|
||||
'+' { PT _ (TS _ 3) }
|
||||
'-' { PT _ (TS _ 4) }
|
||||
'->' { PT _ (TS _ 5) }
|
||||
'=' { PT _ (TS _ 6) }
|
||||
'\\' { PT _ (TS _ 7) }
|
||||
'main' { PT _ (TS _ 8) }
|
||||
L_Ident { PT _ (TV $$) }
|
||||
L_integ { PT _ (TI $$) }
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Non-terminals
|
||||
-----------------------------------------------------------------------------
|
||||
%start_pProgram rule 0
|
||||
%start_pExp3 rule 1
|
||||
%start_pExp2 rule 2
|
||||
%start_pExp1 rule 3
|
||||
%start_pExp rule 4
|
||||
Ident rule 5
|
||||
Integer rule 6
|
||||
Program rule 7
|
||||
Exp3 rules 8, 9, 10
|
||||
Exp2 rules 11, 12
|
||||
Exp1 rules 13, 14, 15
|
||||
Exp rules 16, 17
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
States
|
||||
-----------------------------------------------------------------------------
|
||||
State 0
|
||||
|
||||
%start_pProgram -> . Program (rule 0)
|
||||
|
||||
'main' shift, and enter state 20
|
||||
|
||||
Program goto state 19
|
||||
|
||||
State 1
|
||||
|
||||
%start_pExp3 -> . Exp3 (rule 1)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 18
|
||||
|
||||
State 2
|
||||
|
||||
%start_pExp2 -> . Exp2 (rule 2)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 9
|
||||
Exp2 goto state 17
|
||||
|
||||
State 3
|
||||
|
||||
%start_pExp1 -> . Exp1 (rule 3)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 9
|
||||
Exp2 goto state 10
|
||||
Exp1 goto state 16
|
||||
|
||||
State 4
|
||||
|
||||
%start_pExp -> . Exp (rule 4)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
'\\' shift, and enter state 14
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 9
|
||||
Exp2 goto state 10
|
||||
Exp1 goto state 11
|
||||
Exp goto state 12
|
||||
|
||||
State 5
|
||||
|
||||
Ident -> . L_Ident (rule 5)
|
||||
|
||||
L_Ident shift, and enter state 6
|
||||
|
||||
|
||||
State 6
|
||||
|
||||
Ident -> L_Ident . (rule 5)
|
||||
|
||||
'(' reduce using rule 5
|
||||
')' reduce using rule 5
|
||||
'+' reduce using rule 5
|
||||
'-' reduce using rule 5
|
||||
'->' reduce using rule 5
|
||||
L_Ident reduce using rule 5
|
||||
L_integ reduce using rule 5
|
||||
%eof reduce using rule 5
|
||||
|
||||
|
||||
State 7
|
||||
|
||||
Exp3 -> Ident . (rule 8)
|
||||
|
||||
'(' reduce using rule 8
|
||||
')' reduce using rule 8
|
||||
'+' reduce using rule 8
|
||||
'-' reduce using rule 8
|
||||
L_Ident reduce using rule 8
|
||||
L_integ reduce using rule 8
|
||||
%eof reduce using rule 8
|
||||
|
||||
|
||||
State 8
|
||||
|
||||
Exp3 -> Integer . (rule 9)
|
||||
|
||||
'(' reduce using rule 9
|
||||
')' reduce using rule 9
|
||||
'+' reduce using rule 9
|
||||
'-' reduce using rule 9
|
||||
L_Ident reduce using rule 9
|
||||
L_integ reduce using rule 9
|
||||
%eof reduce using rule 9
|
||||
|
||||
|
||||
State 9
|
||||
|
||||
Exp2 -> Exp3 . (rule 12)
|
||||
|
||||
'(' reduce using rule 12
|
||||
')' reduce using rule 12
|
||||
'+' reduce using rule 12
|
||||
'-' reduce using rule 12
|
||||
L_Ident reduce using rule 12
|
||||
L_integ reduce using rule 12
|
||||
%eof reduce using rule 12
|
||||
|
||||
|
||||
State 10
|
||||
|
||||
Exp2 -> Exp2 . Exp3 (rule 11)
|
||||
Exp1 -> Exp2 . (rule 15)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
')' reduce using rule 15
|
||||
'+' reduce using rule 15
|
||||
'-' reduce using rule 15
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
%eof reduce using rule 15
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 22
|
||||
|
||||
State 11
|
||||
|
||||
Exp1 -> Exp1 . '+' Exp2 (rule 13)
|
||||
Exp1 -> Exp1 . '-' Exp2 (rule 14)
|
||||
Exp -> Exp1 . (rule 17)
|
||||
|
||||
')' reduce using rule 17
|
||||
'+' shift, and enter state 23
|
||||
'-' shift, and enter state 24
|
||||
%eof reduce using rule 17
|
||||
|
||||
|
||||
State 12
|
||||
|
||||
%start_pExp -> Exp . (rule 4)
|
||||
|
||||
%eof accept
|
||||
|
||||
|
||||
State 13
|
||||
|
||||
Exp3 -> '(' . Exp ')' (rule 10)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
'\\' shift, and enter state 14
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 9
|
||||
Exp2 goto state 10
|
||||
Exp1 goto state 11
|
||||
Exp goto state 26
|
||||
|
||||
State 14
|
||||
|
||||
Exp -> '\\' . Ident '->' Exp (rule 16)
|
||||
|
||||
L_Ident shift, and enter state 6
|
||||
|
||||
Ident goto state 25
|
||||
|
||||
State 15
|
||||
|
||||
Integer -> L_integ . (rule 6)
|
||||
|
||||
'(' reduce using rule 6
|
||||
')' reduce using rule 6
|
||||
'+' reduce using rule 6
|
||||
'-' reduce using rule 6
|
||||
L_Ident reduce using rule 6
|
||||
L_integ reduce using rule 6
|
||||
%eof reduce using rule 6
|
||||
|
||||
|
||||
State 16
|
||||
|
||||
%start_pExp1 -> Exp1 . (rule 3)
|
||||
Exp1 -> Exp1 . '+' Exp2 (rule 13)
|
||||
Exp1 -> Exp1 . '-' Exp2 (rule 14)
|
||||
|
||||
'+' shift, and enter state 23
|
||||
'-' shift, and enter state 24
|
||||
%eof accept
|
||||
|
||||
|
||||
State 17
|
||||
|
||||
%start_pExp2 -> Exp2 . (rule 2)
|
||||
Exp2 -> Exp2 . Exp3 (rule 11)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
%eof accept
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 22
|
||||
|
||||
State 18
|
||||
|
||||
%start_pExp3 -> Exp3 . (rule 1)
|
||||
|
||||
%eof accept
|
||||
|
||||
|
||||
State 19
|
||||
|
||||
%start_pProgram -> Program . (rule 0)
|
||||
|
||||
%eof accept
|
||||
|
||||
|
||||
State 20
|
||||
|
||||
Program -> 'main' . '=' Exp (rule 7)
|
||||
|
||||
'=' shift, and enter state 21
|
||||
|
||||
|
||||
State 21
|
||||
|
||||
Program -> 'main' '=' . Exp (rule 7)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
'\\' shift, and enter state 14
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 9
|
||||
Exp2 goto state 10
|
||||
Exp1 goto state 11
|
||||
Exp goto state 31
|
||||
|
||||
State 22
|
||||
|
||||
Exp2 -> Exp2 Exp3 . (rule 11)
|
||||
|
||||
'(' reduce using rule 11
|
||||
')' reduce using rule 11
|
||||
'+' reduce using rule 11
|
||||
'-' reduce using rule 11
|
||||
L_Ident reduce using rule 11
|
||||
L_integ reduce using rule 11
|
||||
%eof reduce using rule 11
|
||||
|
||||
|
||||
State 23
|
||||
|
||||
Exp1 -> Exp1 '+' . Exp2 (rule 13)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 9
|
||||
Exp2 goto state 30
|
||||
|
||||
State 24
|
||||
|
||||
Exp1 -> Exp1 '-' . Exp2 (rule 14)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 9
|
||||
Exp2 goto state 29
|
||||
|
||||
State 25
|
||||
|
||||
Exp -> '\\' Ident . '->' Exp (rule 16)
|
||||
|
||||
'->' shift, and enter state 28
|
||||
|
||||
|
||||
State 26
|
||||
|
||||
Exp3 -> '(' Exp . ')' (rule 10)
|
||||
|
||||
')' shift, and enter state 27
|
||||
|
||||
|
||||
State 27
|
||||
|
||||
Exp3 -> '(' Exp ')' . (rule 10)
|
||||
|
||||
'(' reduce using rule 10
|
||||
')' reduce using rule 10
|
||||
'+' reduce using rule 10
|
||||
'-' reduce using rule 10
|
||||
L_Ident reduce using rule 10
|
||||
L_integ reduce using rule 10
|
||||
%eof reduce using rule 10
|
||||
|
||||
|
||||
State 28
|
||||
|
||||
Exp -> '\\' Ident '->' . Exp (rule 16)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
'\\' shift, and enter state 14
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 9
|
||||
Exp2 goto state 10
|
||||
Exp1 goto state 11
|
||||
Exp goto state 32
|
||||
|
||||
State 29
|
||||
|
||||
Exp2 -> Exp2 . Exp3 (rule 11)
|
||||
Exp1 -> Exp1 '-' Exp2 . (rule 14)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
')' reduce using rule 14
|
||||
'+' reduce using rule 14
|
||||
'-' reduce using rule 14
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
%eof reduce using rule 14
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 22
|
||||
|
||||
State 30
|
||||
|
||||
Exp2 -> Exp2 . Exp3 (rule 11)
|
||||
Exp1 -> Exp1 '+' Exp2 . (rule 13)
|
||||
|
||||
'(' shift, and enter state 13
|
||||
')' reduce using rule 13
|
||||
'+' reduce using rule 13
|
||||
'-' reduce using rule 13
|
||||
L_Ident shift, and enter state 6
|
||||
L_integ shift, and enter state 15
|
||||
%eof reduce using rule 13
|
||||
|
||||
Ident goto state 7
|
||||
Integer goto state 8
|
||||
Exp3 goto state 22
|
||||
|
||||
State 31
|
||||
|
||||
Program -> 'main' '=' Exp . (rule 7)
|
||||
|
||||
%eof reduce using rule 7
|
||||
|
||||
|
||||
State 32
|
||||
|
||||
Exp -> '\\' Ident '->' Exp . (rule 16)
|
||||
|
||||
')' reduce using rule 16
|
||||
%eof reduce using rule 16
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Grammar Totals
|
||||
-----------------------------------------------------------------------------
|
||||
Number of rules: 18
|
||||
Number of terminals: 10
|
||||
Number of non-terminals: 12
|
||||
Number of states: 33
|
||||
BIN
src/Grammar/Par.o
Normal file
BIN
src/Grammar/Par.o
Normal file
Binary file not shown.
BIN
src/Grammar/Print.hi
Normal file
BIN
src/Grammar/Print.hi
Normal file
Binary file not shown.
|
|
@ -150,4 +150,5 @@ instance Print Grammar.Abs.Exp where
|
|||
Grammar.Abs.EInt n -> prPrec i 3 (concatD [prt 0 n])
|
||||
Grammar.Abs.EApp exp1 exp2 -> prPrec i 2 (concatD [prt 2 exp1, prt 3 exp2])
|
||||
Grammar.Abs.EAdd exp1 exp2 -> prPrec i 1 (concatD [prt 1 exp1, doc (showString "+"), prt 2 exp2])
|
||||
Grammar.Abs.ESub exp1 exp2 -> prPrec i 1 (concatD [prt 1 exp1, doc (showString "-"), prt 2 exp2])
|
||||
Grammar.Abs.EAbs id_ exp -> prPrec i 0 (concatD [doc (showString "\\"), prt 0 id_, doc (showString "->"), prt 0 exp])
|
||||
|
|
|
|||
BIN
src/Grammar/Print.o
Normal file
BIN
src/Grammar/Print.o
Normal file
Binary file not shown.
BIN
src/Grammar/Skel.hi
Normal file
BIN
src/Grammar/Skel.hi
Normal file
Binary file not shown.
|
|
@ -29,4 +29,5 @@ transExp x = case x of
|
|||
Grammar.Abs.EInt integer -> failure x
|
||||
Grammar.Abs.EApp exp1 exp2 -> failure x
|
||||
Grammar.Abs.EAdd exp1 exp2 -> failure x
|
||||
Grammar.Abs.ESub exp1 exp2 -> failure x
|
||||
Grammar.Abs.EAbs ident exp -> failure x
|
||||
|
|
|
|||
BIN
src/Grammar/Skel.o
Normal file
BIN
src/Grammar/Skel.o
Normal file
Binary file not shown.
BIN
src/Grammar/Test.hi
Normal file
BIN
src/Grammar/Test.hi
Normal file
Binary file not shown.
BIN
src/Grammar/Test.o
Normal file
BIN
src/Grammar/Test.o
Normal file
Binary file not shown.
BIN
src/Grammar/test
Executable file
BIN
src/Grammar/test
Executable file
Binary file not shown.
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
|
||||
|
||||
main = 1 + (123 + 4214) + 1231 + 314
|
||||
main = 1 + (123 + 4214) - 1231 + 314
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue