parse programs (with types :D)
This commit is contained in:
@@ -15,15 +15,6 @@ import Core.Syntax
|
|||||||
import Core.TH
|
import Core.TH
|
||||||
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
|
|
||||||
--
|
|
||||||
fac3 = undefined
|
|
||||||
sumList = undefined
|
|
||||||
constDivZero = undefined
|
|
||||||
idCase = undefined
|
|
||||||
--}
|
|
||||||
|
|
||||||
{--
|
|
||||||
|
|
||||||
letrecExample :: Program'
|
letrecExample :: Program'
|
||||||
letrecExample = [coreProg|
|
letrecExample = [coreProg|
|
||||||
pair x y f = f x y;
|
pair x y f = f x y;
|
||||||
@@ -225,5 +216,3 @@ idCase = [coreProg|
|
|||||||
-- , ScDef "Cons" [] $ Con 2 2
|
-- , ScDef "Cons" [] $ Con 2 2
|
||||||
-- ]
|
-- ]
|
||||||
|
|
||||||
--}
|
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ StandaloneProgram : Program eof { $1 }
|
|||||||
Program :: { Program Name }
|
Program :: { Program Name }
|
||||||
Program : ScTypeSig ';' Program { insTypeSig $1 $3 }
|
Program : ScTypeSig ';' Program { insTypeSig $1 $3 }
|
||||||
| ScTypeSig OptSemi { singletonTypeSig $1 }
|
| ScTypeSig OptSemi { singletonTypeSig $1 }
|
||||||
|
| ScDef ';' Program { insScDef $1 $3 }
|
||||||
|
| ScDef OptSemi { singletonScDef $1 }
|
||||||
|
|
||||||
OptSemi :: { () }
|
OptSemi :: { () }
|
||||||
OptSemi : ';' { () }
|
OptSemi : ';' { () }
|
||||||
@@ -216,8 +218,13 @@ insTypeSig :: (Hashable b) => (b, Type) -> Program b -> Program b
|
|||||||
insTypeSig ts = programTypeSigs %~ uncurry H.insert ts
|
insTypeSig ts = programTypeSigs %~ uncurry H.insert ts
|
||||||
|
|
||||||
singletonTypeSig :: (Hashable b) => (b, Type) -> Program b
|
singletonTypeSig :: (Hashable b) => (b, Type) -> Program b
|
||||||
singletonTypeSig ts = mempty
|
singletonTypeSig ts = insTypeSig ts mempty
|
||||||
& programTypeSigs .~ uncurry H.singleton ts
|
|
||||||
|
insScDef :: (Hashable b) => ScDef b -> Program b -> Program b
|
||||||
|
insScDef sc = programScDefs %~ (sc:)
|
||||||
|
|
||||||
|
singletonScDef :: (Hashable b) => ScDef b -> Program b
|
||||||
|
singletonScDef sc = insScDef sc mempty
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user