diff options
Diffstat (limited to 'src/GF/Source')
| -rw-r--r-- | src/GF/Source/GrammarToSource.hs | 12 | ||||
| -rw-r--r-- | src/GF/Source/SourceToGrammar.hs | 23 |
2 files changed, 24 insertions, 11 deletions
diff --git a/src/GF/Source/GrammarToSource.hs b/src/GF/Source/GrammarToSource.hs index cea8fb517..2a2e3e2d5 100644 --- a/src/GF/Source/GrammarToSource.hs +++ b/src/GF/Source/GrammarToSource.hs @@ -5,14 +5,19 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/02/18 19:21:20 $ +-- > CVS $Date: 2005/02/24 11:46:38 $ -- > CVS $Author: peb $ --- > CVS $Revision: 1.16 $ +-- > CVS $Revision: 1.17 $ -- -- From internal source syntax to BNFC-generated (used for printing). ----------------------------------------------------------------------------- -module GrammarToSource where +module GrammarToSource ( trGrammar, + trModule, + trAnyDef, + trLabel, + trt, tri, trp + ) where import Operations import Grammar @@ -205,6 +210,7 @@ tri i = case prIdent i of trb i = if isWildIdent i then P.BWild else P.BIdent (tri i) +trLabel :: Label -> P.Label trLabel i = case i of LIdent s -> P.LIdent $ identC s LVar i -> P.LVar $ toInteger i diff --git a/src/GF/Source/SourceToGrammar.hs b/src/GF/Source/SourceToGrammar.hs index fd25fe2fd..259e4f9fe 100644 --- a/src/GF/Source/SourceToGrammar.hs +++ b/src/GF/Source/SourceToGrammar.hs @@ -5,14 +5,20 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/02/18 19:21:21 $ +-- > CVS $Date: 2005/02/24 11:46:38 $ -- > CVS $Author: peb $ --- > CVS $Revision: 1.20 $ +-- > CVS $Revision: 1.21 $ -- -- based on the skeleton Haskell module generated by the BNF converter ----------------------------------------------------------------------------- -module SourceToGrammar where +module SourceToGrammar ( transGrammar, + transInclude, + transModDef, + transOldGrammar, + transExp, + newReservedWords + ) where import qualified Grammar as G import qualified PrGrammar as GP @@ -321,7 +327,7 @@ getDefsGen d = case d of e' <- transExp e return [(id',(nope, yes (G.Eqs [(ps',e')])))] --- sometimes you need this special case, e.g. in linearization rules +-- | sometimes you need this special case, e.g. in linearization rules getDefs :: Def -> Err [(Ident, (G.Perh G.Type, G.Perh G.Term))] getDefs d = case d of DPatt id patts e -> do @@ -331,7 +337,7 @@ getDefs d = case d of return [(id',(nope, yes (M.mkAbs xs e')))] _ -> getDefsGen d --- accepts a pattern that is either a variable or a wild card +-- | accepts a pattern that is either a variable or a wild card tryMakeVar :: Patt -> Err Ident tryMakeVar p = do p' <- transPatt p @@ -434,6 +440,7 @@ erecord2term ds = do _ -> Bad $ "illegal record field" +++ GP.prt (fst f) +locdef2fields :: LocDef -> Err [(Ident, (Maybe G.Type, Maybe G.Type))] locdef2fields d = case d of LDDecl ids t -> do labs <- mapM transIdent ids @@ -522,9 +529,8 @@ transDDecl x = case x of DDDec binds exp -> transDecl $ DDec binds exp DDExp exp -> transDecl $ DExp exp --- to deal with the old format, sort judgements in three modules, forming +-- | to deal with the old format, sort judgements in three modules, forming -- their names from a given string, e.g. file name or overriding user-given string - transOldGrammar :: Options -> FilePath -> OldGrammar -> Err G.SourceGrammar transOldGrammar opts name0 x = case x of OldGr includes topdefs -> do --- includes must be collected separately @@ -594,7 +600,8 @@ transInclude x = case x of --- unsafe hack ; cf. GetGrammar.oldLexer -newReservedWords = +newReservedWords :: [String] +newReservedWords = words $ "abstract concrete interface incomplete " ++ "instance out open resource reuse transfer union with where" |
