diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-06-01 11:02:02 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-06-01 11:02:02 +0000 |
| commit | 9dbf9c56609132c7a3731819b53e73045c430e3b (patch) | |
| tree | 8a629aa5003111d82087797fb2eba25bf6165aa8 /src-3.0/GF/Source | |
| parent | 2771367118994770907597c860cc7c4229496fd3 (diff) | |
added an argument place to ResOverload for extended overloads
Diffstat (limited to 'src-3.0/GF/Source')
| -rw-r--r-- | src-3.0/GF/Source/GrammarToSource.hs | 8 | ||||
| -rw-r--r-- | src-3.0/GF/Source/SourceToGrammar.hs | 26 |
2 files changed, 22 insertions, 12 deletions
diff --git a/src-3.0/GF/Source/GrammarToSource.hs b/src-3.0/GF/Source/GrammarToSource.hs index 75446a6e4..e00edc689 100644 --- a/src-3.0/GF/Source/GrammarToSource.hs +++ b/src-3.0/GF/Source/GrammarToSource.hs @@ -96,10 +96,12 @@ trAnyDef (i,info) = let i' = tri i in case info of May b -> P.ParDefIndir i' $ tri b _ -> P.ParDefAbs i']] - ResOverload tysts -> + ResOverload os tysts -> [P.DefOper [P.DDef [mkName i'] ( - P.EApp (P.EIdent $ tri $ cOverload) - (P.ERecord [P.LDFull [i'] (trt ty) (trt fu) | (ty,fu) <- tysts]))]] + foldl P.EApp + (P.EIdent $ tri $ cOverload) + (map trt os ++ + [P.ERecord [P.LDFull [i'] (trt ty) (trt fu) | (ty,fu) <- tysts]]))]] CncCat (Yes ty) Nope _ -> [P.DefLincat [P.PrintDef [mkName i'] (trt ty)]] diff --git a/src-3.0/GF/Source/SourceToGrammar.hs b/src-3.0/GF/Source/SourceToGrammar.hs index 74b168b46..0e0d790c1 100644 --- a/src-3.0/GF/Source/SourceToGrammar.hs +++ b/src-3.0/GF/Source/SourceToGrammar.hs @@ -353,18 +353,26 @@ transResDef x = case x of DefFlag defs -> liftM (Right . concatModuleOptions) $ mapM transFlagDef defs _ -> Bad $ "illegal definition form in resource" +++ printTree x where - mkOverload (c,p,j) = case j of - G.ResOper _ (Yes (G.App keyw (G.R fs@(_:_:_)))) | - isOverloading keyw c fs -> - [(c,p,G.ResOverload [(ty,fu) | (_,(Just ty,fu)) <- fs])] + mkOverload op@(c,p,j) = case j of + G.ResOper _ (Yes df) -> case M.appForm df of + (keyw, ts@(_:_)) | isOverloading keyw -> case last ts of + G.R fs -> + [(c,p,G.ResOverload (init ts) [(ty,fu) | (_,(Just ty,fu)) <- fs])] + _ -> [op] + _ -> [op] -- to enable separare type signature --- not type-checked - G.ResOper (Yes (G.App keyw (G.RecType fs@(_:_:_)))) _ | - isOverloading keyw c fs -> [] + G.ResOper (Yes df) _ -> case M.appForm df of + (keyw, ts@(_:_)) | isOverloading keyw -> case last ts of + G.RecType _ -> [] + _ -> [op] + _ -> [op] _ -> [(c,p,j)] - isOverloading keyw c fs = - GP.prt keyw == "overload" && -- overload is a "soft keyword" - all (== GP.prt c) (map (GP.prt . fst) fs) + isOverloading keyw = + GP.prt keyw == "overload" -- overload is a "soft keyword" + isRec t = case t of + G.R _ -> True + _ -> False transParDef :: ParDef -> Err (Ident, [G.Param]) transParDef x = case x of |
