"Committed_by_peb"

This commit is contained in:
peb
2005-02-24 10:46:37 +00:00
parent d669e538d6
commit 59b378a4e5
43 changed files with 786 additions and 493 deletions

View File

@@ -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

View File

@@ -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"