diff options
Diffstat (limited to 'src/GF/Source')
| -rw-r--r-- | src/GF/Source/GrammarToSource.hs | 3 | ||||
| -rw-r--r-- | src/GF/Source/SourceToGrammar.hs | 17 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/GF/Source/GrammarToSource.hs b/src/GF/Source/GrammarToSource.hs index 055c79d15..16a68cdb0 100644 --- a/src/GF/Source/GrammarToSource.hs +++ b/src/GF/Source/GrammarToSource.hs @@ -96,7 +96,8 @@ trAnyDef (i,info) = let i' = tri i in case info of ResOverload tysts -> [P.DefOper [P.DDef [mkName i'] ( - P.ERecord [P.LDFull [i'] (trt ty) (trt fu) | (ty,fu) <- tysts])]] + P.EApp (P.EIdent $ identC "overload") + (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/GF/Source/SourceToGrammar.hs b/src/GF/Source/SourceToGrammar.hs index 49023bf09..7e525a4b9 100644 --- a/src/GF/Source/SourceToGrammar.hs +++ b/src/GF/Source/SourceToGrammar.hs @@ -299,7 +299,7 @@ transResDef x = case x of (p,pars) <- pardefs', (f,co) <- pars] DefOper defs -> do defs' <- liftM concat $ mapM getDefs defs - returnl [mkOverload (f, G.ResOper pt pe) | (f,(pt,pe)) <- defs'] + returnl $ concatMap mkOverload [(f, G.ResOper pt pe) | (f,(pt,pe)) <- defs'] DefLintype defs -> do defs' <- liftM concat $ mapM getDefs defs @@ -309,10 +309,17 @@ transResDef x = case x of _ -> Bad $ "illegal definition form in resource" +++ printTree x where mkOverload (c,j) = case j of - G.ResOper Nope (Yes (G.R fs@(_:_:_))) | isOverloading c fs -> - (c,G.ResOverload [(ty,fu) | (_,(Just ty,fu)) <- fs]) - _ -> (c,j) - isOverloading c fs = all (== GP.prt c) (map (GP.prt . fst) fs) + G.ResOper _ (Yes (G.App keyw (G.R fs@(_:_:_)))) | + isOverloading keyw c fs -> + [(c,G.ResOverload [(ty,fu) | (_,(Just ty,fu)) <- fs])] + + -- to enable separare type signature --- not type-checked + G.ResOper (Yes (G.App keyw (G.RecType fs@(_:_:_)))) _ | + isOverloading keyw c fs -> [] + _ -> [(c,j)] + isOverloading keyw c fs = + GP.prt keyw == "overload" && -- overload is a "soft keyword" + all (== GP.prt c) (map (GP.prt . fst) fs) transParDef :: ParDef -> Err (Ident, [G.Param]) transParDef x = case x of |
