diff options
Diffstat (limited to 'src/LambdaCube/Compiler/Parser.hs')
-rw-r--r-- | src/LambdaCube/Compiler/Parser.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/LambdaCube/Compiler/Parser.hs b/src/LambdaCube/Compiler/Parser.hs index 5c0c64b8..d643b746 100644 --- a/src/LambdaCube/Compiler/Parser.hs +++ b/src/LambdaCube/Compiler/Parser.hs | |||
@@ -162,7 +162,8 @@ getApps = second reverse . run where | |||
162 | run (SApp _ h a b) = second ((h, b):) $ run a | 162 | run (SApp _ h a b) = second ((h, b):) $ run a |
163 | run x = (x, []) | 163 | run x = (x, []) |
164 | 164 | ||
165 | downToS n m = map (SVar (debugSI "20", ".ds")) [n+m-1, n+m-2..n] | 165 | -- todo: remove |
166 | downToS err n m = [SVar (debugSI $ err ++ " " ++ show i, ".ds") (n + i) | i <- [m-1, m-2..0]] | ||
166 | 167 | ||
167 | instance SourceInfo (SExp' a) where | 168 | instance SourceInfo (SExp' a) where |
168 | sourceInfo = \case | 169 | sourceInfo = \case |
@@ -226,7 +227,7 @@ class Up a where | |||
226 | instance (Up a, Up b) => Up (a, b) where | 227 | instance (Up a, Up b) => Up (a, b) where |
227 | up_ n i (a, b) = (up_ n i a, up_ n i b) | 228 | up_ n i (a, b) = (up_ n i a, up_ n i b) |
228 | used i (a, b) = used i a || used i b | 229 | used i (a, b) = used i a || used i b |
229 | fold _ _ _ = error "fold @(_,_)" | 230 | fold f i (a, b) = fold f i a <> fold f i b |
230 | maxDB_ (a, b) = maxDB_ a <> maxDB_ b | 231 | maxDB_ (a, b) = maxDB_ a <> maxDB_ b |
231 | closedExp (a, b) = (closedExp a, closedExp b) | 232 | closedExp (a, b) = (closedExp a, closedExp b) |
232 | 233 | ||
@@ -287,7 +288,7 @@ instance Up Void where | |||
287 | 288 | ||
288 | instance Up a => Up (SExp' a) where | 289 | instance Up a => Up (SExp' a) where |
289 | up_ n = mapS' (\sn j i -> SVar sn $ if j < i then j else j+n) (+1) | 290 | up_ n = mapS' (\sn j i -> SVar sn $ if j < i then j else j+n) (+1) |
290 | fold f = foldS (\_ _ _ -> error "fold @SExp") mempty $ \sn j i -> f j i | 291 | fold f = foldS (\i si x -> fold f i x) mempty $ \sn j i -> f j i |
291 | maxDB_ _ = error "maxDB @SExp" | 292 | maxDB_ _ = error "maxDB @SExp" |
292 | 293 | ||
293 | dbf' = dbf_ 0 | 294 | dbf' = dbf_ 0 |
@@ -756,7 +757,7 @@ parseDef = | |||
756 | t <- dbf' npsd <$> parseType (Just SType) | 757 | t <- dbf' npsd <$> parseType (Just SType) |
757 | let mkConTy mk (nps', ts') = | 758 | let mkConTy mk (nps', ts') = |
758 | ( if mk then Just nps' else Nothing | 759 | ( if mk then Just nps' else Nothing |
759 | , foldr (uncurry SPi) (foldl SAppV (SGlobal x) $ downToS (length ts') $ length ts) ts') | 760 | , foldr (uncurry SPi) (foldl SAppV (SGlobal x) $ downToS "a1" (length ts') $ length ts) ts') |
760 | (af, cs) <- option (True, []) $ | 761 | (af, cs) <- option (True, []) $ |
761 | do fmap ((,) True) $ (reserved "where" >>) $ indentMS True $ second ((,) Nothing . dbf' npsd) <$> typedIds Nothing | 762 | do fmap ((,) True) $ (reserved "where" >>) $ indentMS True $ second ((,) Nothing . dbf' npsd) <$> typedIds Nothing |
762 | <|> (,) False <$ reservedOp "=" <*> | 763 | <|> (,) False <$ reservedOp "=" <*> |
@@ -949,7 +950,7 @@ compileFunAlts par ulend lend ds xs = dsInfo >>= \ge -> case xs of | |||
949 | ++ [ FunAlt n (replicate (length ps) (noTA $ PVar (debugSI "compileFunAlts1", "generated_name0"))) $ Right $ SBuiltin "'Empty" `SAppV` sLit (LString $ "no instance of " ++ snd n ++ " on ???")] | 950 | ++ [ FunAlt n (replicate (length ps) (noTA $ PVar (debugSI "compileFunAlts1", "generated_name0"))) $ Right $ SBuiltin "'Empty" `SAppV` sLit (LString $ "no instance of " ++ snd n ++ " on ???")] |
950 | cds <- sequence | 951 | cds <- sequence |
951 | [ compileFunAlts' SLabelEnd | 952 | [ compileFunAlts' SLabelEnd |
952 | $ TypeAnn m (addParamsS (map ((,) Hidden) ps) $ SPi Hidden (foldl SAppV (SGlobal n) $ downToS 0 $ length ps) $ up1 t) | 953 | $ TypeAnn m (addParamsS (map ((,) Hidden) ps) $ SPi Hidden (foldl SAppV (SGlobal n) $ downToS "a2" 0 $ length ps) $ up1 t) |
953 | : as | 954 | : as |
954 | | (m, t) <- ms | 955 | | (m, t) <- ms |
955 | -- , let ts = fst $ getParamsS $ up1 t | 956 | -- , let ts = fst $ getParamsS $ up1 t |
@@ -1054,7 +1055,6 @@ data Module | |||
1054 | , moduleImports :: [(SName, ImportItems)] | 1055 | , moduleImports :: [(SName, ImportItems)] |
1055 | , moduleExports :: Maybe [Export] | 1056 | , moduleExports :: Maybe [Export] |
1056 | , definitions :: DesugarInfo -> (Either String [Stmt], [PostponedCheck]) | 1057 | , definitions :: DesugarInfo -> (Either String [Stmt], [PostponedCheck]) |
1057 | , sourceCode :: String | ||
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | parseModule :: FilePath -> String -> P Module | 1060 | parseModule :: FilePath -> String -> P Module |
@@ -1085,7 +1085,6 @@ parseModule f str = do | |||
1085 | , moduleImports = [("Prelude", ImportAllBut []) | NoImplicitPrelude `notElem` exts] ++ idefs | 1085 | , moduleImports = [("Prelude", ImportAllBut []) | NoImplicitPrelude `notElem` exts] ++ idefs |
1086 | , moduleExports = join $ snd <$> header | 1086 | , moduleExports = join $ snd <$> header |
1087 | , definitions = \ge -> first ((show +++ id) . snd) $ runP' (ge, ns) f (parseDefs SLabelEnd <* eof) st | 1087 | , definitions = \ge -> first ((show +++ id) . snd) $ runP' (ge, ns) f (parseDefs SLabelEnd <* eof) st |
1088 | , sourceCode = str | ||
1089 | } | 1088 | } |
1090 | 1089 | ||
1091 | parseLC :: MonadError ErrorMsg m => FilePath -> String -> m Module | 1090 | parseLC :: MonadError ErrorMsg m => FilePath -> String -> m Module |