BNFC 2.4.2.0 → 2.4.2.1
raw patch · 279 files changed
+3612/−520 lines, 279 filesdep −haskell98new-uploaderbinary-added
Dependencies removed: haskell98
Files
- BNFC.cabal +6/−2
- CF.hs +35/−35
- GetCF.hs +4/−4
- Main.hs +19/−17
- MultiView.hs +10/−10
- ParBNF.hs +128/−128
- PrintBNF.hs +1/−1
- dist/build/autogen/Paths_BNFC.hs +32/−0
- dist/build/autogen/cabal_macros.h +37/−0
- dist/build/bnfc/bnfc too large to diff
- dist/build/bnfc/bnfc-tmp/AbsBNF.hi binary
- dist/build/bnfc/bnfc-tmp/AbsBNF.o binary
- dist/build/bnfc/bnfc-tmp/CAbstoCSharpAbs.hi binary
- dist/build/bnfc/bnfc-tmp/CAbstoCSharpAbs.o binary
- dist/build/bnfc/bnfc-tmp/CAbstoCSharpAbstractVisitSkeleton.hi binary
- dist/build/bnfc/bnfc-tmp/CAbstoCSharpAbstractVisitSkeleton.o binary
- dist/build/bnfc/bnfc-tmp/CAbstoCSharpVisitSkeleton.hi binary
- dist/build/bnfc/bnfc-tmp/CAbstoCSharpVisitSkeleton.o binary
- dist/build/bnfc/bnfc-tmp/CF.hi binary
- dist/build/bnfc/bnfc-tmp/CF.o binary
- dist/build/bnfc/bnfc-tmp/CFtoAbstract.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoAbstract.o binary
- dist/build/bnfc/bnfc-tmp/CFtoAbstractGADT.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoAbstractGADT.o binary
- dist/build/bnfc/bnfc-tmp/CFtoAbstractVisitor.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoAbstractVisitor.o binary
- dist/build/bnfc/bnfc-tmp/CFtoAlex.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoAlex.o binary
- dist/build/bnfc/bnfc-tmp/CFtoAlex2.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoAlex2.o binary
- dist/build/bnfc/bnfc-tmp/CFtoAllVisitor.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoAllVisitor.o binary
- dist/build/bnfc/bnfc-tmp/CFtoBison.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoBison.o binary
- dist/build/bnfc/bnfc-tmp/CFtoBisonC.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoBisonC.o binary
- dist/build/bnfc/bnfc-tmp/CFtoBisonSTL.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoBisonSTL.o binary
- dist/build/bnfc/bnfc-tmp/CFtoCAbs.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoCAbs.o binary
- dist/build/bnfc/bnfc-tmp/CFtoCPPAbs.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoCPPAbs.o binary
- dist/build/bnfc/bnfc-tmp/CFtoCPPPrinter.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoCPPPrinter.o binary
- dist/build/bnfc/bnfc-tmp/CFtoCPrinter.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoCPrinter.o binary
- dist/build/bnfc/bnfc-tmp/CFtoCSharpPrinter.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoCSharpPrinter.o binary
- dist/build/bnfc/bnfc-tmp/CFtoCSkel.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoCSkel.o binary
- dist/build/bnfc/bnfc-tmp/CFtoCVisitSkel.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoCVisitSkel.o binary
- dist/build/bnfc/bnfc-tmp/CFtoCVisitSkelSTL.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoCVisitSkelSTL.o binary
- dist/build/bnfc/bnfc-tmp/CFtoComposVisitor.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoComposVisitor.o binary
- dist/build/bnfc/bnfc-tmp/CFtoCup.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoCup.o binary
- dist/build/bnfc/bnfc-tmp/CFtoCup15.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoCup15.o binary
- dist/build/bnfc/bnfc-tmp/CFtoFlex.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoFlex.o binary
- dist/build/bnfc/bnfc-tmp/CFtoFlexC.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoFlexC.o binary
- dist/build/bnfc/bnfc-tmp/CFtoFoldVisitor.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoFoldVisitor.o binary
- dist/build/bnfc/bnfc-tmp/CFtoGPLEX.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoGPLEX.o binary
- dist/build/bnfc/bnfc-tmp/CFtoGPPG.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoGPPG.o binary
- dist/build/bnfc/bnfc-tmp/CFtoHappy.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoHappy.o binary
- dist/build/bnfc/bnfc-tmp/CFtoHappyProfile.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoHappyProfile.o binary
- dist/build/bnfc/bnfc-tmp/CFtoJLex.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoJLex.o binary
- dist/build/bnfc/bnfc-tmp/CFtoJLex15.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoJLex15.o binary
- dist/build/bnfc/bnfc-tmp/CFtoJavaAbs.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoJavaAbs.o binary
- dist/build/bnfc/bnfc-tmp/CFtoJavaAbs15.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoJavaAbs15.o binary
- dist/build/bnfc/bnfc-tmp/CFtoJavaPrinter.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoJavaPrinter.o binary
- dist/build/bnfc/bnfc-tmp/CFtoJavaPrinter15.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoJavaPrinter15.o binary
- dist/build/bnfc/bnfc-tmp/CFtoJavaSkeleton.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoJavaSkeleton.o binary
- dist/build/bnfc/bnfc-tmp/CFtoLatex.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoLatex.o binary
- dist/build/bnfc/bnfc-tmp/CFtoLayout.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoLayout.o binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlAbs.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlAbs.o binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlLex.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlLex.o binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlPrinter.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlPrinter.o binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlShow.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlShow.o binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlTemplate.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlTemplate.o binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlTest.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlTest.o binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlYacc.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoOCamlYacc.o binary
- dist/build/bnfc/bnfc-tmp/CFtoPrinter.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoPrinter.o binary
- dist/build/bnfc/bnfc-tmp/CFtoPrinterGADT.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoPrinterGADT.o binary
- dist/build/bnfc/bnfc-tmp/CFtoSTLAbs.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoSTLAbs.o binary
- dist/build/bnfc/bnfc-tmp/CFtoSTLPrinter.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoSTLPrinter.o binary
- dist/build/bnfc/bnfc-tmp/CFtoTemplate.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoTemplate.o binary
- dist/build/bnfc/bnfc-tmp/CFtoTemplateGADT.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoTemplateGADT.o binary
- dist/build/bnfc/bnfc-tmp/CFtoTxt.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoTxt.o binary
- dist/build/bnfc/bnfc-tmp/CFtoVisitSkel.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoVisitSkel.o binary
- dist/build/bnfc/bnfc-tmp/CFtoVisitSkel15.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoVisitSkel15.o binary
- dist/build/bnfc/bnfc-tmp/CFtoXML.hi binary
- dist/build/bnfc/bnfc-tmp/CFtoXML.o binary
- dist/build/bnfc/bnfc-tmp/CPPTop.hi binary
- dist/build/bnfc/bnfc-tmp/CPPTop.o binary
- dist/build/bnfc/bnfc-tmp/CSharpTop.hi binary
- dist/build/bnfc/bnfc-tmp/CSharpTop.o binary
- dist/build/bnfc/bnfc-tmp/CSharpUtils.hi binary
- dist/build/bnfc/bnfc-tmp/CSharpUtils.o binary
- dist/build/bnfc/bnfc-tmp/CTop.hi binary
- dist/build/bnfc/bnfc-tmp/CTop.o binary
- dist/build/bnfc/bnfc-tmp/ErrM.hi binary
- dist/build/bnfc/bnfc-tmp/ErrM.o binary
- dist/build/bnfc/bnfc-tmp/FSharpTop.hi binary
- dist/build/bnfc/bnfc-tmp/FSharpTop.o binary
- dist/build/bnfc/bnfc-tmp/GetCF.hi binary
- dist/build/bnfc/bnfc-tmp/GetCF.o binary
- dist/build/bnfc/bnfc-tmp/HaskellGADTCommon.hi binary
- dist/build/bnfc/bnfc-tmp/HaskellGADTCommon.o binary
- dist/build/bnfc/bnfc-tmp/HaskellTop.hi binary
- dist/build/bnfc/bnfc-tmp/HaskellTop.o binary
- dist/build/bnfc/bnfc-tmp/HaskellTopGADT.hi binary
- dist/build/bnfc/bnfc-tmp/HaskellTopGADT.o binary
- dist/build/bnfc/bnfc-tmp/JavaTop.hi binary
- dist/build/bnfc/bnfc-tmp/JavaTop.o binary
- dist/build/bnfc/bnfc-tmp/JavaTop15.hi binary
- dist/build/bnfc/bnfc-tmp/JavaTop15.o binary
- dist/build/bnfc/bnfc-tmp/LexBNF.hi binary
- dist/build/bnfc/bnfc-tmp/LexBNF.hs +1/−1
- dist/build/bnfc/bnfc-tmp/LexBNF.o binary
- dist/build/bnfc/bnfc-tmp/Main.hi binary
- dist/build/bnfc/bnfc-tmp/Main.o binary
- dist/build/bnfc/bnfc-tmp/MkErrM.hi binary
- dist/build/bnfc/bnfc-tmp/MkErrM.o binary
- dist/build/bnfc/bnfc-tmp/MkSharedString.hi binary
- dist/build/bnfc/bnfc-tmp/MkSharedString.o binary
- dist/build/bnfc/bnfc-tmp/MultiView.hi binary
- dist/build/bnfc/bnfc-tmp/MultiView.o binary
- dist/build/bnfc/bnfc-tmp/NamedVariables.hi binary
- dist/build/bnfc/bnfc-tmp/NamedVariables.o binary
- dist/build/bnfc/bnfc-tmp/OCamlTop.hi binary
- dist/build/bnfc/bnfc-tmp/OCamlTop.o binary
- dist/build/bnfc/bnfc-tmp/OCamlUtil.hi binary
- dist/build/bnfc/bnfc-tmp/OCamlUtil.o binary
- dist/build/bnfc/bnfc-tmp/OOAbstract.hi binary
- dist/build/bnfc/bnfc-tmp/OOAbstract.o binary
- dist/build/bnfc/bnfc-tmp/ParBNF.hi binary
- dist/build/bnfc/bnfc-tmp/ParBNF.o binary
- dist/build/bnfc/bnfc-tmp/PrintBNF.hi binary
- dist/build/bnfc/bnfc-tmp/PrintBNF.o binary
- dist/build/bnfc/bnfc-tmp/ProfileTop.hi binary
- dist/build/bnfc/bnfc-tmp/ProfileTop.o binary
- dist/build/bnfc/bnfc-tmp/RegToAlex.hi binary
- dist/build/bnfc/bnfc-tmp/RegToAlex.o binary
- dist/build/bnfc/bnfc-tmp/RegToFlex.hi binary
- dist/build/bnfc/bnfc-tmp/RegToFlex.o binary
- dist/build/bnfc/bnfc-tmp/RegToGPLEX.hi binary
- dist/build/bnfc/bnfc-tmp/RegToGPLEX.o binary
- dist/build/bnfc/bnfc-tmp/RegToJLex.hi binary
- dist/build/bnfc/bnfc-tmp/RegToJLex.o binary
- dist/build/bnfc/bnfc-tmp/STLTop.hi binary
- dist/build/bnfc/bnfc-tmp/STLTop.o binary
- dist/build/bnfc/bnfc-tmp/STLUtils.hi binary
- dist/build/bnfc/bnfc-tmp/STLUtils.o binary
- dist/build/bnfc/bnfc-tmp/TypeChecker.hi binary
- dist/build/bnfc/bnfc-tmp/TypeChecker.o binary
- dist/build/bnfc/bnfc-tmp/Utils.hi binary
- dist/build/bnfc/bnfc-tmp/Utils.o binary
- dist/package.conf.inplace +1/−0
- dist/setup-config +2/−0
- formats/CFtoLatex.hs +1/−1
- formats/CFtoTxt.hs +1/−1
- formats/NamedVariables.hs +2/−2
- formats/OOAbstract.hs +2/−2
- formats/c-sharp/CAbstoCSharpAbs.hs +2/−2
- formats/c-sharp/CAbstoCSharpAbstractVisitSkeleton.hs +1/−1
- formats/c-sharp/CAbstoCSharpVisitSkeleton.hs +1/−1
- formats/c-sharp/CFtoCSharpPrinter.hs +2/−2
- formats/c-sharp/CFtoGPLEX.hs +1/−1
- formats/c-sharp/CFtoGPPG.hs +2/−2
- formats/c-sharp/CSharpTop.hs +18/−18
- formats/c-sharp/CSharpTop.hs~ +367/−0
- formats/c-sharp/CSharpUtils.hs +2/−2
- formats/c-sharp/RegToGPLEX.hs +1/−1
- formats/c/CFtoBisonC.hs +2/−2
- formats/c/CFtoCAbs.hs +2/−2
- formats/c/CFtoCPrinter.hs +2/−2
- formats/c/CFtoCSkel.hs +2/−2
- formats/c/CFtoFlexC.hs +1/−1
- formats/c/CTop.hs +11/−10
- formats/c/CTop.hs~ +217/−0
- formats/cpp/CFtoBison.hs +2/−2
- formats/cpp/CFtoCPPAbs.hs +2/−2
- formats/cpp/CFtoCPPPrinter.hs +2/−2
- formats/cpp/CFtoCVisitSkel.hs +2/−2
- formats/cpp/CFtoFlex.hs +1/−1
- formats/cpp/CPPTop.hs +12/−11
- formats/cpp/CPPTop.hs~ +208/−0
- formats/cpp/RegToFlex.hs +1/−1
- formats/cpp_stl/CFtoBisonSTL.hs +2/−2
- formats/cpp_stl/CFtoCVisitSkelSTL.hs +2/−2
- formats/cpp_stl/CFtoSTLAbs.hs +2/−2
- formats/cpp_stl/CFtoSTLPrinter.hs +2/−2
- formats/cpp_stl/STLTop.hs +12/−11
- formats/cpp_stl/STLTop.hs~ +223/−0
- formats/cpp_stl/STLUtils.hs +1/−1
- formats/f-sharp/FSharpTop.hs +21/−20
- formats/f-sharp/FSharpTop.hs~ +208/−0
- formats/haskell-gadt/CFtoAbstractGADT.hs +1/−1
- formats/haskell-gadt/CFtoPrinterGADT.hs +2/−2
- formats/haskell-gadt/CFtoTemplateGADT.hs +1/−1
- formats/haskell-gadt/HaskellGADTCommon.hs +1/−1
- formats/haskell-gadt/HaskellTopGADT.hs +35/−34
- formats/haskell-gadt/HaskellTopGADT.hs~ +387/−0
- formats/haskell2/CFtoAbstract.hs +1/−1
- formats/haskell2/CFtoAlex.hs +1/−1
- formats/haskell2/CFtoAlex2.hs +2/−2
- formats/haskell2/CFtoHappy.hs +2/−2
- formats/haskell2/CFtoPrinter.hs +2/−2
- formats/haskell2/CFtoTemplate.hs +2/−2
- formats/haskell2/HaskellTop.hs +35/−34
- formats/haskell2/HaskellTop.hs~ +356/−0
- formats/haskell2/RegToAlex.hs +1/−1
- formats/java/CFtoCup.hs +1/−1
- formats/java/CFtoJLex.hs +1/−1
- formats/java/CFtoJavaAbs.hs +2/−2
- formats/java/CFtoJavaPrinter.hs +2/−2
- formats/java/CFtoJavaSkeleton.hs +2/−2
- formats/java/CFtoVisitSkel.hs +2/−2
- formats/java/JavaTop.hs +13/−12
- formats/java/JavaTop.hs~ +313/−0
- formats/java/RegToJLex.hs +1/−1
- formats/java1.5/CFtoAbstractVisitor.hs +2/−2
- formats/java1.5/CFtoAllVisitor.hs +2/−2
- formats/java1.5/CFtoComposVisitor.hs +2/−2
- formats/java1.5/CFtoCup15.hs +1/−1
- formats/java1.5/CFtoFoldVisitor.hs +2/−2
- formats/java1.5/CFtoJLex15.hs +1/−1
- formats/java1.5/CFtoJavaAbs15.hs +3/−3
- formats/java1.5/CFtoJavaPrinter15.hs +2/−2
- formats/java1.5/CFtoVisitSkel15.hs +2/−2
- formats/java1.5/JavaTop15.hs +12/−12
- formats/java1.5/JavaTop15.hs~ +285/−0
- formats/ocaml/CFtoOCamlAbs.hs +1/−1
- formats/ocaml/CFtoOCamlLex.hs +2/−2
- formats/ocaml/CFtoOCamlPrinter.hs +2/−2
- formats/ocaml/CFtoOCamlShow.hs +2/−2
- formats/ocaml/CFtoOCamlTemplate.hs +2/−2
- formats/ocaml/CFtoOCamlYacc.hs +2/−2
- formats/ocaml/OCamlTop.hs +21/−20
- formats/ocaml/OCamlTop.hs~ +207/−0
- formats/ocaml/OCamlUtil.hs +1/−1
- formats/profile/CFtoHappyProfile.hs +2/−2
- formats/profile/ProfileTop.hs +34/−33
- formats/profile/ProfileTop.hs~ +234/−0
- formats/xml/CFtoXML.hs +3/−3
@@ -1,5 +1,5 @@ Name: BNFC-Version: 2.4.2.0+Version: 2.4.2.1 cabal-version: >= 1.2 build-type: Simple category: Development@@ -21,10 +21,14 @@ a Happy, CUP, or Bison parser generator file, a pretty-printer as a Haskell/Java/C++/C module, a Latex file containing a readable specification of the language.+ .+ This version only works with Alex version < 3, e.g. alex-2.3.5.+tested-with: GHC == 7.4.1 Extra-source-files: BNF.cf Executable bnfc- Build-Depends: haskell98, base>=4 && <5, mtl, directory, array, process+ Build-Depends: mtl, directory, array, process, base>=4 && <5+-- haskell98, Main-is: Main.hs HS-source-dirs: . formats formats/haskell2
@@ -90,7 +90,7 @@ CFP, -- CF with profiles RuleP,- FunP, + FunP, Prof, cf2cfpRule, cf2cfp,@@ -101,11 +101,11 @@ ) where import Utils (prParenth,(+++))-import List (nub, intersperse, partition, sort,sort,group)-import Char+import Data.List (nub, intersperse, partition, sort,sort,group)+import Data.Char import AbsBNF (Reg()) --- A context free grammar consists of a set of rules and some extended +-- A context free grammar consists of a set of rules and some extended -- information (e.g. pragmas, literals, symbols, keywords) type CF = (Exts,[Rule]) @@ -162,7 +162,7 @@ listView e = Left e -- pragmas for single line comments and for multiple-line comments.-data Pragma = CommentS String +data Pragma = CommentS String | CommentM (String,String) | TokenReg String Bool Reg | EntryPoints [Cat]@@ -197,7 +197,7 @@ -- Cat is the Non-terminals of the grammar. type Cat = String--- Fun is the function name of a rule. +-- Fun is the function name of a rule. type Fun = String internalCat :: Cat@@ -214,7 +214,7 @@ firstCat = valCat . head . rulesOfCF firstEntry :: CF -> Cat-firstEntry cf = case allEntryPoints cf of +firstEntry cf = case allEntryPoints cf of (x:_) -> x _ -> firstCat cf @@ -250,11 +250,11 @@ -- returns all normal rules that constructs the given Cat. rulesForCat :: CF -> Cat -> [Rule]-rulesForCat cf cat = [normRuleFun r | r <- rulesOfCF cf, isParsable r, valCat r == cat] +rulesForCat cf cat = [normRuleFun r | r <- rulesOfCF cf, isParsable r, valCat r == cat] --This version doesn't exclude internal rules. rulesForCat' :: CF -> Cat -> [Rule]-rulesForCat' cf cat = [normRuleFun r | r <- rulesOfCF cf, valCat r == cat] +rulesForCat' cf cat = [normRuleFun r | r <- rulesOfCF cf, valCat r == cat] valCat :: Rul f -> Cat valCat = fst . snd@@ -287,7 +287,7 @@ literals :: CFG f -> [Cat] literals cf = lits ++ owns- where + where (lits,_,_,_) = infoOfCF cf owns = map fst $ tokenPragmas cf @@ -300,7 +300,7 @@ where (_,_,keywords,_) = infoOfCF cf reversibleCats :: CFG f -> [Cat]-reversibleCats cf = cats +reversibleCats cf = cats where (_,_,_,cats) = infoOfCF cf -- Comments can be defined by the 'comment' pragma@@ -331,35 +331,35 @@ -- to print parse trees prTree :: Tree -> String-prTree (Tree (fun,[])) = fun +prTree (Tree (fun,[])) = fun prTree (Tree (fun,trees)) = fun +++ unwords (map pr2 trees) where pr2 t@(Tree (_,ts)) = (if (null ts) then id else prParenth) (prTree t) -- abstract syntax trees: data type definitions cf2data :: CF -> [Data]-cf2data cf = - [(cat, nub (map mkData [r | r@(f,_) <- rulesOfCF cf, +cf2data cf =+ [(cat, nub (map mkData [r | r@(f,_) <- rulesOfCF cf, not (isDefinedRule f),- not (isCoercion f), eqCat cat (valCat r)])) - | cat <- allNormalCats cf] + not (isCoercion f), eqCat cat (valCat r)]))+ | cat <- allNormalCats cf] where mkData (f,(_,its)) = (normFun f,[normCat c | Left c <- its, c /= internalCat]) --This version includes lists in the returned data. --Michael 4/03 cf2dataLists :: CF -> [Data]-cf2dataLists cf = - [(cat, nub (map mkData [r | r@(f,_) <- rulesOfCF cf, +cf2dataLists cf =+ [(cat, nub (map mkData [r | r@(f,_) <- rulesOfCF cf, not (isDefinedRule f),- not (isCoercion f), eqCat cat (valCat r)])) - | cat <- (filter (\x -> not $ isDigit $ last x) (allCats cf))] + not (isCoercion f), eqCat cat (valCat r)]))+ | cat <- (filter (\x -> not $ isDigit $ last x) (allCats cf))] where mkData (f,(_,its)) = (normFun f,[normCat c | Left c <- its, c /= internalCat]) specialData :: CF -> [Data] specialData cf = [(c,[(c,[arg c])]) | c <- specialCats cf] where- arg c = case c of + arg c = case c of _ -> "String" allNormalCats :: CF -> [Cat]@@ -415,7 +415,7 @@ isParsable _ = True isList :: Cat -> Bool-isList c = head c == '[' +isList c = head c == '[' unList :: Cat -> Cat unList c = c@@ -427,9 +427,9 @@ isNilFun, isOneFun, isConsFun, isNilCons :: Fun -> Bool isNilCons f = isNilFun f || isOneFun f || isConsFun f-isNilFun f = f == "[]" -isOneFun f = f == "(:[])" -isConsFun f = f == "(:)" +isNilFun f = f == "[]"+isOneFun f = f == "(:[])"+isConsFun f = f == "(:)" isEmptyListCat :: CF -> Cat -> Bool isEmptyListCat cf c = elem "[]" $ map fst $ rulesForCat' cf c@@ -440,19 +440,19 @@ -- applies only if the [] rule has no terminals revSepListRule :: Rul f -> Rul f revSepListRule r@(f,(c, ts)) = (f, (c, xs : x : sep)) where- (x,sep,xs) = (head ts, init (tail ts), last ts) + (x,sep,xs) = (head ts, init (tail ts), last ts) -- invariant: test in findAllReversibleCats have been performed findAllReversibleCats :: CF -> [Cat] findAllReversibleCats cf = [c | (c,r) <- ruleGroups cf, isRev c r] where isRev c rs = case rs of- [r1,r2] | isList c -> if isConsFun (funRule r2) + [r1,r2] | isList c -> if isConsFun (funRule r2) then tryRev r2 r1- else if isConsFun (funRule r1) + else if isConsFun (funRule r1) then tryRev r1 r2 else False _ -> False- tryRev (f,(_,ts@(x:_:xs))) r = isEmptyNilRule r && + tryRev (f,(_,ts@(x:_:xs))) r = isEmptyNilRule r && isConsFun f && isNonterm x && isNonterm (last ts) tryRev _ _ = False @@ -481,7 +481,7 @@ ([],c') -> (reverse c', 0) (d,c') -> (reverse c', read (reverse d)) --- we should actually check that +-- we should actually check that -- (1) coercions are always between variants -- (2) no other digits are used @@ -506,15 +506,15 @@ badNil = isNilFun f && not (isList c && null cs) badOne = isOneFun f && not (isList c && cs == [catOfList c]) badCons = isConsFun f && not (isList c && cs == [catOfList c, c])- badList = isList c && + badList = isList c && not (isCoercion f || isNilFun f || isOneFun f || isConsFun f) badSpecial = elem c specialCatsP && not (isCoercion f) badMissing = not (null missing)- missing = filter nodef [c | Left c <- rhs] + missing = filter nodef [c | Left c <- rhs] nodef t = notElem t defineds- defineds = - "#" : map fst (tokenPragmas cf) ++ specialCatsP ++ map valCat (rulesOfCF cf) + defineds =+ "#" : map fst (tokenPragmas cf) ++ specialCatsP ++ map valCat (rulesOfCF cf) badTypeName = not (null badtypes) badtypes = filter isBadType $ cat : [c | Left c <- rhs] isBadType c = not (isUpper (head c) || isList c || c == "#")@@ -555,7 +555,7 @@ ruleGroupsP cf = [(c, rulesForCatP cf c) | c <- allCatsP cf] rulesForCatP :: CFP -> Cat -> [RuleP]-rulesForCatP cf cat = [r | r <- rulesOfCFP cf, isParsable r, valCat r == cat] +rulesForCatP cf cat = [r | r <- rulesOfCFP cf, isParsable r, valCat r == cat] allCatsP :: CFP -> [Cat] allCatsP = nub . map valCat . rulesOfCFP -- no cats w/o production
@@ -20,17 +20,17 @@ module GetCF where -import Directory ( doesFileExist, renameFile )-import Monad ( when )+import System.Directory ( doesFileExist, renameFile )+import Control.Monad ( when ) import CF import Utils import ParBNF-import List(nub,partition)+import Data.List(nub,partition) import qualified AbsBNF as Abs -- import LexBNF import ErrM-import Char+import Data.Char import TypeChecker readCF :: FilePath -> IO CF
@@ -1,7 +1,7 @@ {- BNF Converter: Main file- Copyright (C) 2002-2010 Authors: - Björn Bringert, Johan Broberg, Markus Forberg, Peter Gammie, + Copyright (C) 2002-2010 Authors:+ Björn Bringert, Johan Broberg, Markus Forberg, Peter Gammie, Patrik Jansson, Antti-Juhani Kaijanaho, Ulf Norell, Michael Pellauer, Aarne Ranta @@ -41,15 +41,17 @@ import MultiView (preprocessMCF, mkTestMulti, mkMakefileMulti) -import System+import System.IO+import System.Cmd import System.Exit-import Char+import System.Environment+import Data.Char import Data.List (elemIndex) -version = "2.4.2.0"+version = "2.4.2.1" title = unlines [- "The BNF Converter, "++version, + "The BNF Converter, "++version, "(c) Krasimir Angelov, Bjorn Bringert, Johan Broberg, Paul Callaghan, ", " Markus Forsberg, Ola Frid, Peter Gammie, Patrik Jansson, ", " Kristofer Johannisson, Antti-Juhani Kaijanaho, Ulf Norell, ",@@ -57,11 +59,11 @@ "Free software under GNU General Public License (GPL).", "Bug reports to {markus,aarne}@cs.chalmers.se." ]- + main :: IO () main = do xx <- getArgs- + case xx of ["--numeric-version"] -> do putStrLn version@@ -100,7 +102,7 @@ alex2StringSharing = elem "-sharestrings" args alex2ByteString = elem "-bytestrings" args glr = "-glr" `elem` args- let xml = if elem "-xml" args then 1 else + let xml = if elem "-xml" args then 1 else if elem "-xmlt" args then 2 else 0 let inDir = elem "-d" args let vsfiles = elem "-vs" args@@ -114,8 +116,8 @@ printUsage if checkUsage False [c, cpp, cpp_stl, csharp, java, haskell, profile] then do- if (isCF (reverse file)) then - do + if (isCF (reverse file)) then+ do putStrLn title case () of _ | c -> makeC make name file@@ -129,23 +131,23 @@ _ | profile-> makeAllProfile make alex1or2 False xml name file _ | haskellGADT -> makeAllGADT make alex1or2 inDir alex2StringSharing alex2ByteString glr xml inPackage name file _ -> makeAll make alex1or2 inDir alex2StringSharing alex2ByteString glr xml inPackage name multi file- if (make && multi) - then (system ("cp Makefile Makefile_" ++ name)) >> return () + if (make && multi)+ then (system ("cp Makefile Makefile_" ++ name)) >> return () else return () else endFileErr else endLanguageErr where isCF ('f':'c':'.':_) = True isCF _ = False- endFileErr = do + endFileErr = do putStr title putStrLn "Error: the input file must end with .cf" exitFailure- endLanguageErr = do + endLanguageErr = do putStr title putStrLn "Error: only one language mode may be chosen" exitFailure- -printUsage = do ++printUsage = do putStrLn title putStrLn "Usage: bnfc <makeoption>* <language>? <special>* file.cf" putStrLn ""
@@ -20,17 +20,17 @@ module MultiView where -import Directory ( doesFileExist, renameFile )+import System.Directory ( doesFileExist, renameFile ) import qualified CF as CF import Utils import ParBNF import PrintBNF-import List(nub,partition)+import Data.List(nub,partition) import AbsBNF -- import LexBNF import ErrM-import Char+import Data.Char import TypeChecker preprocessMCF :: FilePath -> IO ([FilePath],String)@@ -46,8 +46,8 @@ return $ (map fst grs,entryp) extract :: String -> LGrammar -> [(FilePath, Grammar)]-extract name (LGr ldefs) = - [(file lang,Grammar [unldef ldef | ldef <- ldefs, isFor lang ldef]) | +extract name (LGr ldefs) =+ [(file lang,Grammar [unldef ldef | ldef <- ldefs, isFor lang ldef]) | lang <- views] where views = [lang | LDefView langs <- ldefs, Ident lang <- langs]@@ -63,7 +63,7 @@ --- the entrypoint is the same for all languages - could be different entrypoint :: LGrammar -> String-entrypoint (LGr rs0) = head $ +entrypoint (LGr rs0) = head $ [c | Entryp (Ident c:_) <- rs] ++ [c | Rule _ (IdCat (Ident c)) _ <- rs] where@@ -74,11 +74,11 @@ _ -> [] --- LDefView writeCF :: (FilePath, Grammar) -> IO ()-writeCF (file,gr) = do +writeCF (file,gr) = do writeFile file $ printTree gr putStrLn $ "wrote file " ++ file ----- These are Haskell specific; +---- These are Haskell specific; ---- should be generalized by inspecting the options xx mkTestMulti :: String -> [String] -> FilePath -> [FilePath] -> IO ()@@ -96,7 +96,7 @@ writeFile "Makefile" content makefile xx abs cncs = unlines $- "all:" : + "all:" : ["\tmake -f Makefile_" ++ cnc | cnc <- cncs] ++ ["\tghc --make -o TestTrans" ++ abs ++ " TestTrans" ++ abs, ""@@ -109,7 +109,7 @@ ["import qualified Print" ++ cnc | cnc <- cncs] ++ ["import Abs" ++ abs, "import ErrM",- "import System (getArgs)",+ "import System.IO (getArgs)", "", "main :: IO ()", "main = do",
@@ -4,7 +4,7 @@ import AbsBNF import LexBNF import ErrM-import Array+import Data.Array #if __GLASGOW_HASKELL__ >= 503 import GHC.Exts #else@@ -369,49 +369,49 @@ happyReduce_32 = happySpecReduce_1 0# happyReduction_32 happyReduction_32 happy_x_1- = case happyOutTok happy_x_1 of { (PT _ (TL happy_var_1)) -> + = case happyOutTok happy_x_1 of { (PT _ (TL happy_var_1)) -> happyIn35 (happy_var_1 )} happyReduce_33 = happySpecReduce_1 1# happyReduction_33 happyReduction_33 happy_x_1- = case happyOutTok happy_x_1 of { (PT _ (TV happy_var_1)) -> + = case happyOutTok happy_x_1 of { (PT _ (TV happy_var_1)) -> happyIn36 (Ident happy_var_1 )} happyReduce_34 = happySpecReduce_1 2# happyReduction_34 happyReduction_34 happy_x_1- = case happyOutTok happy_x_1 of { (PT _ (TI happy_var_1)) -> + = case happyOutTok happy_x_1 of { (PT _ (TI happy_var_1)) -> happyIn37 ((read happy_var_1) :: Integer )} happyReduce_35 = happySpecReduce_1 3# happyReduction_35 happyReduction_35 happy_x_1- = case happyOutTok happy_x_1 of { (PT _ (TC happy_var_1)) -> + = case happyOutTok happy_x_1 of { (PT _ (TC happy_var_1)) -> happyIn38 ((read happy_var_1) :: Char )} happyReduce_36 = happySpecReduce_1 4# happyReduction_36 happyReduction_36 happy_x_1- = case happyOutTok happy_x_1 of { (PT _ (TD happy_var_1)) -> + = case happyOutTok happy_x_1 of { (PT _ (TD happy_var_1)) -> happyIn39 ((read happy_var_1) :: Double )} happyReduce_37 = happySpecReduce_1 5# happyReduction_37 happyReduction_37 happy_x_1- = case happyOut42 happy_x_1 of { happy_var_1 -> + = case happyOut42 happy_x_1 of { happy_var_1 -> happyIn40 (LGr happy_var_1 )} happyReduce_38 = happySpecReduce_1 6# happyReduction_38 happyReduction_38 happy_x_1- = case happyOut46 happy_x_1 of { happy_var_1 -> + = case happyOut46 happy_x_1 of { happy_var_1 -> happyIn41 (DefAll happy_var_1 )}@@ -420,8 +420,8 @@ happyReduction_39 happy_x_3 happy_x_2 happy_x_1- = case happyOut71 happy_x_1 of { happy_var_1 -> - case happyOut46 happy_x_3 of { happy_var_3 -> + = case happyOut71 happy_x_1 of { happy_var_1 ->+ case happyOut46 happy_x_3 of { happy_var_3 -> happyIn41 (DefSome happy_var_1 happy_var_3 )}}@@ -429,7 +429,7 @@ happyReduce_40 = happySpecReduce_2 6# happyReduction_40 happyReduction_40 happy_x_2 happy_x_1- = case happyOut71 happy_x_2 of { happy_var_2 -> + = case happyOut71 happy_x_2 of { happy_var_2 -> happyIn41 (LDefView happy_var_2 )}@@ -441,7 +441,7 @@ happyReduce_42 = happySpecReduce_1 7# happyReduction_42 happyReduction_42 happy_x_1- = case happyOut41 happy_x_1 of { happy_var_1 -> + = case happyOut41 happy_x_1 of { happy_var_1 -> happyIn42 ((:[]) happy_var_1 )}@@ -450,15 +450,15 @@ happyReduction_43 happy_x_3 happy_x_2 happy_x_1- = case happyOut41 happy_x_1 of { happy_var_1 -> - case happyOut42 happy_x_3 of { happy_var_3 -> + = case happyOut41 happy_x_1 of { happy_var_1 ->+ case happyOut42 happy_x_3 of { happy_var_3 -> happyIn42 ((:) happy_var_1 happy_var_3 )}} happyReduce_44 = happySpecReduce_1 8# happyReduction_44 happyReduction_44 happy_x_1- = case happyOut44 happy_x_1 of { happy_var_1 -> + = case happyOut44 happy_x_1 of { happy_var_1 -> happyIn43 (Grammar happy_var_1 )}@@ -470,7 +470,7 @@ happyReduce_46 = happySpecReduce_1 9# happyReduction_46 happyReduction_46 happy_x_1- = case happyOut46 happy_x_1 of { happy_var_1 -> + = case happyOut46 happy_x_1 of { happy_var_1 -> happyIn44 ((:[]) happy_var_1 )}@@ -479,8 +479,8 @@ happyReduction_47 happy_x_3 happy_x_2 happy_x_1- = case happyOut46 happy_x_1 of { happy_var_1 -> - case happyOut44 happy_x_3 of { happy_var_3 -> + = case happyOut46 happy_x_1 of { happy_var_1 ->+ case happyOut44 happy_x_3 of { happy_var_3 -> happyIn44 ((:) happy_var_1 happy_var_3 )}}@@ -493,8 +493,8 @@ happyReduce_49 = happySpecReduce_2 10# happyReduction_49 happyReduction_49 happy_x_2 happy_x_1- = case happyOut45 happy_x_1 of { happy_var_1 -> - case happyOut47 happy_x_2 of { happy_var_2 -> + = case happyOut45 happy_x_1 of { happy_var_1 ->+ case happyOut47 happy_x_2 of { happy_var_2 -> happyIn45 (flip (:) happy_var_1 happy_var_2 )}}@@ -506,9 +506,9 @@ happy_x_2 `HappyStk` happy_x_1 `HappyStk` happyRest)- = case happyOut49 happy_x_1 of { happy_var_1 -> - case happyOut48 happy_x_3 of { happy_var_3 -> - case happyOut45 happy_x_5 of { happy_var_5 -> + = case happyOut49 happy_x_1 of { happy_var_1 ->+ case happyOut48 happy_x_3 of { happy_var_3 ->+ case happyOut45 happy_x_5 of { happy_var_5 -> happyIn46 (Rule happy_var_1 happy_var_3 (reverse happy_var_5) ) `HappyStk` happyRest}}}@@ -516,7 +516,7 @@ happyReduce_51 = happySpecReduce_2 11# happyReduction_51 happyReduction_51 happy_x_2 happy_x_1- = case happyOut35 happy_x_2 of { happy_var_2 -> + = case happyOut35 happy_x_2 of { happy_var_2 -> happyIn46 (Comment happy_var_2 )}@@ -525,8 +525,8 @@ happyReduction_52 happy_x_3 happy_x_2 happy_x_1- = case happyOut35 happy_x_2 of { happy_var_2 -> - case happyOut35 happy_x_3 of { happy_var_3 -> + = case happyOut35 happy_x_2 of { happy_var_2 ->+ case happyOut35 happy_x_3 of { happy_var_3 -> happyIn46 (Comments happy_var_2 happy_var_3 )}}@@ -539,9 +539,9 @@ happy_x_2 `HappyStk` happy_x_1 `HappyStk` happyRest)- = case happyOut49 happy_x_2 of { happy_var_2 -> - case happyOut48 happy_x_4 of { happy_var_4 -> - case happyOut45 happy_x_6 of { happy_var_6 -> + = case happyOut49 happy_x_2 of { happy_var_2 ->+ case happyOut48 happy_x_4 of { happy_var_4 ->+ case happyOut45 happy_x_6 of { happy_var_6 -> happyIn46 (Internal happy_var_2 happy_var_4 (reverse happy_var_6) ) `HappyStk` happyRest}}}@@ -550,8 +550,8 @@ happyReduction_54 happy_x_3 happy_x_2 happy_x_1- = case happyOut36 happy_x_2 of { happy_var_2 -> - case happyOut70 happy_x_3 of { happy_var_3 -> + = case happyOut36 happy_x_2 of { happy_var_2 ->+ case happyOut70 happy_x_3 of { happy_var_3 -> happyIn46 (Token happy_var_2 happy_var_3 )}}@@ -562,8 +562,8 @@ happy_x_2 `HappyStk` happy_x_1 `HappyStk` happyRest)- = case happyOut36 happy_x_3 of { happy_var_3 -> - case happyOut70 happy_x_4 of { happy_var_4 -> + = case happyOut36 happy_x_3 of { happy_var_3 ->+ case happyOut70 happy_x_4 of { happy_var_4 -> happyIn46 (PosToken happy_var_3 happy_var_4 ) `HappyStk` happyRest}}@@ -571,7 +571,7 @@ happyReduce_56 = happySpecReduce_2 11# happyReduction_56 happyReduction_56 happy_x_2 happy_x_1- = case happyOut71 happy_x_2 of { happy_var_2 -> + = case happyOut71 happy_x_2 of { happy_var_2 -> happyIn46 (Entryp happy_var_2 )}@@ -582,9 +582,9 @@ happy_x_2 `HappyStk` happy_x_1 `HappyStk` happyRest)- = case happyOut66 happy_x_2 of { happy_var_2 -> - case happyOut48 happy_x_3 of { happy_var_3 -> - case happyOut35 happy_x_4 of { happy_var_4 -> + = case happyOut66 happy_x_2 of { happy_var_2 ->+ case happyOut48 happy_x_3 of { happy_var_3 ->+ case happyOut35 happy_x_4 of { happy_var_4 -> happyIn46 (Separator happy_var_2 happy_var_3 happy_var_4 ) `HappyStk` happyRest}}}@@ -595,9 +595,9 @@ happy_x_2 `HappyStk` happy_x_1 `HappyStk` happyRest)- = case happyOut66 happy_x_2 of { happy_var_2 -> - case happyOut48 happy_x_3 of { happy_var_3 -> - case happyOut35 happy_x_4 of { happy_var_4 -> + = case happyOut66 happy_x_2 of { happy_var_2 ->+ case happyOut48 happy_x_3 of { happy_var_3 ->+ case happyOut35 happy_x_4 of { happy_var_4 -> happyIn46 (Terminator happy_var_2 happy_var_3 happy_var_4 ) `HappyStk` happyRest}}}@@ -606,8 +606,8 @@ happyReduction_59 happy_x_3 happy_x_2 happy_x_1- = case happyOut36 happy_x_2 of { happy_var_2 -> - case happyOut37 happy_x_3 of { happy_var_3 -> + = case happyOut36 happy_x_2 of { happy_var_2 ->+ case happyOut37 happy_x_3 of { happy_var_3 -> happyIn46 (Coercions happy_var_2 happy_var_3 )}}@@ -618,8 +618,8 @@ happy_x_2 `HappyStk` happy_x_1 `HappyStk` happyRest)- = case happyOut36 happy_x_2 of { happy_var_2 -> - case happyOut64 happy_x_4 of { happy_var_4 -> + = case happyOut36 happy_x_2 of { happy_var_2 ->+ case happyOut64 happy_x_4 of { happy_var_4 -> happyIn46 (Rules happy_var_2 happy_var_4 ) `HappyStk` happyRest}}@@ -631,9 +631,9 @@ happy_x_2 `HappyStk` happy_x_1 `HappyStk` happyRest)- = case happyOut36 happy_x_2 of { happy_var_2 -> - case happyOut57 happy_x_3 of { happy_var_3 -> - case happyOut58 happy_x_5 of { happy_var_5 -> + = case happyOut36 happy_x_2 of { happy_var_2 ->+ case happyOut57 happy_x_3 of { happy_var_3 ->+ case happyOut58 happy_x_5 of { happy_var_5 -> happyIn46 (Function happy_var_2 (reverse happy_var_3) happy_var_5 ) `HappyStk` happyRest}}}@@ -641,7 +641,7 @@ happyReduce_62 = happySpecReduce_2 11# happyReduction_62 happyReduction_62 happy_x_2 happy_x_1- = case happyOut63 happy_x_2 of { happy_var_2 -> + = case happyOut63 happy_x_2 of { happy_var_2 -> happyIn46 (Layout happy_var_2 )}@@ -650,7 +650,7 @@ happyReduction_63 happy_x_3 happy_x_2 happy_x_1- = case happyOut63 happy_x_3 of { happy_var_3 -> + = case happyOut63 happy_x_3 of { happy_var_3 -> happyIn46 (LayoutStop happy_var_3 )}@@ -664,14 +664,14 @@ happyReduce_65 = happySpecReduce_1 12# happyReduction_65 happyReduction_65 happy_x_1- = case happyOut35 happy_x_1 of { happy_var_1 -> + = case happyOut35 happy_x_1 of { happy_var_1 -> happyIn47 (Terminal happy_var_1 )} happyReduce_66 = happySpecReduce_1 12# happyReduction_66 happyReduction_66 happy_x_1- = case happyOut48 happy_x_1 of { happy_var_1 -> + = case happyOut48 happy_x_1 of { happy_var_1 -> happyIn47 (NTerminal happy_var_1 )}@@ -680,21 +680,21 @@ happyReduction_67 happy_x_3 happy_x_2 happy_x_1- = case happyOut48 happy_x_2 of { happy_var_2 -> + = case happyOut48 happy_x_2 of { happy_var_2 -> happyIn48 (ListCat happy_var_2 )} happyReduce_68 = happySpecReduce_1 13# happyReduction_68 happyReduction_68 happy_x_1- = case happyOut36 happy_x_1 of { happy_var_1 -> + = case happyOut36 happy_x_1 of { happy_var_1 -> happyIn48 (IdCat happy_var_1 )} happyReduce_69 = happySpecReduce_1 14# happyReduction_69 happyReduction_69 happy_x_1- = case happyOut50 happy_x_1 of { happy_var_1 -> + = case happyOut50 happy_x_1 of { happy_var_1 -> happyIn49 (LabNoP happy_var_1 )}@@ -702,8 +702,8 @@ happyReduce_70 = happySpecReduce_2 14# happyReduction_70 happyReduction_70 happy_x_2 happy_x_1- = case happyOut50 happy_x_1 of { happy_var_1 -> - case happyOut55 happy_x_2 of { happy_var_2 -> + = case happyOut50 happy_x_1 of { happy_var_1 ->+ case happyOut55 happy_x_2 of { happy_var_2 -> happyIn49 (LabP happy_var_1 happy_var_2 )}}@@ -712,9 +712,9 @@ happyReduction_71 happy_x_3 happy_x_2 happy_x_1- = case happyOut50 happy_x_1 of { happy_var_1 -> - case happyOut50 happy_x_2 of { happy_var_2 -> - case happyOut55 happy_x_3 of { happy_var_3 -> + = case happyOut50 happy_x_1 of { happy_var_1 ->+ case happyOut50 happy_x_2 of { happy_var_2 ->+ case happyOut55 happy_x_3 of { happy_var_3 -> happyIn49 (LabPF happy_var_1 happy_var_2 happy_var_3 )}}}@@ -722,15 +722,15 @@ happyReduce_72 = happySpecReduce_2 14# happyReduction_72 happyReduction_72 happy_x_2 happy_x_1- = case happyOut50 happy_x_1 of { happy_var_1 -> - case happyOut50 happy_x_2 of { happy_var_2 -> + = case happyOut50 happy_x_1 of { happy_var_1 ->+ case happyOut50 happy_x_2 of { happy_var_2 -> happyIn49 (LabF happy_var_1 happy_var_2 )}} happyReduce_73 = happySpecReduce_1 15# happyReduction_73 happyReduction_73 happy_x_1- = case happyOut36 happy_x_1 of { happy_var_1 -> + = case happyOut36 happy_x_1 of { happy_var_1 -> happyIn50 (Id happy_var_1 )}@@ -778,8 +778,8 @@ happy_x_2 `HappyStk` happy_x_1 `HappyStk` happyRest)- = case happyOut54 happy_x_3 of { happy_var_3 -> - case happyOut53 happy_x_7 of { happy_var_7 -> + = case happyOut54 happy_x_3 of { happy_var_3 ->+ case happyOut53 happy_x_7 of { happy_var_7 -> happyIn51 (ProfIt happy_var_3 happy_var_7 ) `HappyStk` happyRest}}@@ -788,7 +788,7 @@ happyReduction_79 happy_x_3 happy_x_2 happy_x_1- = case happyOut53 happy_x_2 of { happy_var_2 -> + = case happyOut53 happy_x_2 of { happy_var_2 -> happyIn52 (Ints happy_var_2 )}@@ -800,7 +800,7 @@ happyReduce_81 = happySpecReduce_1 18# happyReduction_81 happyReduction_81 happy_x_1- = case happyOut37 happy_x_1 of { happy_var_1 -> + = case happyOut37 happy_x_1 of { happy_var_1 -> happyIn53 ((:[]) happy_var_1 )}@@ -809,8 +809,8 @@ happyReduction_82 happy_x_3 happy_x_2 happy_x_1- = case happyOut37 happy_x_1 of { happy_var_1 -> - case happyOut53 happy_x_3 of { happy_var_3 -> + = case happyOut37 happy_x_1 of { happy_var_1 ->+ case happyOut53 happy_x_3 of { happy_var_3 -> happyIn53 ((:) happy_var_1 happy_var_3 )}}@@ -822,7 +822,7 @@ happyReduce_84 = happySpecReduce_1 19# happyReduction_84 happyReduction_84 happy_x_1- = case happyOut52 happy_x_1 of { happy_var_1 -> + = case happyOut52 happy_x_1 of { happy_var_1 -> happyIn54 ((:[]) happy_var_1 )}@@ -831,15 +831,15 @@ happyReduction_85 happy_x_3 happy_x_2 happy_x_1- = case happyOut52 happy_x_1 of { happy_var_1 -> - case happyOut54 happy_x_3 of { happy_var_3 -> + = case happyOut52 happy_x_1 of { happy_var_1 ->+ case happyOut54 happy_x_3 of { happy_var_3 -> happyIn54 ((:) happy_var_1 happy_var_3 )}} happyReduce_86 = happySpecReduce_1 20# happyReduction_86 happyReduction_86 happy_x_1- = case happyOut51 happy_x_1 of { happy_var_1 -> + = case happyOut51 happy_x_1 of { happy_var_1 -> happyIn55 ((:[]) happy_var_1 )}@@ -847,15 +847,15 @@ happyReduce_87 = happySpecReduce_2 20# happyReduction_87 happyReduction_87 happy_x_2 happy_x_1- = case happyOut51 happy_x_1 of { happy_var_1 -> - case happyOut55 happy_x_2 of { happy_var_2 -> + = case happyOut51 happy_x_1 of { happy_var_1 ->+ case happyOut55 happy_x_2 of { happy_var_2 -> happyIn55 ((:) happy_var_1 happy_var_2 )}} happyReduce_88 = happySpecReduce_1 21# happyReduction_88 happyReduction_88 happy_x_1- = case happyOut36 happy_x_1 of { happy_var_1 -> + = case happyOut36 happy_x_1 of { happy_var_1 -> happyIn56 (Arg happy_var_1 )}@@ -868,8 +868,8 @@ happyReduce_90 = happySpecReduce_2 22# happyReduction_90 happyReduction_90 happy_x_2 happy_x_1- = case happyOut57 happy_x_1 of { happy_var_1 -> - case happyOut56 happy_x_2 of { happy_var_2 -> + = case happyOut57 happy_x_1 of { happy_var_1 ->+ case happyOut56 happy_x_2 of { happy_var_2 -> happyIn57 (flip (:) happy_var_1 happy_var_2 )}}@@ -878,15 +878,15 @@ happyReduction_91 happy_x_3 happy_x_2 happy_x_1- = case happyOut59 happy_x_1 of { happy_var_1 -> - case happyOut58 happy_x_3 of { happy_var_3 -> + = case happyOut59 happy_x_1 of { happy_var_1 ->+ case happyOut58 happy_x_3 of { happy_var_3 -> happyIn58 (Cons happy_var_1 happy_var_3 )}} happyReduce_92 = happySpecReduce_1 23# happyReduction_92 happyReduction_92 happy_x_1- = case happyOut59 happy_x_1 of { happy_var_1 -> + = case happyOut59 happy_x_1 of { happy_var_1 -> happyIn58 (happy_var_1 )}@@ -894,50 +894,50 @@ happyReduce_93 = happySpecReduce_2 24# happyReduction_93 happyReduction_93 happy_x_2 happy_x_1- = case happyOut36 happy_x_1 of { happy_var_1 -> - case happyOut61 happy_x_2 of { happy_var_2 -> + = case happyOut36 happy_x_1 of { happy_var_1 ->+ case happyOut61 happy_x_2 of { happy_var_2 -> happyIn59 (App happy_var_1 happy_var_2 )}} happyReduce_94 = happySpecReduce_1 24# happyReduction_94 happyReduction_94 happy_x_1- = case happyOut60 happy_x_1 of { happy_var_1 -> + = case happyOut60 happy_x_1 of { happy_var_1 -> happyIn59 (happy_var_1 )} happyReduce_95 = happySpecReduce_1 25# happyReduction_95 happyReduction_95 happy_x_1- = case happyOut36 happy_x_1 of { happy_var_1 -> + = case happyOut36 happy_x_1 of { happy_var_1 -> happyIn60 (Var happy_var_1 )} happyReduce_96 = happySpecReduce_1 25# happyReduction_96 happyReduction_96 happy_x_1- = case happyOut37 happy_x_1 of { happy_var_1 -> + = case happyOut37 happy_x_1 of { happy_var_1 -> happyIn60 (LitInt happy_var_1 )} happyReduce_97 = happySpecReduce_1 25# happyReduction_97 happyReduction_97 happy_x_1- = case happyOut38 happy_x_1 of { happy_var_1 -> + = case happyOut38 happy_x_1 of { happy_var_1 -> happyIn60 (LitChar happy_var_1 )} happyReduce_98 = happySpecReduce_1 25# happyReduction_98 happyReduction_98 happy_x_1- = case happyOut35 happy_x_1 of { happy_var_1 -> + = case happyOut35 happy_x_1 of { happy_var_1 -> happyIn60 (LitString happy_var_1 )} happyReduce_99 = happySpecReduce_1 25# happyReduction_99 happyReduction_99 happy_x_1- = case happyOut39 happy_x_1 of { happy_var_1 -> + = case happyOut39 happy_x_1 of { happy_var_1 -> happyIn60 (LitDouble happy_var_1 )}@@ -946,7 +946,7 @@ happyReduction_100 happy_x_3 happy_x_2 happy_x_1- = case happyOut62 happy_x_2 of { happy_var_2 -> + = case happyOut62 happy_x_2 of { happy_var_2 -> happyIn60 (List happy_var_2 )}@@ -955,14 +955,14 @@ happyReduction_101 happy_x_3 happy_x_2 happy_x_1- = case happyOut58 happy_x_2 of { happy_var_2 -> + = case happyOut58 happy_x_2 of { happy_var_2 -> happyIn60 (happy_var_2 )} happyReduce_102 = happySpecReduce_1 26# happyReduction_102 happyReduction_102 happy_x_1- = case happyOut60 happy_x_1 of { happy_var_1 -> + = case happyOut60 happy_x_1 of { happy_var_1 -> happyIn61 ((:[]) happy_var_1 )}@@ -970,8 +970,8 @@ happyReduce_103 = happySpecReduce_2 26# happyReduction_103 happyReduction_103 happy_x_2 happy_x_1- = case happyOut60 happy_x_1 of { happy_var_1 -> - case happyOut61 happy_x_2 of { happy_var_2 -> + = case happyOut60 happy_x_1 of { happy_var_1 ->+ case happyOut61 happy_x_2 of { happy_var_2 -> happyIn61 ((:) happy_var_1 happy_var_2 )}}@@ -983,7 +983,7 @@ happyReduce_105 = happySpecReduce_1 27# happyReduction_105 happyReduction_105 happy_x_1- = case happyOut58 happy_x_1 of { happy_var_1 -> + = case happyOut58 happy_x_1 of { happy_var_1 -> happyIn62 ((:[]) happy_var_1 )}@@ -992,15 +992,15 @@ happyReduction_106 happy_x_3 happy_x_2 happy_x_1- = case happyOut58 happy_x_1 of { happy_var_1 -> - case happyOut62 happy_x_3 of { happy_var_3 -> + = case happyOut58 happy_x_1 of { happy_var_1 ->+ case happyOut62 happy_x_3 of { happy_var_3 -> happyIn62 ((:) happy_var_1 happy_var_3 )}} happyReduce_107 = happySpecReduce_1 28# happyReduction_107 happyReduction_107 happy_x_1- = case happyOut35 happy_x_1 of { happy_var_1 -> + = case happyOut35 happy_x_1 of { happy_var_1 -> happyIn63 ((:[]) happy_var_1 )}@@ -1009,15 +1009,15 @@ happyReduction_108 happy_x_3 happy_x_2 happy_x_1- = case happyOut35 happy_x_1 of { happy_var_1 -> - case happyOut63 happy_x_3 of { happy_var_3 -> + = case happyOut35 happy_x_1 of { happy_var_1 ->+ case happyOut63 happy_x_3 of { happy_var_3 -> happyIn63 ((:) happy_var_1 happy_var_3 )}} happyReduce_109 = happySpecReduce_1 29# happyReduction_109 happyReduction_109 happy_x_1- = case happyOut65 happy_x_1 of { happy_var_1 -> + = case happyOut65 happy_x_1 of { happy_var_1 -> happyIn64 ((:[]) happy_var_1 )}@@ -1026,15 +1026,15 @@ happyReduction_110 happy_x_3 happy_x_2 happy_x_1- = case happyOut65 happy_x_1 of { happy_var_1 -> - case happyOut64 happy_x_3 of { happy_var_3 -> + = case happyOut65 happy_x_1 of { happy_var_1 ->+ case happyOut64 happy_x_3 of { happy_var_3 -> happyIn64 ((:) happy_var_1 happy_var_3 )}} happyReduce_111 = happySpecReduce_1 30# happyReduction_111 happyReduction_111 happy_x_1- = case happyOut45 happy_x_1 of { happy_var_1 -> + = case happyOut45 happy_x_1 of { happy_var_1 -> happyIn65 (RHS (reverse happy_var_1) )}@@ -1053,15 +1053,15 @@ happyReduce_114 = happySpecReduce_2 32# happyReduction_114 happyReduction_114 happy_x_2 happy_x_1- = case happyOut67 happy_x_1 of { happy_var_1 -> - case happyOut69 happy_x_2 of { happy_var_2 -> + = case happyOut67 happy_x_1 of { happy_var_1 ->+ case happyOut69 happy_x_2 of { happy_var_2 -> happyIn67 (RSeq happy_var_1 happy_var_2 )}} happyReduce_115 = happySpecReduce_1 32# happyReduction_115 happyReduction_115 happy_x_1- = case happyOut69 happy_x_1 of { happy_var_1 -> + = case happyOut69 happy_x_1 of { happy_var_1 -> happyIn67 (happy_var_1 )}@@ -1070,8 +1070,8 @@ happyReduction_116 happy_x_3 happy_x_2 happy_x_1- = case happyOut68 happy_x_1 of { happy_var_1 -> - case happyOut67 happy_x_3 of { happy_var_3 -> + = case happyOut68 happy_x_1 of { happy_var_1 ->+ case happyOut67 happy_x_3 of { happy_var_3 -> happyIn68 (RAlt happy_var_1 happy_var_3 )}}@@ -1080,15 +1080,15 @@ happyReduction_117 happy_x_3 happy_x_2 happy_x_1- = case happyOut67 happy_x_1 of { happy_var_1 -> - case happyOut67 happy_x_3 of { happy_var_3 -> + = case happyOut67 happy_x_1 of { happy_var_1 ->+ case happyOut67 happy_x_3 of { happy_var_3 -> happyIn68 (RMinus happy_var_1 happy_var_3 )}} happyReduce_118 = happySpecReduce_1 33# happyReduction_118 happyReduction_118 happy_x_1- = case happyOut67 happy_x_1 of { happy_var_1 -> + = case happyOut67 happy_x_1 of { happy_var_1 -> happyIn68 (happy_var_1 )}@@ -1096,7 +1096,7 @@ happyReduce_119 = happySpecReduce_2 34# happyReduction_119 happyReduction_119 happy_x_2 happy_x_1- = case happyOut69 happy_x_1 of { happy_var_1 -> + = case happyOut69 happy_x_1 of { happy_var_1 -> happyIn69 (RStar happy_var_1 )}@@ -1104,7 +1104,7 @@ happyReduce_120 = happySpecReduce_2 34# happyReduction_120 happyReduction_120 happy_x_2 happy_x_1- = case happyOut69 happy_x_1 of { happy_var_1 -> + = case happyOut69 happy_x_1 of { happy_var_1 -> happyIn69 (RPlus happy_var_1 )}@@ -1112,7 +1112,7 @@ happyReduce_121 = happySpecReduce_2 34# happyReduction_121 happyReduction_121 happy_x_2 happy_x_1- = case happyOut69 happy_x_1 of { happy_var_1 -> + = case happyOut69 happy_x_1 of { happy_var_1 -> happyIn69 (ROpt happy_var_1 )}@@ -1125,7 +1125,7 @@ happyReduce_123 = happySpecReduce_1 34# happyReduction_123 happyReduction_123 happy_x_1- = case happyOut38 happy_x_1 of { happy_var_1 -> + = case happyOut38 happy_x_1 of { happy_var_1 -> happyIn69 (RChar happy_var_1 )}@@ -1134,7 +1134,7 @@ happyReduction_124 happy_x_3 happy_x_2 happy_x_1- = case happyOut35 happy_x_2 of { happy_var_2 -> + = case happyOut35 happy_x_2 of { happy_var_2 -> happyIn69 (RAlts happy_var_2 )}@@ -1143,7 +1143,7 @@ happyReduction_125 happy_x_3 happy_x_2 happy_x_1- = case happyOut35 happy_x_2 of { happy_var_2 -> + = case happyOut35 happy_x_2 of { happy_var_2 -> happyIn69 (RSeqs happy_var_2 )}@@ -1182,21 +1182,21 @@ happyReduction_131 happy_x_3 happy_x_2 happy_x_1- = case happyOut70 happy_x_2 of { happy_var_2 -> + = case happyOut70 happy_x_2 of { happy_var_2 -> happyIn69 (happy_var_2 )} happyReduce_132 = happySpecReduce_1 35# happyReduction_132 happyReduction_132 happy_x_1- = case happyOut68 happy_x_1 of { happy_var_1 -> + = case happyOut68 happy_x_1 of { happy_var_1 -> happyIn70 (happy_var_1 )} happyReduce_133 = happySpecReduce_1 36# happyReduction_133 happyReduction_133 happy_x_1- = case happyOut36 happy_x_1 of { happy_var_1 -> + = case happyOut36 happy_x_1 of { happy_var_1 -> happyIn71 ((:[]) happy_var_1 )}@@ -1205,8 +1205,8 @@ happyReduction_134 happy_x_3 happy_x_2 happy_x_1- = case happyOut36 happy_x_1 of { happy_var_1 -> - case happyOut71 happy_x_3 of { happy_var_3 -> + = case happyOut36 happy_x_1 of { happy_var_1 ->+ case happyOut71 happy_x_3 of { happy_var_3 -> happyIn71 ((:) happy_var_1 happy_var_3 )}}@@ -1383,7 +1383,7 @@ happyError :: [Token] -> Err a happyError ts =- Bad $ "syntax error at " ++ tokenPos ts ++ + Bad $ "syntax error at " ++ tokenPos ts ++ case ts of [] -> [] [Err _] -> " due to lexer error"@@ -1437,7 +1437,7 @@ -- the stack in this case. happyAccept 0# tk st sts (_ `HappyStk` ans `HappyStk` _) = happyReturn1 ans-happyAccept j tk st sts (HappyStk ans _) = +happyAccept j tk st sts (HappyStk ans _) = (happyTcHack j (happyTcHack st)) (happyReturn1 ans) -----------------------------------------------------------------------------@@ -1574,7 +1574,7 @@ -- Moving to a new state after a reduction -happyGoto nt j tk st = +happyGoto nt j tk st = {- nothing -} happyDoAction j tk new_state where off = indexShortOffAddr happyGotoOffsets st@@ -1589,7 +1589,7 @@ -- parse error if we are in recovery and we fail again happyFail 0# tk old_st _ stk =--- trace "failing" $ +-- trace "failing" $ happyError_ tk {- We don't need state discarding for our restricted implementation of@@ -1597,7 +1597,7 @@ for now --SDM -- discard a state-happyFail 0# tk old_st (HappyCons ((action)) (sts)) +happyFail 0# tk old_st (HappyCons ((action)) (sts)) (saved_tok `HappyStk` _ `HappyStk` stk) = -- trace ("discarding state, depth " ++ show (length stk)) $ happyDoAction 0# tk action sts ((saved_tok`HappyStk`stk))@@ -1623,7 +1623,7 @@ -------------------------------------------------------------------------------- Seq-ing. If the --strict flag is given, then Happy emits +-- Seq-ing. If the --strict flag is given, then Happy emits -- happySeq = happyDoSeq -- otherwise it emits -- happySeq = happyDontSeq
@@ -4,7 +4,7 @@ -- pretty-printer generated by the BNF converter import AbsBNF-import Char+import Data.Char -- the top-level printing method printTree :: Print a => a -> String
@@ -0,0 +1,32 @@+module Paths_BNFC (+ version,+ getBinDir, getLibDir, getDataDir, getLibexecDir,+ getDataFileName+ ) where++import qualified Control.Exception as Exception+import Data.Version (Version(..))+import System.Environment (getEnv)+catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a+catchIO = Exception.catch+++version :: Version+version = Version {versionBranch = [2,4,2,1], versionTags = []}+bindir, libdir, datadir, libexecdir :: FilePath++bindir = "/home/abel/.cabal/bin"+libdir = "/home/abel/.cabal/lib/BNFC-2.4.2.1/ghc-7.4.1"+datadir = "/home/abel/.cabal/share/BNFC-2.4.2.1"+libexecdir = "/home/abel/.cabal/libexec"++getBinDir, getLibDir, getDataDir, getLibexecDir :: IO FilePath+getBinDir = catchIO (getEnv "BNFC_bindir") (\_ -> return bindir)+getLibDir = catchIO (getEnv "BNFC_libdir") (\_ -> return libdir)+getDataDir = catchIO (getEnv "BNFC_datadir") (\_ -> return datadir)+getLibexecDir = catchIO (getEnv "BNFC_libexecdir") (\_ -> return libexecdir)++getDataFileName :: FilePath -> IO FilePath+getDataFileName name = do+ dir <- getDataDir+ return (dir ++ "/" ++ name)
@@ -0,0 +1,37 @@+/* DO NOT EDIT: This file is automatically generated by Cabal */++/* package array-0.4.0.0 */+#define VERSION_array "0.4.0.0"+#define MIN_VERSION_array(major1,major2,minor) (\+ (major1) < 0 || \+ (major1) == 0 && (major2) < 4 || \+ (major1) == 0 && (major2) == 4 && (minor) <= 0)++/* package base-4.5.0.0 */+#define VERSION_base "4.5.0.0"+#define MIN_VERSION_base(major1,major2,minor) (\+ (major1) < 4 || \+ (major1) == 4 && (major2) < 5 || \+ (major1) == 4 && (major2) == 5 && (minor) <= 0)++/* package directory-1.1.0.2 */+#define VERSION_directory "1.1.0.2"+#define MIN_VERSION_directory(major1,major2,minor) (\+ (major1) < 1 || \+ (major1) == 1 && (major2) < 1 || \+ (major1) == 1 && (major2) == 1 && (minor) <= 0)++/* package mtl-2.0.1.0 */+#define VERSION_mtl "2.0.1.0"+#define MIN_VERSION_mtl(major1,major2,minor) (\+ (major1) < 2 || \+ (major1) == 2 && (major2) < 0 || \+ (major1) == 2 && (major2) == 0 && (minor) <= 1)++/* package process-1.1.0.1 */+#define VERSION_process "1.1.0.1"+#define MIN_VERSION_process(major1,major2,minor) (\+ (major1) < 1 || \+ (major1) == 1 && (major2) < 1 || \+ (major1) == 1 && (major2) == 1 && (minor) <= 0)+
file too large to diff
binary file changed (absent → 64777 bytes)
binary file changed (absent → 390832 bytes)
binary file changed (absent → 2003 bytes)
binary file changed (absent → 92384 bytes)
binary file changed (absent → 1773 bytes)
binary file changed (absent → 20048 bytes)
binary file changed (absent → 2069 bytes)
binary file changed (absent → 37576 bytes)
binary file changed (absent → 26863 bytes)
binary file changed (absent → 212696 bytes)
binary file changed (absent → 1251 bytes)
binary file changed (absent → 16392 bytes)
binary file changed (absent → 1568 bytes)
binary file changed (absent → 93216 bytes)
binary file changed (absent → 1703 bytes)
binary file changed (absent → 17904 bytes)
binary file changed (absent → 2682 bytes)
binary file changed (absent → 94272 bytes)
binary file changed (absent → 7099 bytes)
binary file changed (absent → 167496 bytes)
binary file changed (absent → 1491 bytes)
binary file changed (absent → 13144 bytes)
binary file changed (absent → 3344 bytes)
binary file changed (absent → 137528 bytes)
binary file changed (absent → 2571 bytes)
binary file changed (absent → 112288 bytes)
binary file changed (absent → 3622 bytes)
binary file changed (absent → 163664 bytes)
binary file changed (absent → 2218 bytes)
binary file changed (absent → 110088 bytes)
binary file changed (absent → 2244 bytes)
binary file changed (absent → 185616 bytes)
binary file changed (absent → 2116 bytes)
binary file changed (absent → 224784 bytes)
binary file changed (absent → 2159 bytes)
binary file changed (absent → 230448 bytes)
binary file changed (absent → 2513 bytes)
binary file changed (absent → 154512 bytes)
binary file changed (absent → 1908 bytes)
binary file changed (absent → 83568 bytes)
binary file changed (absent → 1914 bytes)
binary file changed (absent → 94264 bytes)
binary file changed (absent → 2023 bytes)
binary file changed (absent → 52144 bytes)
binary file changed (absent → 1952 bytes)
binary file changed (absent → 47864 bytes)
binary file changed (absent → 3141 bytes)
binary file changed (absent → 115192 bytes)
binary file changed (absent → 3143 bytes)
binary file changed (absent → 110712 bytes)
binary file changed (absent → 1884 bytes)
binary file changed (absent → 78112 bytes)
binary file changed (absent → 1664 bytes)
binary file changed (absent → 66256 bytes)
binary file changed (absent → 1948 bytes)
binary file changed (absent → 38704 bytes)
binary file changed (absent → 2036 bytes)
binary file changed (absent → 96824 bytes)
binary file changed (absent → 3432 bytes)
binary file changed (absent → 117688 bytes)
binary file changed (absent → 2998 bytes)
binary file changed (absent → 94432 bytes)
binary file changed (absent → 2256 bytes)
binary file changed (absent → 76616 bytes)
binary file changed (absent → 1722 bytes)
binary file changed (absent → 58040 bytes)
binary file changed (absent → 1714 bytes)
binary file changed (absent → 57616 bytes)
binary file changed (absent → 2108 bytes)
binary file changed (absent → 84728 bytes)
binary file changed (absent → 3036 bytes)
binary file changed (absent → 95968 bytes)
binary file changed (absent → 2002 bytes)
binary file changed (absent → 129520 bytes)
binary file changed (absent → 2203 bytes)
binary file changed (absent → 132896 bytes)
binary file changed (absent → 1638 bytes)
binary file changed (absent → 43768 bytes)
binary file changed (absent → 2120 bytes)
binary file changed (absent → 116528 bytes)
binary file changed (absent → 1795 bytes)
binary file changed (absent → 136008 bytes)
binary file changed (absent → 1428 bytes)
binary file changed (absent → 18240 bytes)
binary file changed (absent → 5464 bytes)
binary file changed (absent → 102864 bytes)
binary file changed (absent → 2295 bytes)
binary file changed (absent → 92984 bytes)
binary file changed (absent → 2132 bytes)
binary file changed (absent → 60984 bytes)
binary file changed (absent → 1657 bytes)
binary file changed (absent → 25896 bytes)
binary file changed (absent → 1206 bytes)
binary file changed (absent → 25664 bytes)
binary file changed (absent → 3679 bytes)
binary file changed (absent → 83112 bytes)
binary file changed (absent → 1844 bytes)
binary file changed (absent → 103104 bytes)
binary file changed (absent → 1923 bytes)
binary file changed (absent → 74568 bytes)
binary file changed (absent → 2126 bytes)
binary file changed (absent → 108752 bytes)
binary file changed (absent → 2421 bytes)
binary file changed (absent → 239080 bytes)
binary file changed (absent → 1368 bytes)
binary file changed (absent → 38712 bytes)
binary file changed (absent → 1491 bytes)
binary file changed (absent → 20744 bytes)
binary file changed (absent → 2046 bytes)
binary file changed (absent → 93456 bytes)
binary file changed (absent → 1821 bytes)
binary file changed (absent → 65048 bytes)
binary file changed (absent → 1942 bytes)
binary file changed (absent → 43224 bytes)
binary file changed (absent → 19585 bytes)
binary file changed (absent → 131792 bytes)
binary file changed (absent → 2836 bytes)
binary file changed (absent → 107520 bytes)
binary file changed (absent → 3359 bytes)
binary file changed (absent → 166568 bytes)
binary file changed (absent → 10133 bytes)
binary file changed (absent → 39360 bytes)
binary file changed (absent → 2799 bytes)
binary file changed (absent → 106336 bytes)
binary file changed (absent → 11330 bytes)
binary file changed (absent → 38088 bytes)
binary file changed (absent → 4725 bytes)
binary file changed (absent → 97912 bytes)
binary file changed (absent → 18414 bytes)
binary file changed (absent → 96576 bytes)
binary file changed (absent → 3179 bytes)
binary file changed (absent → 38432 bytes)
binary file changed (absent → 5604 bytes)
binary file changed (absent → 205888 bytes)
binary file changed (absent → 5334 bytes)
binary file changed (absent → 223144 bytes)
binary file changed (absent → 3110 bytes)
binary file changed (absent → 132248 bytes)
binary file changed (absent → 3535 bytes)
binary file changed (absent → 116832 bytes)
binary file changed (absent → 51013 bytes)
@@ -17,7 +17,7 @@ import Data.Array.Base (unsafeAt) #else import Array-import Char (ord)+import Data.Char (ord) #endif #if __GLASGOW_HASKELL__ >= 503 import GHC.Exts
binary file changed (absent → 189200 bytes)
binary file changed (absent → 7514 bytes)
binary file changed (absent → 89632 bytes)
binary file changed (absent → 5045 bytes)
binary file changed (absent → 15592 bytes)
binary file changed (absent → 8128 bytes)
binary file changed (absent → 24304 bytes)
binary file changed (absent → 9375 bytes)
binary file changed (absent → 52128 bytes)
binary file changed (absent → 5100 bytes)
binary file changed (absent → 23912 bytes)
binary file changed (absent → 4722 bytes)
binary file changed (absent → 97896 bytes)
binary file changed (absent → 13752 bytes)
binary file changed (absent → 50576 bytes)
binary file changed (absent → 7283 bytes)
binary file changed (absent → 42928 bytes)
binary file changed (absent → 160244 bytes)
binary file changed (absent → 357272 bytes)
binary file changed (absent → 35987 bytes)
binary file changed (absent → 252752 bytes)
binary file changed (absent → 2697 bytes)
binary file changed (absent → 74448 bytes)
binary file changed (absent → 5324 bytes)
binary file changed (absent → 40608 bytes)
binary file changed (absent → 5100 bytes)
binary file changed (absent → 41704 bytes)
binary file changed (absent → 5102 bytes)
binary file changed (absent → 41760 bytes)
binary file changed (absent → 7813 bytes)
binary file changed (absent → 51768 bytes)
binary file changed (absent → 3180 bytes)
binary file changed (absent → 124368 bytes)
binary file changed (absent → 2314 bytes)
binary file changed (absent → 6616 bytes)
binary file changed (absent → 12591 bytes)
binary file changed (absent → 84936 bytes)
binary file changed (absent → 8381 bytes)
binary file changed (absent → 26032 bytes)
@@ -0,0 +1,1 @@+[]
@@ -0,0 +1,2 @@+Saved package config for BNFC-2.4.2.1 written by Cabal-1.14.0 using ghc-7.4+LocalBuildInfo {configFlags = ConfigFlags {configPrograms = [], configProgramPaths = [], configProgramArgs = [], configHcFlavor = Flag GHC, configHcPath = NoFlag, configHcPkg = NoFlag, configVanillaLib = Flag True, configProfLib = Flag False, configSharedLib = Flag False, configDynExe = Flag False, configProfExe = Flag False, configConfigureArgs = [], configOptimization = Flag NormalOptimisation, configProgPrefix = Flag "", configProgSuffix = Flag "", configInstallDirs = InstallDirs {prefix = Flag "/home/abel/.cabal", bindir = NoFlag, libdir = NoFlag, libsubdir = NoFlag, dynlibdir = NoFlag, libexecdir = NoFlag, progdir = NoFlag, includedir = NoFlag, datadir = NoFlag, datasubdir = NoFlag, docdir = NoFlag, mandir = NoFlag, htmldir = NoFlag, haddockdir = NoFlag}, configScratchDir = NoFlag, configExtraLibDirs = [], configExtraIncludeDirs = [], configDistPref = Flag "dist", configVerbosity = Flag Normal, configUserInstall = Flag True, configPackageDB = NoFlag, configGHCiLib = Flag True, configSplitObjs = Flag False, configStripExes = Flag True, configConstraints = [Dependency (PackageName "process") (ThisVersion (Version {versionBranch = [1,1,0,1], versionTags = []})),Dependency (PackageName "mtl") (ThisVersion (Version {versionBranch = [2,0,1,0], versionTags = []})),Dependency (PackageName "directory") (ThisVersion (Version {versionBranch = [1,1,0,2], versionTags = []})),Dependency (PackageName "base") (ThisVersion (Version {versionBranch = [4,5,0,0], versionTags = []})),Dependency (PackageName "array") (ThisVersion (Version {versionBranch = [0,4,0,0], versionTags = []}))], configConfigurationsFlags = [], configTests = Flag False, configBenchmarks = Flag False, configLibCoverage = Flag False}, extraConfigArgs = [], installDirTemplates = InstallDirs {prefix = "/home/abel/.cabal", bindir = "$prefix/bin", libdir = "$prefix/lib", libsubdir = "$pkgid/$compiler", dynlibdir = "$libdir", libexecdir = "$prefix/libexec", progdir = "$libdir/hugs/programs", includedir = "$libdir/$libsubdir/include", datadir = "$prefix/share", datasubdir = "$pkgid", docdir = "$datadir/doc/$pkgid", mandir = "$datadir/man", htmldir = "$docdir/html", haddockdir = "$htmldir"}, compiler = Compiler {compilerId = CompilerId GHC (Version {versionBranch = [7,4,1], versionTags = []}), compilerLanguages = [(Haskell98,"-XHaskell98"),(Haskell2010,"-XHaskell2010")], compilerExtensions = [(UnknownExtension "Haskell98","-XHaskell98"),(UnknownExtension "Haskell2010","-XHaskell2010"),(UnknownExtension "Unsafe","-XUnsafe"),(EnableExtension Trustworthy,"-XTrustworthy"),(EnableExtension Safe,"-XSafe"),(EnableExtension CPP,"-XCPP"),(DisableExtension CPP,"-XNoCPP"),(EnableExtension PostfixOperators,"-XPostfixOperators"),(DisableExtension PostfixOperators,"-XNoPostfixOperators"),(EnableExtension TupleSections,"-XTupleSections"),(DisableExtension TupleSections,"-XNoTupleSections"),(EnableExtension PatternGuards,"-XPatternGuards"),(DisableExtension PatternGuards,"-XNoPatternGuards"),(EnableExtension UnicodeSyntax,"-XUnicodeSyntax"),(DisableExtension UnicodeSyntax,"-XNoUnicodeSyntax"),(EnableExtension MagicHash,"-XMagicHash"),(DisableExtension MagicHash,"-XNoMagicHash"),(EnableExtension PolymorphicComponents,"-XPolymorphicComponents"),(DisableExtension PolymorphicComponents,"-XNoPolymorphicComponents"),(EnableExtension ExistentialQuantification,"-XExistentialQuantification"),(DisableExtension ExistentialQuantification,"-XNoExistentialQuantification"),(EnableExtension KindSignatures,"-XKindSignatures"),(DisableExtension KindSignatures,"-XNoKindSignatures"),(EnableExtension EmptyDataDecls,"-XEmptyDataDecls"),(DisableExtension EmptyDataDecls,"-XNoEmptyDataDecls"),(EnableExtension ParallelListComp,"-XParallelListComp"),(DisableExtension ParallelListComp,"-XNoParallelListComp"),(EnableExtension TransformListComp,"-XTransformListComp"),(DisableExtension TransformListComp,"-XNoTransformListComp"),(UnknownExtension "MonadComprehensions","-XMonadComprehensions"),(UnknownExtension "NoMonadComprehensions","-XNoMonadComprehensions"),(EnableExtension ForeignFunctionInterface,"-XForeignFunctionInterface"),(DisableExtension ForeignFunctionInterface,"-XNoForeignFunctionInterface"),(EnableExtension UnliftedFFITypes,"-XUnliftedFFITypes"),(DisableExtension UnliftedFFITypes,"-XNoUnliftedFFITypes"),(UnknownExtension "InterruptibleFFI","-XInterruptibleFFI"),(UnknownExtension "NoInterruptibleFFI","-XNoInterruptibleFFI"),(UnknownExtension "CApiFFI","-XCApiFFI"),(UnknownExtension "NoCApiFFI","-XNoCApiFFI"),(EnableExtension GHCForeignImportPrim,"-XGHCForeignImportPrim"),(DisableExtension GHCForeignImportPrim,"-XNoGHCForeignImportPrim"),(EnableExtension LiberalTypeSynonyms,"-XLiberalTypeSynonyms"),(DisableExtension LiberalTypeSynonyms,"-XNoLiberalTypeSynonyms"),(EnableExtension Rank2Types,"-XRank2Types"),(DisableExtension Rank2Types,"-XNoRank2Types"),(EnableExtension RankNTypes,"-XRankNTypes"),(DisableExtension RankNTypes,"-XNoRankNTypes"),(EnableExtension ImpredicativeTypes,"-XImpredicativeTypes"),(DisableExtension ImpredicativeTypes,"-XNoImpredicativeTypes"),(EnableExtension TypeOperators,"-XTypeOperators"),(DisableExtension TypeOperators,"-XNoTypeOperators"),(EnableExtension RecursiveDo,"-XRecursiveDo"),(DisableExtension RecursiveDo,"-XNoRecursiveDo"),(EnableExtension DoRec,"-XDoRec"),(DisableExtension DoRec,"-XNoDoRec"),(EnableExtension Arrows,"-XArrows"),(DisableExtension Arrows,"-XNoArrows"),(UnknownExtension "ParallelArrays","-XParallelArrays"),(UnknownExtension "NoParallelArrays","-XNoParallelArrays"),(EnableExtension TemplateHaskell,"-XTemplateHaskell"),(DisableExtension TemplateHaskell,"-XNoTemplateHaskell"),(EnableExtension QuasiQuotes,"-XQuasiQuotes"),(DisableExtension QuasiQuotes,"-XNoQuasiQuotes"),(EnableExtension ImplicitPrelude,"-XImplicitPrelude"),(DisableExtension ImplicitPrelude,"-XNoImplicitPrelude"),(EnableExtension RecordWildCards,"-XRecordWildCards"),(DisableExtension RecordWildCards,"-XNoRecordWildCards"),(EnableExtension NamedFieldPuns,"-XNamedFieldPuns"),(DisableExtension NamedFieldPuns,"-XNoNamedFieldPuns"),(EnableExtension RecordPuns,"-XRecordPuns"),(DisableExtension RecordPuns,"-XNoRecordPuns"),(EnableExtension DisambiguateRecordFields,"-XDisambiguateRecordFields"),(DisableExtension DisambiguateRecordFields,"-XNoDisambiguateRecordFields"),(EnableExtension OverloadedStrings,"-XOverloadedStrings"),(DisableExtension OverloadedStrings,"-XNoOverloadedStrings"),(EnableExtension GADTs,"-XGADTs"),(DisableExtension GADTs,"-XNoGADTs"),(EnableExtension GADTSyntax,"-XGADTSyntax"),(DisableExtension GADTSyntax,"-XNoGADTSyntax"),(EnableExtension ViewPatterns,"-XViewPatterns"),(DisableExtension ViewPatterns,"-XNoViewPatterns"),(EnableExtension TypeFamilies,"-XTypeFamilies"),(DisableExtension TypeFamilies,"-XNoTypeFamilies"),(EnableExtension BangPatterns,"-XBangPatterns"),(DisableExtension BangPatterns,"-XNoBangPatterns"),(EnableExtension MonomorphismRestriction,"-XMonomorphismRestriction"),(DisableExtension MonomorphismRestriction,"-XNoMonomorphismRestriction"),(EnableExtension NPlusKPatterns,"-XNPlusKPatterns"),(DisableExtension NPlusKPatterns,"-XNoNPlusKPatterns"),(EnableExtension DoAndIfThenElse,"-XDoAndIfThenElse"),(DisableExtension DoAndIfThenElse,"-XNoDoAndIfThenElse"),(EnableExtension RebindableSyntax,"-XRebindableSyntax"),(DisableExtension RebindableSyntax,"-XNoRebindableSyntax"),(EnableExtension ConstraintKinds,"-XConstraintKinds"),(DisableExtension ConstraintKinds,"-XNoConstraintKinds"),(UnknownExtension "PolyKinds","-XPolyKinds"),(UnknownExtension "NoPolyKinds","-XNoPolyKinds"),(UnknownExtension "DataKinds","-XDataKinds"),(UnknownExtension "NoDataKinds","-XNoDataKinds"),(EnableExtension MonoPatBinds,"-XMonoPatBinds"),(DisableExtension MonoPatBinds,"-XNoMonoPatBinds"),(EnableExtension ExplicitForAll,"-XExplicitForAll"),(DisableExtension ExplicitForAll,"-XNoExplicitForAll"),(UnknownExtension "AlternativeLayoutRule","-XAlternativeLayoutRule"),(UnknownExtension "NoAlternativeLayoutRule","-XNoAlternativeLayoutRule"),(UnknownExtension "AlternativeLayoutRuleTransitional","-XAlternativeLayoutRuleTransitional"),(UnknownExtension "NoAlternativeLayoutRuleTransitional","-XNoAlternativeLayoutRuleTransitional"),(EnableExtension DatatypeContexts,"-XDatatypeContexts"),(DisableExtension DatatypeContexts,"-XNoDatatypeContexts"),(EnableExtension NondecreasingIndentation,"-XNondecreasingIndentation"),(DisableExtension NondecreasingIndentation,"-XNoNondecreasingIndentation"),(UnknownExtension "RelaxedLayout","-XRelaxedLayout"),(UnknownExtension "NoRelaxedLayout","-XNoRelaxedLayout"),(UnknownExtension "TraditionalRecordSyntax","-XTraditionalRecordSyntax"),(UnknownExtension "NoTraditionalRecordSyntax","-XNoTraditionalRecordSyntax"),(EnableExtension MonoLocalBinds,"-XMonoLocalBinds"),(DisableExtension MonoLocalBinds,"-XNoMonoLocalBinds"),(EnableExtension RelaxedPolyRec,"-XRelaxedPolyRec"),(DisableExtension RelaxedPolyRec,"-XNoRelaxedPolyRec"),(EnableExtension ExtendedDefaultRules,"-XExtendedDefaultRules"),(DisableExtension ExtendedDefaultRules,"-XNoExtendedDefaultRules"),(EnableExtension ImplicitParams,"-XImplicitParams"),(DisableExtension ImplicitParams,"-XNoImplicitParams"),(EnableExtension ScopedTypeVariables,"-XScopedTypeVariables"),(DisableExtension ScopedTypeVariables,"-XNoScopedTypeVariables"),(EnableExtension PatternSignatures,"-XPatternSignatures"),(DisableExtension PatternSignatures,"-XNoPatternSignatures"),(EnableExtension UnboxedTuples,"-XUnboxedTuples"),(DisableExtension UnboxedTuples,"-XNoUnboxedTuples"),(EnableExtension StandaloneDeriving,"-XStandaloneDeriving"),(DisableExtension StandaloneDeriving,"-XNoStandaloneDeriving"),(EnableExtension DeriveDataTypeable,"-XDeriveDataTypeable"),(DisableExtension DeriveDataTypeable,"-XNoDeriveDataTypeable"),(EnableExtension DeriveFunctor,"-XDeriveFunctor"),(DisableExtension DeriveFunctor,"-XNoDeriveFunctor"),(EnableExtension DeriveTraversable,"-XDeriveTraversable"),(DisableExtension DeriveTraversable,"-XNoDeriveTraversable"),(EnableExtension DeriveFoldable,"-XDeriveFoldable"),(DisableExtension DeriveFoldable,"-XNoDeriveFoldable"),(UnknownExtension "DeriveGeneric","-XDeriveGeneric"),(UnknownExtension "NoDeriveGeneric","-XNoDeriveGeneric"),(UnknownExtension "DefaultSignatures","-XDefaultSignatures"),(UnknownExtension "NoDefaultSignatures","-XNoDefaultSignatures"),(EnableExtension TypeSynonymInstances,"-XTypeSynonymInstances"),(DisableExtension TypeSynonymInstances,"-XNoTypeSynonymInstances"),(EnableExtension FlexibleContexts,"-XFlexibleContexts"),(DisableExtension FlexibleContexts,"-XNoFlexibleContexts"),(EnableExtension FlexibleInstances,"-XFlexibleInstances"),(DisableExtension FlexibleInstances,"-XNoFlexibleInstances"),(EnableExtension ConstrainedClassMethods,"-XConstrainedClassMethods"),(DisableExtension ConstrainedClassMethods,"-XNoConstrainedClassMethods"),(EnableExtension MultiParamTypeClasses,"-XMultiParamTypeClasses"),(DisableExtension MultiParamTypeClasses,"-XNoMultiParamTypeClasses"),(EnableExtension FunctionalDependencies,"-XFunctionalDependencies"),(DisableExtension FunctionalDependencies,"-XNoFunctionalDependencies"),(EnableExtension GeneralizedNewtypeDeriving,"-XGeneralizedNewtypeDeriving"),(DisableExtension GeneralizedNewtypeDeriving,"-XNoGeneralizedNewtypeDeriving"),(EnableExtension OverlappingInstances,"-XOverlappingInstances"),(DisableExtension OverlappingInstances,"-XNoOverlappingInstances"),(EnableExtension UndecidableInstances,"-XUndecidableInstances"),(DisableExtension UndecidableInstances,"-XNoUndecidableInstances"),(EnableExtension IncoherentInstances,"-XIncoherentInstances"),(DisableExtension IncoherentInstances,"-XNoIncoherentInstances"),(EnableExtension PackageImports,"-XPackageImports"),(DisableExtension PackageImports,"-XNoPackageImports")]}, buildDir = "dist/build", scratchDir = "dist/scratch", libraryConfig = Nothing, executableConfigs = [("bnfc",ComponentLocalBuildInfo {componentPackageDeps = [(InstalledPackageId "array-0.4.0.0-59d1cc0e7979167b002f021942d60f46",PackageIdentifier {pkgName = PackageName "array", pkgVersion = Version {versionBranch = [0,4,0,0], versionTags = []}}),(InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,5,0,0], versionTags = []}}),(InstalledPackageId "directory-1.1.0.2-ebacad9b5233212b1abbebce9b7e6524",PackageIdentifier {pkgName = PackageName "directory", pkgVersion = Version {versionBranch = [1,1,0,2], versionTags = []}}),(InstalledPackageId "mtl-2.0.1.0-db19dd8a7700e3d3adda8aa8fe5bf53d",PackageIdentifier {pkgName = PackageName "mtl", pkgVersion = Version {versionBranch = [2,0,1,0], versionTags = []}}),(InstalledPackageId "process-1.1.0.1-18dadd8ad5fc640f55a7afdc7aace500",PackageIdentifier {pkgName = PackageName "process", pkgVersion = Version {versionBranch = [1,1,0,1], versionTags = []}})]})], compBuildOrder = [CExeName "bnfc"], testSuiteConfigs = [], benchmarkConfigs = [], installedPkgs = PackageIndex (fromList [(InstalledPackageId "array-0.4.0.0-59d1cc0e7979167b002f021942d60f46",InstalledPackageInfo {installedPackageId = InstalledPackageId "array-0.4.0.0-59d1cc0e7979167b002f021942d60f46", sourcePackageId = PackageIdentifier {pkgName = PackageName "array", pkgVersion = Version {versionBranch = [0,4,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "Mutable and immutable arrays", description = "This package defines the classes @IArray@ of immutable arrays and\n@MArray@ of arrays mutable within appropriate monads, as well as\nsome instances of these classes.", category = "Data Structures", exposed = True, exposedModules = [ModuleName ["Data","Array","Base"],ModuleName ["Data","Array","IArray"],ModuleName ["Data","Array","IO"],ModuleName ["Data","Array","IO","Safe"],ModuleName ["Data","Array","IO","Internals"],ModuleName ["Data","Array","MArray"],ModuleName ["Data","Array","MArray","Safe"],ModuleName ["Data","Array","ST"],ModuleName ["Data","Array","ST","Safe"],ModuleName ["Data","Array","Storable"],ModuleName ["Data","Array","Storable","Safe"],ModuleName ["Data","Array","Storable","Internals"],ModuleName ["Data","Array","Unboxed"],ModuleName ["Data","Array","Unsafe"],ModuleName ["Data","Array"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/array-0.4.0.0"], libraryDirs = ["/usr/lib/ghc/array-0.4.0.0"], hsLibraries = ["HSarray-0.4.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/array-0.4.0.0/array.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/array-0.4.0.0"]}),(InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageInfo {installedPackageId = InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702", sourcePackageId = PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,5,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "Basic libraries", description = "This package contains the Prelude and its support libraries,\nand a large collection of useful libraries ranging from data\nstructures to parsing combinators and debugging utilities.", category = "", exposed = True, exposedModules = [ModuleName ["Foreign","Concurrent"],ModuleName ["GHC","Arr"],ModuleName ["GHC","Base"],ModuleName ["GHC","Conc"],ModuleName ["GHC","Conc","IO"],ModuleName ["GHC","Conc","Signal"],ModuleName ["GHC","Conc","Sync"],ModuleName ["GHC","ConsoleHandler"],ModuleName ["GHC","Constants"],ModuleName ["GHC","Desugar"],ModuleName ["GHC","Enum"],ModuleName ["GHC","Environment"],ModuleName ["GHC","Err"],ModuleName ["GHC","Exception"],ModuleName ["GHC","Exts"],ModuleName ["GHC","Fingerprint"],ModuleName ["GHC","Fingerprint","Type"],ModuleName ["GHC","Float"],ModuleName ["GHC","Float","ConversionUtils"],ModuleName ["GHC","Float","RealFracMethods"],ModuleName ["GHC","Foreign"],ModuleName ["GHC","ForeignPtr"],ModuleName ["GHC","Handle"],ModuleName ["GHC","IO"],ModuleName ["GHC","IO","Buffer"],ModuleName ["GHC","IO","BufferedIO"],ModuleName ["GHC","IO","Device"],ModuleName ["GHC","IO","Encoding"],ModuleName ["GHC","IO","Encoding","CodePage"],ModuleName ["GHC","IO","Encoding","Failure"],ModuleName ["GHC","IO","Encoding","Iconv"],ModuleName ["GHC","IO","Encoding","Latin1"],ModuleName ["GHC","IO","Encoding","Types"],ModuleName ["GHC","IO","Encoding","UTF16"],ModuleName ["GHC","IO","Encoding","UTF32"],ModuleName ["GHC","IO","Encoding","UTF8"],ModuleName ["GHC","IO","Exception"],ModuleName ["GHC","IO","FD"],ModuleName ["GHC","IO","Handle"],ModuleName ["GHC","IO","Handle","FD"],ModuleName ["GHC","IO","Handle","Internals"],ModuleName ["GHC","IO","Handle","Text"],ModuleName ["GHC","IO","Handle","Types"],ModuleName ["GHC","IO","IOMode"],ModuleName ["GHC","IOArray"],ModuleName ["GHC","IOBase"],ModuleName ["GHC","IORef"],ModuleName ["GHC","Int"],ModuleName ["GHC","List"],ModuleName ["GHC","MVar"],ModuleName ["GHC","Num"],ModuleName ["GHC","PArr"],ModuleName ["GHC","Pack"],ModuleName ["GHC","Ptr"],ModuleName ["GHC","Read"],ModuleName ["GHC","Real"],ModuleName ["GHC","ST"],ModuleName ["GHC","Stack"],ModuleName ["GHC","Stats"],ModuleName ["GHC","Show"],ModuleName ["GHC","Stable"],ModuleName ["GHC","Storable"],ModuleName ["GHC","STRef"],ModuleName ["GHC","TopHandler"],ModuleName ["GHC","Unicode"],ModuleName ["GHC","Weak"],ModuleName ["GHC","Word"],ModuleName ["System","Timeout"],ModuleName ["GHC","Event"],ModuleName ["Control","Applicative"],ModuleName ["Control","Arrow"],ModuleName ["Control","Category"],ModuleName ["Control","Concurrent"],ModuleName ["Control","Concurrent","Chan"],ModuleName ["Control","Concurrent","MVar"],ModuleName ["Control","Concurrent","QSem"],ModuleName ["Control","Concurrent","QSemN"],ModuleName ["Control","Concurrent","SampleVar"],ModuleName ["Control","Exception"],ModuleName ["Control","Exception","Base"],ModuleName ["Control","OldException"],ModuleName ["Control","Monad"],ModuleName ["Control","Monad","Fix"],ModuleName ["Control","Monad","Instances"],ModuleName ["Control","Monad","ST"],ModuleName ["Control","Monad","ST","Safe"],ModuleName ["Control","Monad","ST","Unsafe"],ModuleName ["Control","Monad","ST","Lazy"],ModuleName ["Control","Monad","ST","Lazy","Safe"],ModuleName ["Control","Monad","ST","Lazy","Unsafe"],ModuleName ["Control","Monad","ST","Strict"],ModuleName ["Control","Monad","Zip"],ModuleName ["Data","Bits"],ModuleName ["Data","Bool"],ModuleName ["Data","Char"],ModuleName ["Data","Complex"],ModuleName ["Data","Dynamic"],ModuleName ["Data","Either"],ModuleName ["Data","Eq"],ModuleName ["Data","Data"],ModuleName ["Data","Fixed"],ModuleName ["Data","Foldable"],ModuleName ["Data","Function"],ModuleName ["Data","Functor"],ModuleName ["Data","HashTable"],ModuleName ["Data","IORef"],ModuleName ["Data","Int"],ModuleName ["Data","Ix"],ModuleName ["Data","List"],ModuleName ["Data","Maybe"],ModuleName ["Data","Monoid"],ModuleName ["Data","Ord"],ModuleName ["Data","Ratio"],ModuleName ["Data","STRef"],ModuleName ["Data","STRef","Lazy"],ModuleName ["Data","STRef","Strict"],ModuleName ["Data","String"],ModuleName ["Data","Traversable"],ModuleName ["Data","Tuple"],ModuleName ["Data","Typeable"],ModuleName ["Data","Typeable","Internal"],ModuleName ["Data","Unique"],ModuleName ["Data","Version"],ModuleName ["Data","Word"],ModuleName ["Debug","Trace"],ModuleName ["Foreign"],ModuleName ["Foreign","C"],ModuleName ["Foreign","C","Error"],ModuleName ["Foreign","C","String"],ModuleName ["Foreign","C","Types"],ModuleName ["Foreign","ForeignPtr"],ModuleName ["Foreign","ForeignPtr","Safe"],ModuleName ["Foreign","ForeignPtr","Unsafe"],ModuleName ["Foreign","Marshal"],ModuleName ["Foreign","Marshal","Alloc"],ModuleName ["Foreign","Marshal","Array"],ModuleName ["Foreign","Marshal","Error"],ModuleName ["Foreign","Marshal","Pool"],ModuleName ["Foreign","Marshal","Safe"],ModuleName ["Foreign","Marshal","Utils"],ModuleName ["Foreign","Marshal","Unsafe"],ModuleName ["Foreign","Ptr"],ModuleName ["Foreign","Safe"],ModuleName ["Foreign","StablePtr"],ModuleName ["Foreign","Storable"],ModuleName ["Numeric"],ModuleName ["Prelude"],ModuleName ["System","Console","GetOpt"],ModuleName ["System","CPUTime"],ModuleName ["System","Environment"],ModuleName ["System","Exit"],ModuleName ["System","IO"],ModuleName ["System","IO","Error"],ModuleName ["System","IO","Unsafe"],ModuleName ["System","Info"],ModuleName ["System","Mem"],ModuleName ["System","Mem","StableName"],ModuleName ["System","Mem","Weak"],ModuleName ["System","Posix","Internals"],ModuleName ["System","Posix","Types"],ModuleName ["Text","ParserCombinators","ReadP"],ModuleName ["Text","ParserCombinators","ReadPrec"],ModuleName ["Text","Printf"],ModuleName ["Text","Read"],ModuleName ["Text","Read","Lex"],ModuleName ["Text","Show"],ModuleName ["Text","Show","Functions"],ModuleName ["Unsafe","Coerce"]], hiddenModules = [ModuleName ["GHC","Event","Array"],ModuleName ["GHC","Event","Clock"],ModuleName ["GHC","Event","Control"],ModuleName ["GHC","Event","EPoll"],ModuleName ["GHC","Event","IntMap"],ModuleName ["GHC","Event","Internal"],ModuleName ["GHC","Event","KQueue"],ModuleName ["GHC","Event","Manager"],ModuleName ["GHC","Event","PSQ"],ModuleName ["GHC","Event","Poll"],ModuleName ["GHC","Event","Thread"],ModuleName ["GHC","Event","Unique"],ModuleName ["Control","Monad","ST","Imp"],ModuleName ["Control","Monad","ST","Lazy","Imp"],ModuleName ["Foreign","ForeignPtr","Imp"]], trusted = False, importDirs = ["/usr/lib/ghc/base-4.5.0.0"], libraryDirs = ["/usr/lib/ghc/base-4.5.0.0"], hsLibraries = ["HSbase-4.5.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/base-4.5.0.0/include"], includes = ["HsBase.h"], depends = [InstalledPackageId "ghc-prim-0.2.0.0-c2ff696e5b8ec4d4b2bc2e42085fe471",InstalledPackageId "integer-gmp-0.4.0.0-3cccac07aef8e27023f605c1f45bdf74",InstalledPackageId "builtin_rts"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/base-4.5.0.0/base.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0"]}),(InstalledPackageId "builtin_rts",InstalledPackageInfo {installedPackageId = InstalledPackageId "builtin_rts", sourcePackageId = PackageIdentifier {pkgName = PackageName "rts", pkgVersion = Version {versionBranch = [1,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "glasgow-haskell-users@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "", description = "", category = "", exposed = True, exposedModules = [], hiddenModules = [], trusted = False, importDirs = [], libraryDirs = ["/usr/lib/ghc"], hsLibraries = ["HSrts"], extraLibraries = ["ffi","m","rt","dl"], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/include"], includes = ["Stg.h"], depends = [], hugsOptions = [], ccOptions = [], ldOptions = ["-u","ghczmprim_GHCziTypes_Izh_static_info","-u","ghczmprim_GHCziTypes_Czh_static_info","-u","ghczmprim_GHCziTypes_Fzh_static_info","-u","ghczmprim_GHCziTypes_Dzh_static_info","-u","base_GHCziPtr_Ptr_static_info","-u","base_GHCziWord_Wzh_static_info","-u","base_GHCziInt_I8zh_static_info","-u","base_GHCziInt_I16zh_static_info","-u","base_GHCziInt_I32zh_static_info","-u","base_GHCziInt_I64zh_static_info","-u","base_GHCziWord_W8zh_static_info","-u","base_GHCziWord_W16zh_static_info","-u","base_GHCziWord_W32zh_static_info","-u","base_GHCziWord_W64zh_static_info","-u","base_GHCziStable_StablePtr_static_info","-u","ghczmprim_GHCziTypes_Izh_con_info","-u","ghczmprim_GHCziTypes_Czh_con_info","-u","ghczmprim_GHCziTypes_Fzh_con_info","-u","ghczmprim_GHCziTypes_Dzh_con_info","-u","base_GHCziPtr_Ptr_con_info","-u","base_GHCziPtr_FunPtr_con_info","-u","base_GHCziStable_StablePtr_con_info","-u","ghczmprim_GHCziTypes_False_closure","-u","ghczmprim_GHCziTypes_True_closure","-u","base_GHCziPack_unpackCString_closure","-u","base_GHCziIOziException_stackOverflow_closure","-u","base_GHCziIOziException_heapOverflow_closure","-u","base_ControlziExceptionziBase_nonTermination_closure","-u","base_GHCziIOziException_blockedIndefinitelyOnMVar_closure","-u","base_GHCziIOziException_blockedIndefinitelyOnSTM_closure","-u","base_ControlziExceptionziBase_nestedAtomically_closure","-u","base_GHCziWeak_runFinalizzerBatch_closure","-u","base_GHCziTopHandler_flushStdHandles_closure","-u","base_GHCziTopHandler_runIO_closure","-u","base_GHCziTopHandler_runNonIO_closure","-u","base_GHCziConcziIO_ensureIOManagerIsRunning_closure","-u","base_GHCziConcziSync_runSparks_closure","-u","base_GHCziConcziSignal_runHandlers_closure"], frameworkDirs = [], frameworks = [], haddockInterfaces = [], haddockHTMLs = []}),(InstalledPackageId "bytestring-0.9.2.1-18f26186028d7c0e92e78edc9071d376",InstalledPackageInfo {installedPackageId = InstalledPackageId "bytestring-0.9.2.1-18f26186028d7c0e92e78edc9071d376", sourcePackageId = PackageIdentifier {pkgName = PackageName "bytestring", pkgVersion = Version {versionBranch = [0,9,2,1], versionTags = []}}, license = BSD3, copyright = "Copyright (c) Don Stewart 2005-2009,\n(c) Duncan Coutts 2006-2009,\n(c) David Roundy 2003-2005.", maintainer = "dons00@gmail.com, duncan@community.haskell.org", author = "Don Stewart, Duncan Coutts", stability = "", homepage = "http://www.cse.unsw.edu.au/~dons/fps.html", pkgUrl = "", synopsis = "Fast, packed, strict and lazy byte arrays with a list interface", description = "A time and space-efficient implementation of byte vectors using\npacked Word8 arrays, suitable for high performance use, both in terms\nof large data quantities, or high speed requirements. Byte vectors\nare encoded as strict 'Word8' arrays of bytes, and lazy lists of\nstrict chunks, held in a 'ForeignPtr', and can be passed between C\nand Haskell with little effort.\n\nTest coverage data for this library is available at:\n<http://code.haskell.org/~dons/tests/bytestring/hpc_index.html>", category = "Data", exposed = True, exposedModules = [ModuleName ["Data","ByteString"],ModuleName ["Data","ByteString","Char8"],ModuleName ["Data","ByteString","Unsafe"],ModuleName ["Data","ByteString","Internal"],ModuleName ["Data","ByteString","Lazy"],ModuleName ["Data","ByteString","Lazy","Char8"],ModuleName ["Data","ByteString","Lazy","Internal"],ModuleName ["Data","ByteString","Fusion"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/bytestring-0.9.2.1"], libraryDirs = ["/usr/lib/ghc/bytestring-0.9.2.1"], hsLibraries = ["HSbytestring-0.9.2.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/bytestring-0.9.2.1/include"], includes = ["fpstring.h"], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "ghc-prim-0.2.0.0-c2ff696e5b8ec4d4b2bc2e42085fe471"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/bytestring-0.9.2.1/bytestring.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/bytestring-0.9.2.1"]}),(InstalledPackageId "directory-1.1.0.2-ebacad9b5233212b1abbebce9b7e6524",InstalledPackageInfo {installedPackageId = InstalledPackageId "directory-1.1.0.2-ebacad9b5233212b1abbebce9b7e6524", sourcePackageId = PackageIdentifier {pkgName = PackageName "directory", pkgVersion = Version {versionBranch = [1,1,0,2], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "library for directory handling", description = "This package provides a library for handling directories.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Directory"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/directory-1.1.0.2"], libraryDirs = ["/usr/lib/ghc/directory-1.1.0.2"], hsLibraries = ["HSdirectory-1.1.0.2"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/directory-1.1.0.2/include"], includes = ["HsDirectory.h"], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "filepath-1.3.0.0-973f5e9fbed93e25cbe66dfeb6b99ad9",InstalledPackageId "old-time-1.1.0.0-b77788a065c86ada9ba279afa5e04576",InstalledPackageId "unix-2.5.1.0-b7c7408f284e3570d0d4dbd1f423845f"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/directory-1.1.0.2/directory.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/directory-1.1.0.2"]}),(InstalledPackageId "filepath-1.3.0.0-973f5e9fbed93e25cbe66dfeb6b99ad9",InstalledPackageInfo {installedPackageId = InstalledPackageId "filepath-1.3.0.0-973f5e9fbed93e25cbe66dfeb6b99ad9", sourcePackageId = PackageIdentifier {pkgName = PackageName "filepath", pkgVersion = Version {versionBranch = [1,3,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "", author = "Neil Mitchell", stability = "", homepage = "http://www-users.cs.york.ac.uk/~ndm/filepath/", pkgUrl = "", synopsis = "Library for manipulating FilePaths in a cross platform way.", description = "", category = "System", exposed = True, exposedModules = [ModuleName ["System","FilePath"],ModuleName ["System","FilePath","Posix"],ModuleName ["System","FilePath","Windows"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/filepath-1.3.0.0"], libraryDirs = ["/usr/lib/ghc/filepath-1.3.0.0"], hsLibraries = ["HSfilepath-1.3.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/filepath-1.3.0.0/filepath.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/filepath-1.3.0.0"]}),(InstalledPackageId "ghc-prim-0.2.0.0-c2ff696e5b8ec4d4b2bc2e42085fe471",InstalledPackageInfo {installedPackageId = InstalledPackageId "ghc-prim-0.2.0.0-c2ff696e5b8ec4d4b2bc2e42085fe471", sourcePackageId = PackageIdentifier {pkgName = PackageName "ghc-prim", pkgVersion = Version {versionBranch = [0,2,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "GHC primitives", description = "GHC primitives.", category = "", exposed = True, exposedModules = [ModuleName ["GHC","Prim"],ModuleName ["GHC","Classes"],ModuleName ["GHC","CString"],ModuleName ["GHC","Debug"],ModuleName ["GHC","Generics"],ModuleName ["GHC","Magic"],ModuleName ["GHC","PrimopWrappers"],ModuleName ["GHC","IntWord64"],ModuleName ["GHC","Tuple"],ModuleName ["GHC","Types"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/ghc-prim-0.2.0.0"], libraryDirs = ["/usr/lib/ghc/ghc-prim-0.2.0.0"], hsLibraries = ["HSghc-prim-0.2.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "builtin_rts"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/ghc-prim-0.2.0.0/ghc-prim.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/ghc-prim-0.2.0.0"]}),(InstalledPackageId "integer-gmp-0.4.0.0-3cccac07aef8e27023f605c1f45bdf74",InstalledPackageInfo {installedPackageId = InstalledPackageId "integer-gmp-0.4.0.0-3cccac07aef8e27023f605c1f45bdf74", sourcePackageId = PackageIdentifier {pkgName = PackageName "integer-gmp", pkgVersion = Version {versionBranch = [0,4,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "Integer library based on GMP", description = "This package contains an Integer library based on GMP.", category = "", exposed = True, exposedModules = [ModuleName ["GHC","Integer"],ModuleName ["GHC","Integer","GMP","Internals"],ModuleName ["GHC","Integer","GMP","Prim"],ModuleName ["GHC","Integer","Logarithms"],ModuleName ["GHC","Integer","Logarithms","Internals"]], hiddenModules = [ModuleName ["GHC","Integer","Type"]], trusted = False, importDirs = ["/usr/lib/ghc/integer-gmp-0.4.0.0"], libraryDirs = ["/usr/lib/ghc/integer-gmp-0.4.0.0"], hsLibraries = ["HSinteger-gmp-0.4.0.0"], extraLibraries = ["gmp"], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "ghc-prim-0.2.0.0-c2ff696e5b8ec4d4b2bc2e42085fe471"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/integer-gmp-0.4.0.0/integer-gmp.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/integer-gmp-0.4.0.0"]}),(InstalledPackageId "mtl-2.0.1.0-db19dd8a7700e3d3adda8aa8fe5bf53d",InstalledPackageInfo {installedPackageId = InstalledPackageId "mtl-2.0.1.0-db19dd8a7700e3d3adda8aa8fe5bf53d", sourcePackageId = PackageIdentifier {pkgName = PackageName "mtl", pkgVersion = Version {versionBranch = [2,0,1,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "Andy Gill", stability = "", homepage = "", pkgUrl = "", synopsis = "Monad classes, using functional dependencies", description = "Monad classes using functional dependencies, with instances\nfor various monad transformers, inspired by the paper\n/Functional Programming with Overloading and Higher-Order Polymorphism/,\nby Mark P Jones, in /Advanced School of Functional Programming/, 1995\n(<http://web.cecs.pdx.edu/~mpj/pubs/springschool.html>).", category = "Control", exposed = True, exposedModules = [ModuleName ["Control","Monad","Cont"],ModuleName ["Control","Monad","Cont","Class"],ModuleName ["Control","Monad","Error"],ModuleName ["Control","Monad","Error","Class"],ModuleName ["Control","Monad","Identity"],ModuleName ["Control","Monad","List"],ModuleName ["Control","Monad","RWS"],ModuleName ["Control","Monad","RWS","Class"],ModuleName ["Control","Monad","RWS","Lazy"],ModuleName ["Control","Monad","RWS","Strict"],ModuleName ["Control","Monad","Reader"],ModuleName ["Control","Monad","Reader","Class"],ModuleName ["Control","Monad","State"],ModuleName ["Control","Monad","State","Class"],ModuleName ["Control","Monad","State","Lazy"],ModuleName ["Control","Monad","State","Strict"],ModuleName ["Control","Monad","Trans"],ModuleName ["Control","Monad","Writer"],ModuleName ["Control","Monad","Writer","Class"],ModuleName ["Control","Monad","Writer","Lazy"],ModuleName ["Control","Monad","Writer","Strict"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/haskell-packages/ghc/lib/mtl-2.0.1.0/ghc-7.4.1"], libraryDirs = ["/usr/lib/haskell-packages/ghc/lib/mtl-2.0.1.0/ghc-7.4.1"], hsLibraries = ["HSmtl-2.0.1.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "transformers-0.2.2.0-367ec8196a45fab9903c082ddf1e964e"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/mtl-2.0.1.0/mtl.haddock"], haddockHTMLs = ["/usr/share/doc/libghc-mtl-doc/html/"]}),(InstalledPackageId "old-locale-1.0.0.4-a2c3d942f886fb70df8171795fdc2e5a",InstalledPackageInfo {installedPackageId = InstalledPackageId "old-locale-1.0.0.4-a2c3d942f886fb70df8171795fdc2e5a", sourcePackageId = PackageIdentifier {pkgName = PackageName "old-locale", pkgVersion = Version {versionBranch = [1,0,0,4], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "locale library", description = "This package provides the old locale library.\nFor new code, the new locale library is recommended.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Locale"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/old-locale-1.0.0.4"], libraryDirs = ["/usr/lib/ghc/old-locale-1.0.0.4"], hsLibraries = ["HSold-locale-1.0.0.4"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/old-locale-1.0.0.4/old-locale.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/old-locale-1.0.0.4"]}),(InstalledPackageId "old-time-1.1.0.0-b77788a065c86ada9ba279afa5e04576",InstalledPackageInfo {installedPackageId = InstalledPackageId "old-time-1.1.0.0-b77788a065c86ada9ba279afa5e04576", sourcePackageId = PackageIdentifier {pkgName = PackageName "old-time", pkgVersion = Version {versionBranch = [1,1,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "Time library", description = "This package provides the old time library.\nFor new code, the new time library is recommended.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Time"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/old-time-1.1.0.0"], libraryDirs = ["/usr/lib/ghc/old-time-1.1.0.0"], hsLibraries = ["HSold-time-1.1.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/old-time-1.1.0.0/include"], includes = ["HsTime.h"], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "old-locale-1.0.0.4-a2c3d942f886fb70df8171795fdc2e5a"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/old-time-1.1.0.0/old-time.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/old-time-1.1.0.0"]}),(InstalledPackageId "process-1.1.0.1-18dadd8ad5fc640f55a7afdc7aace500",InstalledPackageInfo {installedPackageId = InstalledPackageId "process-1.1.0.1-18dadd8ad5fc640f55a7afdc7aace500", sourcePackageId = PackageIdentifier {pkgName = PackageName "process", pkgVersion = Version {versionBranch = [1,1,0,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "Process libraries", description = "This package contains libraries for dealing with system processes.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Process","Internals"],ModuleName ["System","Process"],ModuleName ["System","Cmd"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/process-1.1.0.1"], libraryDirs = ["/usr/lib/ghc/process-1.1.0.1"], hsLibraries = ["HSprocess-1.1.0.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/process-1.1.0.1/include"], includes = ["runProcess.h"], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "directory-1.1.0.2-ebacad9b5233212b1abbebce9b7e6524",InstalledPackageId "filepath-1.3.0.0-973f5e9fbed93e25cbe66dfeb6b99ad9",InstalledPackageId "unix-2.5.1.0-b7c7408f284e3570d0d4dbd1f423845f"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/process-1.1.0.1/process.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/process-1.1.0.1"]}),(InstalledPackageId "transformers-0.2.2.0-367ec8196a45fab9903c082ddf1e964e",InstalledPackageInfo {installedPackageId = InstalledPackageId "transformers-0.2.2.0-367ec8196a45fab9903c082ddf1e964e", sourcePackageId = PackageIdentifier {pkgName = PackageName "transformers", pkgVersion = Version {versionBranch = [0,2,2,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "Ross Paterson <ross@soi.city.ac.uk>", author = "Andy Gill, Ross Paterson", stability = "", homepage = "", pkgUrl = "", synopsis = "Concrete functor and monad transformers", description = "Haskell 98 part of a monad transformer library, inspired by the paper\n\\\"Functional Programming with Overloading and Higher-Order Polymorphism\\\",\nby Mark P Jones, in /Advanced School of Functional Programming/, 1995\n(<http://web.cecs.pdx.edu/~mpj/pubs/springschool.html>).\n\nThis part contains the monad transformer class, the concrete monad\ntransformers, operations and liftings. It can be used on its own\nin Haskell 98 code, or with the monad classes in the @monads-fd@ or\n@monads-tf@ packages, which automatically lift operations introduced\nby monad transformers through other transformers.", category = "Control", exposed = True, exposedModules = [ModuleName ["Control","Monad","IO","Class"],ModuleName ["Control","Monad","Trans","Class"],ModuleName ["Control","Monad","Trans","Cont"],ModuleName ["Control","Monad","Trans","Error"],ModuleName ["Control","Monad","Trans","Identity"],ModuleName ["Control","Monad","Trans","List"],ModuleName ["Control","Monad","Trans","Maybe"],ModuleName ["Control","Monad","Trans","Reader"],ModuleName ["Control","Monad","Trans","RWS"],ModuleName ["Control","Monad","Trans","RWS","Lazy"],ModuleName ["Control","Monad","Trans","RWS","Strict"],ModuleName ["Control","Monad","Trans","State"],ModuleName ["Control","Monad","Trans","State","Lazy"],ModuleName ["Control","Monad","Trans","State","Strict"],ModuleName ["Control","Monad","Trans","Writer"],ModuleName ["Control","Monad","Trans","Writer","Lazy"],ModuleName ["Control","Monad","Trans","Writer","Strict"],ModuleName ["Data","Functor","Compose"],ModuleName ["Data","Functor","Constant"],ModuleName ["Data","Functor","Identity"],ModuleName ["Data","Functor","Product"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/haskell-packages/ghc/lib/transformers-0.2.2.0/ghc-7.4.1"], libraryDirs = ["/usr/lib/haskell-packages/ghc/lib/transformers-0.2.2.0/ghc-7.4.1"], hsLibraries = ["HStransformers-0.2.2.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/transformers-0.2.2.0/transformers.haddock"], haddockHTMLs = ["/usr/share/doc/libghc-transformers-doc/html/"]}),(InstalledPackageId "unix-2.5.1.0-b7c7408f284e3570d0d4dbd1f423845f",InstalledPackageInfo {installedPackageId = InstalledPackageId "unix-2.5.1.0-b7c7408f284e3570d0d4dbd1f423845f", sourcePackageId = PackageIdentifier {pkgName = PackageName "unix", pkgVersion = Version {versionBranch = [2,5,1,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "POSIX functionality", description = "This package gives you access to the set of operating system\nservices standardised by POSIX 1003.1b (or the IEEE Portable\nOperating System Interface for Computing Environments -\nIEEE Std. 1003.1).\n\nThe package is not supported under Windows (except under Cygwin).", category = "System", exposed = True, exposedModules = [ModuleName ["System","Posix"],ModuleName ["System","Posix","ByteString"],ModuleName ["System","Posix","Error"],ModuleName ["System","Posix","Resource"],ModuleName ["System","Posix","Time"],ModuleName ["System","Posix","Unistd"],ModuleName ["System","Posix","User"],ModuleName ["System","Posix","Signals"],ModuleName ["System","Posix","Signals","Exts"],ModuleName ["System","Posix","Semaphore"],ModuleName ["System","Posix","SharedMem"],ModuleName ["System","Posix","ByteString","FilePath"],ModuleName ["System","Posix","Directory"],ModuleName ["System","Posix","Directory","ByteString"],ModuleName ["System","Posix","DynamicLinker","Module"],ModuleName ["System","Posix","DynamicLinker","Module","ByteString"],ModuleName ["System","Posix","DynamicLinker","Prim"],ModuleName ["System","Posix","DynamicLinker","ByteString"],ModuleName ["System","Posix","DynamicLinker"],ModuleName ["System","Posix","Files"],ModuleName ["System","Posix","Files","ByteString"],ModuleName ["System","Posix","IO"],ModuleName ["System","Posix","IO","ByteString"],ModuleName ["System","Posix","Env"],ModuleName ["System","Posix","Env","ByteString"],ModuleName ["System","Posix","Process"],ModuleName ["System","Posix","Process","Internals"],ModuleName ["System","Posix","Process","ByteString"],ModuleName ["System","Posix","Temp"],ModuleName ["System","Posix","Temp","ByteString"],ModuleName ["System","Posix","Terminal"],ModuleName ["System","Posix","Terminal","ByteString"]], hiddenModules = [ModuleName ["System","Posix","Directory","Common"],ModuleName ["System","Posix","DynamicLinker","Common"],ModuleName ["System","Posix","Files","Common"],ModuleName ["System","Posix","IO","Common"],ModuleName ["System","Posix","Process","Common"],ModuleName ["System","Posix","Terminal","Common"]], trusted = False, importDirs = ["/usr/lib/ghc/unix-2.5.1.0"], libraryDirs = ["/usr/lib/ghc/unix-2.5.1.0"], hsLibraries = ["HSunix-2.5.1.0"], extraLibraries = ["rt","util","dl","pthread"], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/unix-2.5.1.0/include"], includes = ["HsUnix.h","execvpe.h"], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "bytestring-0.9.2.1-18f26186028d7c0e92e78edc9071d376"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/unix-2.5.1.0/unix.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/unix-2.5.1.0"]})]) (fromList [(PackageName "array",fromList [(Version {versionBranch = [0,4,0,0], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "array-0.4.0.0-59d1cc0e7979167b002f021942d60f46", sourcePackageId = PackageIdentifier {pkgName = PackageName "array", pkgVersion = Version {versionBranch = [0,4,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "Mutable and immutable arrays", description = "This package defines the classes @IArray@ of immutable arrays and\n@MArray@ of arrays mutable within appropriate monads, as well as\nsome instances of these classes.", category = "Data Structures", exposed = True, exposedModules = [ModuleName ["Data","Array","Base"],ModuleName ["Data","Array","IArray"],ModuleName ["Data","Array","IO"],ModuleName ["Data","Array","IO","Safe"],ModuleName ["Data","Array","IO","Internals"],ModuleName ["Data","Array","MArray"],ModuleName ["Data","Array","MArray","Safe"],ModuleName ["Data","Array","ST"],ModuleName ["Data","Array","ST","Safe"],ModuleName ["Data","Array","Storable"],ModuleName ["Data","Array","Storable","Safe"],ModuleName ["Data","Array","Storable","Internals"],ModuleName ["Data","Array","Unboxed"],ModuleName ["Data","Array","Unsafe"],ModuleName ["Data","Array"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/array-0.4.0.0"], libraryDirs = ["/usr/lib/ghc/array-0.4.0.0"], hsLibraries = ["HSarray-0.4.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/array-0.4.0.0/array.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/array-0.4.0.0"]}])]),(PackageName "base",fromList [(Version {versionBranch = [4,5,0,0], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702", sourcePackageId = PackageIdentifier {pkgName = PackageName "base", pkgVersion = Version {versionBranch = [4,5,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "Basic libraries", description = "This package contains the Prelude and its support libraries,\nand a large collection of useful libraries ranging from data\nstructures to parsing combinators and debugging utilities.", category = "", exposed = True, exposedModules = [ModuleName ["Foreign","Concurrent"],ModuleName ["GHC","Arr"],ModuleName ["GHC","Base"],ModuleName ["GHC","Conc"],ModuleName ["GHC","Conc","IO"],ModuleName ["GHC","Conc","Signal"],ModuleName ["GHC","Conc","Sync"],ModuleName ["GHC","ConsoleHandler"],ModuleName ["GHC","Constants"],ModuleName ["GHC","Desugar"],ModuleName ["GHC","Enum"],ModuleName ["GHC","Environment"],ModuleName ["GHC","Err"],ModuleName ["GHC","Exception"],ModuleName ["GHC","Exts"],ModuleName ["GHC","Fingerprint"],ModuleName ["GHC","Fingerprint","Type"],ModuleName ["GHC","Float"],ModuleName ["GHC","Float","ConversionUtils"],ModuleName ["GHC","Float","RealFracMethods"],ModuleName ["GHC","Foreign"],ModuleName ["GHC","ForeignPtr"],ModuleName ["GHC","Handle"],ModuleName ["GHC","IO"],ModuleName ["GHC","IO","Buffer"],ModuleName ["GHC","IO","BufferedIO"],ModuleName ["GHC","IO","Device"],ModuleName ["GHC","IO","Encoding"],ModuleName ["GHC","IO","Encoding","CodePage"],ModuleName ["GHC","IO","Encoding","Failure"],ModuleName ["GHC","IO","Encoding","Iconv"],ModuleName ["GHC","IO","Encoding","Latin1"],ModuleName ["GHC","IO","Encoding","Types"],ModuleName ["GHC","IO","Encoding","UTF16"],ModuleName ["GHC","IO","Encoding","UTF32"],ModuleName ["GHC","IO","Encoding","UTF8"],ModuleName ["GHC","IO","Exception"],ModuleName ["GHC","IO","FD"],ModuleName ["GHC","IO","Handle"],ModuleName ["GHC","IO","Handle","FD"],ModuleName ["GHC","IO","Handle","Internals"],ModuleName ["GHC","IO","Handle","Text"],ModuleName ["GHC","IO","Handle","Types"],ModuleName ["GHC","IO","IOMode"],ModuleName ["GHC","IOArray"],ModuleName ["GHC","IOBase"],ModuleName ["GHC","IORef"],ModuleName ["GHC","Int"],ModuleName ["GHC","List"],ModuleName ["GHC","MVar"],ModuleName ["GHC","Num"],ModuleName ["GHC","PArr"],ModuleName ["GHC","Pack"],ModuleName ["GHC","Ptr"],ModuleName ["GHC","Read"],ModuleName ["GHC","Real"],ModuleName ["GHC","ST"],ModuleName ["GHC","Stack"],ModuleName ["GHC","Stats"],ModuleName ["GHC","Show"],ModuleName ["GHC","Stable"],ModuleName ["GHC","Storable"],ModuleName ["GHC","STRef"],ModuleName ["GHC","TopHandler"],ModuleName ["GHC","Unicode"],ModuleName ["GHC","Weak"],ModuleName ["GHC","Word"],ModuleName ["System","Timeout"],ModuleName ["GHC","Event"],ModuleName ["Control","Applicative"],ModuleName ["Control","Arrow"],ModuleName ["Control","Category"],ModuleName ["Control","Concurrent"],ModuleName ["Control","Concurrent","Chan"],ModuleName ["Control","Concurrent","MVar"],ModuleName ["Control","Concurrent","QSem"],ModuleName ["Control","Concurrent","QSemN"],ModuleName ["Control","Concurrent","SampleVar"],ModuleName ["Control","Exception"],ModuleName ["Control","Exception","Base"],ModuleName ["Control","OldException"],ModuleName ["Control","Monad"],ModuleName ["Control","Monad","Fix"],ModuleName ["Control","Monad","Instances"],ModuleName ["Control","Monad","ST"],ModuleName ["Control","Monad","ST","Safe"],ModuleName ["Control","Monad","ST","Unsafe"],ModuleName ["Control","Monad","ST","Lazy"],ModuleName ["Control","Monad","ST","Lazy","Safe"],ModuleName ["Control","Monad","ST","Lazy","Unsafe"],ModuleName ["Control","Monad","ST","Strict"],ModuleName ["Control","Monad","Zip"],ModuleName ["Data","Bits"],ModuleName ["Data","Bool"],ModuleName ["Data","Char"],ModuleName ["Data","Complex"],ModuleName ["Data","Dynamic"],ModuleName ["Data","Either"],ModuleName ["Data","Eq"],ModuleName ["Data","Data"],ModuleName ["Data","Fixed"],ModuleName ["Data","Foldable"],ModuleName ["Data","Function"],ModuleName ["Data","Functor"],ModuleName ["Data","HashTable"],ModuleName ["Data","IORef"],ModuleName ["Data","Int"],ModuleName ["Data","Ix"],ModuleName ["Data","List"],ModuleName ["Data","Maybe"],ModuleName ["Data","Monoid"],ModuleName ["Data","Ord"],ModuleName ["Data","Ratio"],ModuleName ["Data","STRef"],ModuleName ["Data","STRef","Lazy"],ModuleName ["Data","STRef","Strict"],ModuleName ["Data","String"],ModuleName ["Data","Traversable"],ModuleName ["Data","Tuple"],ModuleName ["Data","Typeable"],ModuleName ["Data","Typeable","Internal"],ModuleName ["Data","Unique"],ModuleName ["Data","Version"],ModuleName ["Data","Word"],ModuleName ["Debug","Trace"],ModuleName ["Foreign"],ModuleName ["Foreign","C"],ModuleName ["Foreign","C","Error"],ModuleName ["Foreign","C","String"],ModuleName ["Foreign","C","Types"],ModuleName ["Foreign","ForeignPtr"],ModuleName ["Foreign","ForeignPtr","Safe"],ModuleName ["Foreign","ForeignPtr","Unsafe"],ModuleName ["Foreign","Marshal"],ModuleName ["Foreign","Marshal","Alloc"],ModuleName ["Foreign","Marshal","Array"],ModuleName ["Foreign","Marshal","Error"],ModuleName ["Foreign","Marshal","Pool"],ModuleName ["Foreign","Marshal","Safe"],ModuleName ["Foreign","Marshal","Utils"],ModuleName ["Foreign","Marshal","Unsafe"],ModuleName ["Foreign","Ptr"],ModuleName ["Foreign","Safe"],ModuleName ["Foreign","StablePtr"],ModuleName ["Foreign","Storable"],ModuleName ["Numeric"],ModuleName ["Prelude"],ModuleName ["System","Console","GetOpt"],ModuleName ["System","CPUTime"],ModuleName ["System","Environment"],ModuleName ["System","Exit"],ModuleName ["System","IO"],ModuleName ["System","IO","Error"],ModuleName ["System","IO","Unsafe"],ModuleName ["System","Info"],ModuleName ["System","Mem"],ModuleName ["System","Mem","StableName"],ModuleName ["System","Mem","Weak"],ModuleName ["System","Posix","Internals"],ModuleName ["System","Posix","Types"],ModuleName ["Text","ParserCombinators","ReadP"],ModuleName ["Text","ParserCombinators","ReadPrec"],ModuleName ["Text","Printf"],ModuleName ["Text","Read"],ModuleName ["Text","Read","Lex"],ModuleName ["Text","Show"],ModuleName ["Text","Show","Functions"],ModuleName ["Unsafe","Coerce"]], hiddenModules = [ModuleName ["GHC","Event","Array"],ModuleName ["GHC","Event","Clock"],ModuleName ["GHC","Event","Control"],ModuleName ["GHC","Event","EPoll"],ModuleName ["GHC","Event","IntMap"],ModuleName ["GHC","Event","Internal"],ModuleName ["GHC","Event","KQueue"],ModuleName ["GHC","Event","Manager"],ModuleName ["GHC","Event","PSQ"],ModuleName ["GHC","Event","Poll"],ModuleName ["GHC","Event","Thread"],ModuleName ["GHC","Event","Unique"],ModuleName ["Control","Monad","ST","Imp"],ModuleName ["Control","Monad","ST","Lazy","Imp"],ModuleName ["Foreign","ForeignPtr","Imp"]], trusted = False, importDirs = ["/usr/lib/ghc/base-4.5.0.0"], libraryDirs = ["/usr/lib/ghc/base-4.5.0.0"], hsLibraries = ["HSbase-4.5.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/base-4.5.0.0/include"], includes = ["HsBase.h"], depends = [InstalledPackageId "ghc-prim-0.2.0.0-c2ff696e5b8ec4d4b2bc2e42085fe471",InstalledPackageId "integer-gmp-0.4.0.0-3cccac07aef8e27023f605c1f45bdf74",InstalledPackageId "builtin_rts"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/base-4.5.0.0/base.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0"]}])]),(PackageName "bytestring",fromList [(Version {versionBranch = [0,9,2,1], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "bytestring-0.9.2.1-18f26186028d7c0e92e78edc9071d376", sourcePackageId = PackageIdentifier {pkgName = PackageName "bytestring", pkgVersion = Version {versionBranch = [0,9,2,1], versionTags = []}}, license = BSD3, copyright = "Copyright (c) Don Stewart 2005-2009,\n(c) Duncan Coutts 2006-2009,\n(c) David Roundy 2003-2005.", maintainer = "dons00@gmail.com, duncan@community.haskell.org", author = "Don Stewart, Duncan Coutts", stability = "", homepage = "http://www.cse.unsw.edu.au/~dons/fps.html", pkgUrl = "", synopsis = "Fast, packed, strict and lazy byte arrays with a list interface", description = "A time and space-efficient implementation of byte vectors using\npacked Word8 arrays, suitable for high performance use, both in terms\nof large data quantities, or high speed requirements. Byte vectors\nare encoded as strict 'Word8' arrays of bytes, and lazy lists of\nstrict chunks, held in a 'ForeignPtr', and can be passed between C\nand Haskell with little effort.\n\nTest coverage data for this library is available at:\n<http://code.haskell.org/~dons/tests/bytestring/hpc_index.html>", category = "Data", exposed = True, exposedModules = [ModuleName ["Data","ByteString"],ModuleName ["Data","ByteString","Char8"],ModuleName ["Data","ByteString","Unsafe"],ModuleName ["Data","ByteString","Internal"],ModuleName ["Data","ByteString","Lazy"],ModuleName ["Data","ByteString","Lazy","Char8"],ModuleName ["Data","ByteString","Lazy","Internal"],ModuleName ["Data","ByteString","Fusion"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/bytestring-0.9.2.1"], libraryDirs = ["/usr/lib/ghc/bytestring-0.9.2.1"], hsLibraries = ["HSbytestring-0.9.2.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/bytestring-0.9.2.1/include"], includes = ["fpstring.h"], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "ghc-prim-0.2.0.0-c2ff696e5b8ec4d4b2bc2e42085fe471"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/bytestring-0.9.2.1/bytestring.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/bytestring-0.9.2.1"]}])]),(PackageName "directory",fromList [(Version {versionBranch = [1,1,0,2], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "directory-1.1.0.2-ebacad9b5233212b1abbebce9b7e6524", sourcePackageId = PackageIdentifier {pkgName = PackageName "directory", pkgVersion = Version {versionBranch = [1,1,0,2], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "library for directory handling", description = "This package provides a library for handling directories.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Directory"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/directory-1.1.0.2"], libraryDirs = ["/usr/lib/ghc/directory-1.1.0.2"], hsLibraries = ["HSdirectory-1.1.0.2"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/directory-1.1.0.2/include"], includes = ["HsDirectory.h"], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "filepath-1.3.0.0-973f5e9fbed93e25cbe66dfeb6b99ad9",InstalledPackageId "old-time-1.1.0.0-b77788a065c86ada9ba279afa5e04576",InstalledPackageId "unix-2.5.1.0-b7c7408f284e3570d0d4dbd1f423845f"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/directory-1.1.0.2/directory.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/directory-1.1.0.2"]}])]),(PackageName "filepath",fromList [(Version {versionBranch = [1,3,0,0], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "filepath-1.3.0.0-973f5e9fbed93e25cbe66dfeb6b99ad9", sourcePackageId = PackageIdentifier {pkgName = PackageName "filepath", pkgVersion = Version {versionBranch = [1,3,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "", author = "Neil Mitchell", stability = "", homepage = "http://www-users.cs.york.ac.uk/~ndm/filepath/", pkgUrl = "", synopsis = "Library for manipulating FilePaths in a cross platform way.", description = "", category = "System", exposed = True, exposedModules = [ModuleName ["System","FilePath"],ModuleName ["System","FilePath","Posix"],ModuleName ["System","FilePath","Windows"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/filepath-1.3.0.0"], libraryDirs = ["/usr/lib/ghc/filepath-1.3.0.0"], hsLibraries = ["HSfilepath-1.3.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/filepath-1.3.0.0/filepath.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/filepath-1.3.0.0"]}])]),(PackageName "ghc-prim",fromList [(Version {versionBranch = [0,2,0,0], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "ghc-prim-0.2.0.0-c2ff696e5b8ec4d4b2bc2e42085fe471", sourcePackageId = PackageIdentifier {pkgName = PackageName "ghc-prim", pkgVersion = Version {versionBranch = [0,2,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "GHC primitives", description = "GHC primitives.", category = "", exposed = True, exposedModules = [ModuleName ["GHC","Prim"],ModuleName ["GHC","Classes"],ModuleName ["GHC","CString"],ModuleName ["GHC","Debug"],ModuleName ["GHC","Generics"],ModuleName ["GHC","Magic"],ModuleName ["GHC","PrimopWrappers"],ModuleName ["GHC","IntWord64"],ModuleName ["GHC","Tuple"],ModuleName ["GHC","Types"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/ghc-prim-0.2.0.0"], libraryDirs = ["/usr/lib/ghc/ghc-prim-0.2.0.0"], hsLibraries = ["HSghc-prim-0.2.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "builtin_rts"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/ghc-prim-0.2.0.0/ghc-prim.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/ghc-prim-0.2.0.0"]}])]),(PackageName "integer-gmp",fromList [(Version {versionBranch = [0,4,0,0], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "integer-gmp-0.4.0.0-3cccac07aef8e27023f605c1f45bdf74", sourcePackageId = PackageIdentifier {pkgName = PackageName "integer-gmp", pkgVersion = Version {versionBranch = [0,4,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "Integer library based on GMP", description = "This package contains an Integer library based on GMP.", category = "", exposed = True, exposedModules = [ModuleName ["GHC","Integer"],ModuleName ["GHC","Integer","GMP","Internals"],ModuleName ["GHC","Integer","GMP","Prim"],ModuleName ["GHC","Integer","Logarithms"],ModuleName ["GHC","Integer","Logarithms","Internals"]], hiddenModules = [ModuleName ["GHC","Integer","Type"]], trusted = False, importDirs = ["/usr/lib/ghc/integer-gmp-0.4.0.0"], libraryDirs = ["/usr/lib/ghc/integer-gmp-0.4.0.0"], hsLibraries = ["HSinteger-gmp-0.4.0.0"], extraLibraries = ["gmp"], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "ghc-prim-0.2.0.0-c2ff696e5b8ec4d4b2bc2e42085fe471"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/integer-gmp-0.4.0.0/integer-gmp.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/integer-gmp-0.4.0.0"]}])]),(PackageName "mtl",fromList [(Version {versionBranch = [2,0,1,0], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "mtl-2.0.1.0-db19dd8a7700e3d3adda8aa8fe5bf53d", sourcePackageId = PackageIdentifier {pkgName = PackageName "mtl", pkgVersion = Version {versionBranch = [2,0,1,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "Andy Gill", stability = "", homepage = "", pkgUrl = "", synopsis = "Monad classes, using functional dependencies", description = "Monad classes using functional dependencies, with instances\nfor various monad transformers, inspired by the paper\n/Functional Programming with Overloading and Higher-Order Polymorphism/,\nby Mark P Jones, in /Advanced School of Functional Programming/, 1995\n(<http://web.cecs.pdx.edu/~mpj/pubs/springschool.html>).", category = "Control", exposed = True, exposedModules = [ModuleName ["Control","Monad","Cont"],ModuleName ["Control","Monad","Cont","Class"],ModuleName ["Control","Monad","Error"],ModuleName ["Control","Monad","Error","Class"],ModuleName ["Control","Monad","Identity"],ModuleName ["Control","Monad","List"],ModuleName ["Control","Monad","RWS"],ModuleName ["Control","Monad","RWS","Class"],ModuleName ["Control","Monad","RWS","Lazy"],ModuleName ["Control","Monad","RWS","Strict"],ModuleName ["Control","Monad","Reader"],ModuleName ["Control","Monad","Reader","Class"],ModuleName ["Control","Monad","State"],ModuleName ["Control","Monad","State","Class"],ModuleName ["Control","Monad","State","Lazy"],ModuleName ["Control","Monad","State","Strict"],ModuleName ["Control","Monad","Trans"],ModuleName ["Control","Monad","Writer"],ModuleName ["Control","Monad","Writer","Class"],ModuleName ["Control","Monad","Writer","Lazy"],ModuleName ["Control","Monad","Writer","Strict"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/haskell-packages/ghc/lib/mtl-2.0.1.0/ghc-7.4.1"], libraryDirs = ["/usr/lib/haskell-packages/ghc/lib/mtl-2.0.1.0/ghc-7.4.1"], hsLibraries = ["HSmtl-2.0.1.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "transformers-0.2.2.0-367ec8196a45fab9903c082ddf1e964e"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/mtl-2.0.1.0/mtl.haddock"], haddockHTMLs = ["/usr/share/doc/libghc-mtl-doc/html/"]}])]),(PackageName "old-locale",fromList [(Version {versionBranch = [1,0,0,4], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "old-locale-1.0.0.4-a2c3d942f886fb70df8171795fdc2e5a", sourcePackageId = PackageIdentifier {pkgName = PackageName "old-locale", pkgVersion = Version {versionBranch = [1,0,0,4], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "locale library", description = "This package provides the old locale library.\nFor new code, the new locale library is recommended.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Locale"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/old-locale-1.0.0.4"], libraryDirs = ["/usr/lib/ghc/old-locale-1.0.0.4"], hsLibraries = ["HSold-locale-1.0.0.4"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/old-locale-1.0.0.4/old-locale.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/old-locale-1.0.0.4"]}])]),(PackageName "old-time",fromList [(Version {versionBranch = [1,1,0,0], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "old-time-1.1.0.0-b77788a065c86ada9ba279afa5e04576", sourcePackageId = PackageIdentifier {pkgName = PackageName "old-time", pkgVersion = Version {versionBranch = [1,1,0,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "Time library", description = "This package provides the old time library.\nFor new code, the new time library is recommended.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Time"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/old-time-1.1.0.0"], libraryDirs = ["/usr/lib/ghc/old-time-1.1.0.0"], hsLibraries = ["HSold-time-1.1.0.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/old-time-1.1.0.0/include"], includes = ["HsTime.h"], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "old-locale-1.0.0.4-a2c3d942f886fb70df8171795fdc2e5a"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/old-time-1.1.0.0/old-time.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/old-time-1.1.0.0"]}])]),(PackageName "process",fromList [(Version {versionBranch = [1,1,0,1], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "process-1.1.0.1-18dadd8ad5fc640f55a7afdc7aace500", sourcePackageId = PackageIdentifier {pkgName = PackageName "process", pkgVersion = Version {versionBranch = [1,1,0,1], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "Process libraries", description = "This package contains libraries for dealing with system processes.", category = "System", exposed = True, exposedModules = [ModuleName ["System","Process","Internals"],ModuleName ["System","Process"],ModuleName ["System","Cmd"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/ghc/process-1.1.0.1"], libraryDirs = ["/usr/lib/ghc/process-1.1.0.1"], hsLibraries = ["HSprocess-1.1.0.1"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/process-1.1.0.1/include"], includes = ["runProcess.h"], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "directory-1.1.0.2-ebacad9b5233212b1abbebce9b7e6524",InstalledPackageId "filepath-1.3.0.0-973f5e9fbed93e25cbe66dfeb6b99ad9",InstalledPackageId "unix-2.5.1.0-b7c7408f284e3570d0d4dbd1f423845f"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/process-1.1.0.1/process.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/process-1.1.0.1"]}])]),(PackageName "rts",fromList [(Version {versionBranch = [1,0], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "builtin_rts", sourcePackageId = PackageIdentifier {pkgName = PackageName "rts", pkgVersion = Version {versionBranch = [1,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "glasgow-haskell-users@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "", description = "", category = "", exposed = True, exposedModules = [], hiddenModules = [], trusted = False, importDirs = [], libraryDirs = ["/usr/lib/ghc"], hsLibraries = ["HSrts"], extraLibraries = ["ffi","m","rt","dl"], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/include"], includes = ["Stg.h"], depends = [], hugsOptions = [], ccOptions = [], ldOptions = ["-u","ghczmprim_GHCziTypes_Izh_static_info","-u","ghczmprim_GHCziTypes_Czh_static_info","-u","ghczmprim_GHCziTypes_Fzh_static_info","-u","ghczmprim_GHCziTypes_Dzh_static_info","-u","base_GHCziPtr_Ptr_static_info","-u","base_GHCziWord_Wzh_static_info","-u","base_GHCziInt_I8zh_static_info","-u","base_GHCziInt_I16zh_static_info","-u","base_GHCziInt_I32zh_static_info","-u","base_GHCziInt_I64zh_static_info","-u","base_GHCziWord_W8zh_static_info","-u","base_GHCziWord_W16zh_static_info","-u","base_GHCziWord_W32zh_static_info","-u","base_GHCziWord_W64zh_static_info","-u","base_GHCziStable_StablePtr_static_info","-u","ghczmprim_GHCziTypes_Izh_con_info","-u","ghczmprim_GHCziTypes_Czh_con_info","-u","ghczmprim_GHCziTypes_Fzh_con_info","-u","ghczmprim_GHCziTypes_Dzh_con_info","-u","base_GHCziPtr_Ptr_con_info","-u","base_GHCziPtr_FunPtr_con_info","-u","base_GHCziStable_StablePtr_con_info","-u","ghczmprim_GHCziTypes_False_closure","-u","ghczmprim_GHCziTypes_True_closure","-u","base_GHCziPack_unpackCString_closure","-u","base_GHCziIOziException_stackOverflow_closure","-u","base_GHCziIOziException_heapOverflow_closure","-u","base_ControlziExceptionziBase_nonTermination_closure","-u","base_GHCziIOziException_blockedIndefinitelyOnMVar_closure","-u","base_GHCziIOziException_blockedIndefinitelyOnSTM_closure","-u","base_ControlziExceptionziBase_nestedAtomically_closure","-u","base_GHCziWeak_runFinalizzerBatch_closure","-u","base_GHCziTopHandler_flushStdHandles_closure","-u","base_GHCziTopHandler_runIO_closure","-u","base_GHCziTopHandler_runNonIO_closure","-u","base_GHCziConcziIO_ensureIOManagerIsRunning_closure","-u","base_GHCziConcziSync_runSparks_closure","-u","base_GHCziConcziSignal_runHandlers_closure"], frameworkDirs = [], frameworks = [], haddockInterfaces = [], haddockHTMLs = []}])]),(PackageName "transformers",fromList [(Version {versionBranch = [0,2,2,0], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "transformers-0.2.2.0-367ec8196a45fab9903c082ddf1e964e", sourcePackageId = PackageIdentifier {pkgName = PackageName "transformers", pkgVersion = Version {versionBranch = [0,2,2,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "Ross Paterson <ross@soi.city.ac.uk>", author = "Andy Gill, Ross Paterson", stability = "", homepage = "", pkgUrl = "", synopsis = "Concrete functor and monad transformers", description = "Haskell 98 part of a monad transformer library, inspired by the paper\n\\\"Functional Programming with Overloading and Higher-Order Polymorphism\\\",\nby Mark P Jones, in /Advanced School of Functional Programming/, 1995\n(<http://web.cecs.pdx.edu/~mpj/pubs/springschool.html>).\n\nThis part contains the monad transformer class, the concrete monad\ntransformers, operations and liftings. It can be used on its own\nin Haskell 98 code, or with the monad classes in the @monads-fd@ or\n@monads-tf@ packages, which automatically lift operations introduced\nby monad transformers through other transformers.", category = "Control", exposed = True, exposedModules = [ModuleName ["Control","Monad","IO","Class"],ModuleName ["Control","Monad","Trans","Class"],ModuleName ["Control","Monad","Trans","Cont"],ModuleName ["Control","Monad","Trans","Error"],ModuleName ["Control","Monad","Trans","Identity"],ModuleName ["Control","Monad","Trans","List"],ModuleName ["Control","Monad","Trans","Maybe"],ModuleName ["Control","Monad","Trans","Reader"],ModuleName ["Control","Monad","Trans","RWS"],ModuleName ["Control","Monad","Trans","RWS","Lazy"],ModuleName ["Control","Monad","Trans","RWS","Strict"],ModuleName ["Control","Monad","Trans","State"],ModuleName ["Control","Monad","Trans","State","Lazy"],ModuleName ["Control","Monad","Trans","State","Strict"],ModuleName ["Control","Monad","Trans","Writer"],ModuleName ["Control","Monad","Trans","Writer","Lazy"],ModuleName ["Control","Monad","Trans","Writer","Strict"],ModuleName ["Data","Functor","Compose"],ModuleName ["Data","Functor","Constant"],ModuleName ["Data","Functor","Identity"],ModuleName ["Data","Functor","Product"]], hiddenModules = [], trusted = False, importDirs = ["/usr/lib/haskell-packages/ghc/lib/transformers-0.2.2.0/ghc-7.4.1"], libraryDirs = ["/usr/lib/haskell-packages/ghc/lib/transformers-0.2.2.0/ghc-7.4.1"], hsLibraries = ["HStransformers-0.2.2.0"], extraLibraries = [], extraGHCiLibraries = [], includeDirs = [], includes = [], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/transformers-0.2.2.0/transformers.haddock"], haddockHTMLs = ["/usr/share/doc/libghc-transformers-doc/html/"]}])]),(PackageName "unix",fromList [(Version {versionBranch = [2,5,1,0], versionTags = []},[InstalledPackageInfo {installedPackageId = InstalledPackageId "unix-2.5.1.0-b7c7408f284e3570d0d4dbd1f423845f", sourcePackageId = PackageIdentifier {pkgName = PackageName "unix", pkgVersion = Version {versionBranch = [2,5,1,0], versionTags = []}}, license = BSD3, copyright = "", maintainer = "libraries@haskell.org", author = "", stability = "", homepage = "", pkgUrl = "", synopsis = "POSIX functionality", description = "This package gives you access to the set of operating system\nservices standardised by POSIX 1003.1b (or the IEEE Portable\nOperating System Interface for Computing Environments -\nIEEE Std. 1003.1).\n\nThe package is not supported under Windows (except under Cygwin).", category = "System", exposed = True, exposedModules = [ModuleName ["System","Posix"],ModuleName ["System","Posix","ByteString"],ModuleName ["System","Posix","Error"],ModuleName ["System","Posix","Resource"],ModuleName ["System","Posix","Time"],ModuleName ["System","Posix","Unistd"],ModuleName ["System","Posix","User"],ModuleName ["System","Posix","Signals"],ModuleName ["System","Posix","Signals","Exts"],ModuleName ["System","Posix","Semaphore"],ModuleName ["System","Posix","SharedMem"],ModuleName ["System","Posix","ByteString","FilePath"],ModuleName ["System","Posix","Directory"],ModuleName ["System","Posix","Directory","ByteString"],ModuleName ["System","Posix","DynamicLinker","Module"],ModuleName ["System","Posix","DynamicLinker","Module","ByteString"],ModuleName ["System","Posix","DynamicLinker","Prim"],ModuleName ["System","Posix","DynamicLinker","ByteString"],ModuleName ["System","Posix","DynamicLinker"],ModuleName ["System","Posix","Files"],ModuleName ["System","Posix","Files","ByteString"],ModuleName ["System","Posix","IO"],ModuleName ["System","Posix","IO","ByteString"],ModuleName ["System","Posix","Env"],ModuleName ["System","Posix","Env","ByteString"],ModuleName ["System","Posix","Process"],ModuleName ["System","Posix","Process","Internals"],ModuleName ["System","Posix","Process","ByteString"],ModuleName ["System","Posix","Temp"],ModuleName ["System","Posix","Temp","ByteString"],ModuleName ["System","Posix","Terminal"],ModuleName ["System","Posix","Terminal","ByteString"]], hiddenModules = [ModuleName ["System","Posix","Directory","Common"],ModuleName ["System","Posix","DynamicLinker","Common"],ModuleName ["System","Posix","Files","Common"],ModuleName ["System","Posix","IO","Common"],ModuleName ["System","Posix","Process","Common"],ModuleName ["System","Posix","Terminal","Common"]], trusted = False, importDirs = ["/usr/lib/ghc/unix-2.5.1.0"], libraryDirs = ["/usr/lib/ghc/unix-2.5.1.0"], hsLibraries = ["HSunix-2.5.1.0"], extraLibraries = ["rt","util","dl","pthread"], extraGHCiLibraries = [], includeDirs = ["/usr/lib/ghc/unix-2.5.1.0/include"], includes = ["HsUnix.h","execvpe.h"], depends = [InstalledPackageId "base-4.5.0.0-40b99d05fae6a4eea95ea69e6e0c9702",InstalledPackageId "bytestring-0.9.2.1-18f26186028d7c0e92e78edc9071d376"], hugsOptions = [], ccOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [], haddockInterfaces = ["/usr/lib/ghc-doc/haddock/unix-2.5.1.0/unix.haddock"], haddockHTMLs = ["/usr/share/doc/ghc-doc/html/libraries/unix-2.5.1.0"]}])])]), pkgDescrFile = Just "./BNFC.cabal", localPkgDescr = PackageDescription {package = PackageIdentifier {pkgName = PackageName "BNFC", pkgVersion = Version {versionBranch = [2,4,2,1], versionTags = []}}, license = GPL Nothing, licenseFile = "COPYING", copyright = "(c) Krasimir Angelov, Bjorn Bringert, Johan Broberg, Paul Callaghan, Markus Forsberg, Ola Frid, Peter Gammie, Patrik Jansson, Kristofer Johannisson, Antti-Juhani Kaijanaho, Ulf Norell, Michael Pellauer and Aarne Ranta 2002 - 2010. Free software under GNU General Public License (GPL).", maintainer = "Markus Forsberg <markus.forsberg@gu.se> Aarne Ranta <aarne@chalmers.se>", author = "", stability = "", testedWith = [(GHC,ThisVersion (Version {versionBranch = [7,4,1], versionTags = []}))], homepage = "http://www.cse.chalmers.se/research/group/Language-technology/BNFC/", pkgUrl = "", bugReports = "", sourceRepos = [], synopsis = "A compiler front-end generator.", description = "The BNF Converter is a compiler construction tool generating a compiler front-end\nfrom a Labelled BNF grammar. It was originally written to generate Haskell,\nbut starting from Version 2.0, it can also be used for generating Java, C++, and C.\n\nGiven a Labelled BNF grammar the tool produces:\nan abstract syntax as a Haskell/C++/C module or Java directory,\na case skeleton for the abstract syntax in the same language,\nan Alex, JLex, or Flex lexer generator file,\na Happy, CUP, or Bison parser generator file,\na pretty-printer as a Haskell/Java/C++/C module,\na Latex file containing a readable specification of the language.\n\nThis version only works with Alex version < 3, e.g. alex-2.3.5.", category = "Development", customFieldsPD = [], buildDepends = [Dependency (PackageName "array") (IntersectVersionRanges AnyVersion (ThisVersion (Version {versionBranch = [0,4,0,0], versionTags = []}))),Dependency (PackageName "base") (IntersectVersionRanges (IntersectVersionRanges (UnionVersionRanges (ThisVersion (Version {versionBranch = [4], versionTags = []})) (LaterVersion (Version {versionBranch = [4], versionTags = []}))) (EarlierVersion (Version {versionBranch = [5], versionTags = []}))) (ThisVersion (Version {versionBranch = [4,5,0,0], versionTags = []}))),Dependency (PackageName "directory") (IntersectVersionRanges AnyVersion (ThisVersion (Version {versionBranch = [1,1,0,2], versionTags = []}))),Dependency (PackageName "mtl") (IntersectVersionRanges AnyVersion (ThisVersion (Version {versionBranch = [2,0,1,0], versionTags = []}))),Dependency (PackageName "process") (IntersectVersionRanges AnyVersion (ThisVersion (Version {versionBranch = [1,1,0,1], versionTags = []})))], specVersionRaw = Right (UnionVersionRanges (ThisVersion (Version {versionBranch = [1,2], versionTags = []})) (LaterVersion (Version {versionBranch = [1,2], versionTags = []}))), buildType = Just Simple, library = Nothing, executables = [Executable {exeName = "bnfc", modulePath = "Main.hs", buildInfo = BuildInfo {buildable = True, buildTools = [], cppOptions = [], ccOptions = [], ldOptions = [], pkgconfigDepends = [], frameworks = [], cSources = [], hsSourceDirs = [".","formats","formats/haskell2","formats/haskell-gadt","formats/xml","formats/profile","formats/java","formats/java1.5","formats/cpp","formats/c","formats/ocaml","formats/cpp_stl","formats/c-sharp","formats/f-sharp"], otherModules = [ModuleName ["LexBNF"],ModuleName ["ParBNF"],ModuleName ["AbsBNF"],ModuleName ["PrintBNF"],ModuleName ["Utils"],ModuleName ["CF"],ModuleName ["ErrM"],ModuleName ["MultiView"],ModuleName ["TypeChecker"],ModuleName ["GetCF"],ModuleName ["NamedVariables"],ModuleName ["OOAbstract"],ModuleName ["CFtoLatex"],ModuleName ["CFtoXML"],ModuleName ["CFtoTxt"],ModuleName ["HaskellTop"],ModuleName ["RegToAlex"],ModuleName ["CFtoTemplate"],ModuleName ["CFtoAlex2"],ModuleName ["CFtoAlex"],ModuleName ["CFtoHappy"],ModuleName ["CFtoPrinter"],ModuleName ["CFtoAbstract"],ModuleName ["CFtoLayout"],ModuleName ["MkErrM"],ModuleName ["MkSharedString"],ModuleName ["ProfileTop"],ModuleName ["CFtoHappyProfile"],ModuleName ["HaskellTopGADT"],ModuleName ["HaskellGADTCommon"],ModuleName ["CFtoPrinterGADT"],ModuleName ["CFtoTemplateGADT"],ModuleName ["CFtoAbstractGADT"],ModuleName ["OCamlTop"],ModuleName ["OCamlUtil"],ModuleName ["CFtoOCamlTest"],ModuleName ["CFtoOCamlShow"],ModuleName ["CFtoOCamlPrinter"],ModuleName ["CFtoOCamlTemplate"],ModuleName ["CFtoOCamlAbs"],ModuleName ["CFtoOCamlYacc"],ModuleName ["CFtoOCamlLex"],ModuleName ["CTop"],ModuleName ["CFtoCPrinter"],ModuleName ["CFtoCSkel"],ModuleName ["CFtoBisonC"],ModuleName ["CFtoFlexC"],ModuleName ["CFtoCAbs"],ModuleName ["CFtoCVisitSkel"],ModuleName ["CPPTop"],ModuleName ["RegToFlex"],ModuleName ["CFtoFlex"],ModuleName ["CFtoBison"],ModuleName ["CFtoCPPPrinter"],ModuleName ["CFtoCPPAbs"],ModuleName ["CFtoBisonSTL"],ModuleName ["CFtoSTLAbs"],ModuleName ["STLUtils"],ModuleName ["CFtoCVisitSkelSTL"],ModuleName ["CFtoSTLPrinter"],ModuleName ["STLTop"],ModuleName ["CSharpTop"],ModuleName ["RegToGPLEX"],ModuleName ["CFtoGPLEX"],ModuleName ["CSharpUtils"],ModuleName ["CFtoCSharpPrinter"],ModuleName ["CAbstoCSharpAbs"],ModuleName ["CAbstoCSharpAbstractVisitSkeleton"],ModuleName ["CAbstoCSharpVisitSkeleton"],ModuleName ["CFtoGPPG"],ModuleName ["JavaTop"],ModuleName ["RegToJLex"],ModuleName ["CFtoCup"],ModuleName ["CFtoVisitSkel"],ModuleName ["CFtoJavaSkeleton"],ModuleName ["CFtoJavaPrinter"],ModuleName ["CFtoJavaAbs"],ModuleName ["CFtoJLex"],ModuleName ["JavaTop15"],ModuleName ["CFtoJavaAbs15"],ModuleName ["CFtoAllVisitor"],ModuleName ["CFtoFoldVisitor"],ModuleName ["CFtoAbstractVisitor"],ModuleName ["CFtoComposVisitor"],ModuleName ["CFtoVisitSkel15"],ModuleName ["CFtoJavaPrinter15"],ModuleName ["CFtoJLex15"],ModuleName ["CFtoCup15"],ModuleName ["FSharpTop"]], defaultLanguage = Nothing, otherLanguages = [], defaultExtensions = [], otherExtensions = [], oldExtensions = [], extraLibs = [], extraLibDirs = [], includeDirs = [], includes = [], installIncludes = [], options = [], ghcProfOptions = [], ghcSharedOptions = [], customFieldsBI = [], targetBuildDepends = [Dependency (PackageName "array") (IntersectVersionRanges AnyVersion (ThisVersion (Version {versionBranch = [0,4,0,0], versionTags = []}))),Dependency (PackageName "base") (IntersectVersionRanges (IntersectVersionRanges (UnionVersionRanges (ThisVersion (Version {versionBranch = [4], versionTags = []})) (LaterVersion (Version {versionBranch = [4], versionTags = []}))) (EarlierVersion (Version {versionBranch = [5], versionTags = []}))) (ThisVersion (Version {versionBranch = [4,5,0,0], versionTags = []}))),Dependency (PackageName "directory") (IntersectVersionRanges AnyVersion (ThisVersion (Version {versionBranch = [1,1,0,2], versionTags = []}))),Dependency (PackageName "mtl") (IntersectVersionRanges AnyVersion (ThisVersion (Version {versionBranch = [2,0,1,0], versionTags = []}))),Dependency (PackageName "process") (IntersectVersionRanges AnyVersion (ThisVersion (Version {versionBranch = [1,1,0,1], versionTags = []})))]}}], testSuites = [], benchmarks = [], dataFiles = [], dataDir = "", extraSrcFiles = ["BNF.cf"], extraTmpFiles = []}, withPrograms = [("alex",ConfiguredProgram {programId = "alex", programVersion = Just (Version {versionBranch = [2,3,5], versionTags = []}), programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/home/abel/.cabal/bin/alex"}}),("ar",ConfiguredProgram {programId = "ar", programVersion = Nothing, programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ar"}}),("cpphs",ConfiguredProgram {programId = "cpphs", programVersion = Just (Version {versionBranch = [1,12], versionTags = []}), programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/home/abel/.cabal/bin/cpphs"}}),("ffihugs",ConfiguredProgram {programId = "ffihugs", programVersion = Nothing, programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ffihugs"}}),("gcc",ConfiguredProgram {programId = "gcc", programVersion = Just (Version {versionBranch = [4,6], versionTags = []}), programDefaultArgs = ["-Wl,--hash-size=31","-Wl,--reduce-memory-overheads"], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/gcc"}}),("ghc",ConfiguredProgram {programId = "ghc", programVersion = Just (Version {versionBranch = [7,4,1], versionTags = []}), programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ghc"}}),("ghc-pkg",ConfiguredProgram {programId = "ghc-pkg", programVersion = Just (Version {versionBranch = [7,4,1], versionTags = []}), programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ghc-pkg"}}),("haddock",ConfiguredProgram {programId = "haddock", programVersion = Just (Version {versionBranch = [2,10,0], versionTags = []}), programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/haddock"}}),("happy",ConfiguredProgram {programId = "happy", programVersion = Just (Version {versionBranch = [1,18,9], versionTags = []}), programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/happy"}}),("hpc",ConfiguredProgram {programId = "hpc", programVersion = Just (Version {versionBranch = [0,6], versionTags = []}), programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/hpc"}}),("hsc2hs",ConfiguredProgram {programId = "hsc2hs", programVersion = Just (Version {versionBranch = [0,67], versionTags = []}), programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/hsc2hs"}}),("hugs",ConfiguredProgram {programId = "hugs", programVersion = Nothing, programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/hugs"}}),("ld",ConfiguredProgram {programId = "ld", programVersion = Nothing, programDefaultArgs = ["-x","--hash-size=31","--reduce-memory-overheads"], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ld"}}),("pkg-config",ConfiguredProgram {programId = "pkg-config", programVersion = Just (Version {versionBranch = [0,26], versionTags = []}), programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/pkg-config"}}),("ranlib",ConfiguredProgram {programId = "ranlib", programVersion = Nothing, programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/ranlib"}}),("strip",ConfiguredProgram {programId = "strip", programVersion = Nothing, programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/usr/bin/strip"}}),("tar",ConfiguredProgram {programId = "tar", programVersion = Nothing, programDefaultArgs = [], programOverrideArgs = [], programLocation = FoundOnSystem {locationPath = "/bin/tar"}})], withPackageDB = [GlobalPackageDB,UserPackageDB], withVanillaLib = True, withProfLib = False, withSharedLib = False, withDynExe = False, withProfExe = False, withOptimization = NormalOptimisation, withGHCiLib = True, splitObjs = False, stripExes = True, progPrefix = "", progSuffix = ""}
@@ -22,7 +22,7 @@ import CF import AbsBNF (Reg (..)) import Utils-import List (nub,intersperse)+import Data.List (nub,intersperse) cfToLatex :: String -> CF -> String cfToLatex name cf = unlines [
@@ -22,7 +22,7 @@ import CF import AbsBNF (Reg (..)) import Utils-import List (nub,intersperse)+import Data.List (nub,intersperse) cfToTxt :: String -> CF -> String cfToTxt name cf = unlines [
@@ -38,8 +38,8 @@ module NamedVariables where import CF-import Char (toLower)-import List (nub)+import Data.Char (toLower)+import Data.List (nub) type IVar = (String, Int) --The type of an instance variable
@@ -44,8 +44,8 @@ import CF import Utils((+++),(++++)) import NamedVariables-import List-import Char(toLower)+import Data.List+import Data.Char(toLower) -- A datastructure more appropriate than CF
@@ -44,8 +44,8 @@ import CF import Utils((+++),(++++)) import NamedVariables-import List-import Char(toLower)+import Data.List+import Data.Char(toLower) import Data.Maybe import CSharpUtils
@@ -51,7 +51,7 @@ import CF import Utils ((+++), (++++)) import NamedVariables-import List+import Data.List import OOAbstract hiding (basetypes) import CSharpUtils import CAbstoCSharpAbs
@@ -41,7 +41,7 @@ import CF import Utils ((+++), (++++)) import NamedVariables-import List+import Data.List import OOAbstract hiding (basetypes) import CSharpUtils import CAbstoCSharpAbs
@@ -43,8 +43,8 @@ import CF import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper, isSpace)+import Data.List+import Data.Char(toLower, toUpper, isSpace) import Data.Maybe import CSharpUtils
@@ -42,7 +42,7 @@ import RegToGPLEX import Utils((+++), (++++)) import NamedVariables-import List+import Data.List import CSharpUtils --The environment must be returned for the parser to use.
@@ -39,9 +39,9 @@ module CFtoGPPG (cf2gppg) where import CF-import List (intersperse, isPrefixOf)+import Data.List (intersperse, isPrefixOf) import NamedVariables hiding (varName)-import Char (toLower,isUpper,isDigit)+import Data.Char (toLower,isUpper,isDigit) import Utils ((+++), (++++)) import TypeChecker import ErrM
@@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -}-{- +{- ************************************************************** BNF Converter Module @@ -31,8 +31,8 @@ Created : 20 November, 2006 Modified : 8 January, 2007 by Johan Broberg- - ************************************************************** ++ ************************************************************** -} module CSharpTop (makeCSharp) where@@ -48,12 +48,12 @@ import CFtoCSharpPrinter import CFtoLatex import CSharpUtils-import System import GetCF-import Char-import System-import System.Directory+import Data.Char import System.IO+import System.Directory+import System.Exit+import System.Environment import System.Process import Data.Maybe import Data.Char@@ -65,12 +65,12 @@ -> Bool -- Visual Studio files -> Bool -- Windows Communication Foundation support -> Maybe Namespace -- C# namespace to use- -> FilePath + -> FilePath -> IO () makeCSharp make vsfiles wcfSupport maybenamespace file = do (cf, isOK) <- tryReadCF file- if isOK - then do + if isOK+ then do let namespace = fromMaybe (filepathtonamespace file) maybenamespace cabs = cf2cabs cf absyn = cabs2csharpabs namespace cabs wcfSupport@@ -93,12 +93,12 @@ if vsfiles then (writeVisualStudioFiles namespace) else return () if make then (writeMakefile namespace) else return () putStrLn "Done!"- else do + else do putStrLn "Failed" exitFailure writeMakefile :: Namespace -> IO ()-writeMakefile namespace = do +writeMakefile namespace = do writeFileRep "Makefile" makefile putStrLn "" putStrLn "-----------------------------------------------------------------------------"@@ -110,7 +110,7 @@ putStrLn "-----------------------------------------------------------------------------" putStrLn "" where- makefile = unlines [ + makefile = unlines [ "MONO = mono", "MONOC = gmcs", "MONOCFLAGS = -optimize -reference:${PARSERREF}",@@ -338,7 +338,7 @@ projectguid :: IO String projectguid = do maybeFilePath <- findDirectory- guid <- maybe getBadGUID getGoodGUID maybeFilePath + guid <- maybe getBadGUID getGoodGUID maybeFilePath return guid where getBadGUID :: IO String@@ -349,19 +349,19 @@ putStrLn "-----------------------------------------------------------------------------" return "{00000000-0000-0000-0000-000000000000}" getGoodGUID :: FilePath -> IO String- getGoodGUID filepath = do + getGoodGUID filepath = do let filepath' = "\"" ++ filepath ++ "\"" (hIn, hOut, hErr, processHandle) <- runInteractiveCommand filepath' guid <- hGetLine hOut return ('{' : init guid ++ "}") findDirectory :: IO (Maybe FilePath) findDirectory = do- -- This works with Visual Studio 2005. - -- We will probably have to be modify this to include another environment variable name for Orcas. + -- This works with Visual Studio 2005.+ -- We will probably have to be modify this to include another environment variable name for Orcas. -- I doubt there is any need to support VS2003? (I doubt they have patched it up to have 2.0 support?) toolpath <- catch (getEnv "VS80COMNTOOLS") (\_ -> return "C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\Tools") exists <- doesDirectoryExist toolpath- if exists + if exists then return (Just (toolpath ++ "\\uuidgen.exe")) -- this handles the case when the user was clever enough to add the directory to his/her PATH else findExecutable "uuidgen.exe"
@@ -0,0 +1,367 @@+{-+ BNF Converter: C# Main file+ Copyright (C) 2006-2007 Author: Johan Broberg++ Modified from STLTop 2006.++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}+{- + **************************************************************+ BNF Converter Module++ Description : C# Main file++ Author : Johan Broberg (johan@pontemonti.com)++ License : GPL (GNU General Public License)++ Created : 20 November, 2006++ Modified : 8 January, 2007 by Johan Broberg+ + ************************************************************** +-}++module CSharpTop (makeCSharp) where++import Utils+import CF+import OOAbstract+import CAbstoCSharpAbs+import CFtoGPLEX+import CFtoGPPG+import CAbstoCSharpVisitSkeleton+import CAbstoCSharpAbstractVisitSkeleton+import CFtoCSharpPrinter+import CFtoLatex+import CSharpUtils+import System.IO+import GetCF+import Data.Char+import System.IO+import System.Directory+import System.IO+import System.Process+import Data.Maybe+import Data.Char+import Control.Monad.ST++-- Control.Monad.State++makeCSharp :: Bool -- Makefile+ -> Bool -- Visual Studio files+ -> Bool -- Windows Communication Foundation support+ -> Maybe Namespace -- C# namespace to use+ -> FilePath + -> IO ()+makeCSharp make vsfiles wcfSupport maybenamespace file = do+ (cf, isOK) <- tryReadCF file+ if isOK + then do + let namespace = fromMaybe (filepathtonamespace file) maybenamespace+ cabs = cf2cabs cf+ absyn = cabs2csharpabs namespace cabs wcfSupport+ (gplex, env) = cf2gplex namespace cf+ gppg = cf2gppg namespace cf env+ skeleton = cabs2csharpvisitskeleton namespace cabs+ absSkeleton = cabs2csharpAbstractVisitSkeleton namespace cabs+ printer = cf2csharpprinter namespace cf+ latex = cfToLatex namespace cf+ writeFileRep "Absyn.cs" absyn+ writeFileRep (namespace ++ ".l") gplex+ putStrLn " (Tested with GPLEX RC1)"+ writeFileRep (namespace ++ ".y") gppg+ putStrLn " (Tested with GPPG 1.0)"+ writeFileRep "AbstractVisitSkeleton.cs" absSkeleton+ writeFileRep "VisitSkeleton.cs" skeleton+ writeFileRep "Printer.cs" printer+ writeFileRep "Test.cs" (csharptest namespace cf)+ writeFileRep (namespace ++ ".tex") latex+ if vsfiles then (writeVisualStudioFiles namespace) else return ()+ if make then (writeMakefile namespace) else return ()+ putStrLn "Done!"+ else do + putStrLn "Failed"+ exitFailure++writeMakefile :: Namespace -> IO ()+writeMakefile namespace = do + writeFileRep "Makefile" makefile+ putStrLn ""+ putStrLn "-----------------------------------------------------------------------------"+ putStrLn "Generated Makefile, which uses mono. You may want to modify the paths to"+ putStrLn "GPLEX and GPPG - unless you are sure that they are globally accessible (the"+ putStrLn "default commands are \"mono gplex.exe\" and \"mono gppg.exe\", respectively."+ putStrLn "The Makefile assumes that ShiftReduceParser.dll is located in ./bin and that"+ putStrLn "is also where test.exe will be generated."+ putStrLn "-----------------------------------------------------------------------------"+ putStrLn ""+ where+ makefile = unlines [ + "MONO = mono",+ "MONOC = gmcs",+ "MONOCFLAGS = -optimize -reference:${PARSERREF}",+ "GPLEX = ${MONO} gplex.exe",+ "GPPG = ${MONO} gppg.exe",+ "LATEX = latex",+ "DVIPS = dvips",+ "PARSERREF = bin/ShiftReduceParser.dll",+ -- Apparently GPLEX outputs filenames in lowercase, so scanner.cs is supposed to be like that!+ "CSFILES = Absyn.cs Parser.cs Printer.cs scanner.cs Test.cs VisitSkeleton.cs",+ "",+ "all: test " ++ namespace ++ ".ps",+ "",+ "clean:",+ -- peteg: don't nuke what we generated - move that to the "vclean" target.+ "\trm -f " ++ namespace ++ ".dvi " ++ namespace ++ ".aux " ++ namespace ++ ".log " ++ namespace ++ ".ps test",+ "",+ "distclean:",+ "\trm -f ${CSFILES} " ++ namespace ++ ".l " ++ namespace ++ ".y " ++ namespace ++ ".tex " ++ namespace ++ ".dvi " ++ namespace ++ ".aux " ++ namespace ++ ".log " ++ namespace ++ ".ps test Makefile",+ "",+ "test: Parser.cs Scanner.cs",+ "\t@echo \"Compiling test...\"",+ "\t${MONOC} ${MONOCFLAGS} -out:bin/test.exe ${CSFILES}",+ "",+ "Scanner.cs: " ++ namespace ++ ".l",+ "\t${GPLEX} /out:Scanner.cs " ++ namespace ++ ".l",+ "",+ "Parser.cs: " ++ namespace ++ ".y",+ "\t${GPPG} /gplex " ++ namespace ++ ".y > Parser.cs",+ "",+ "" ++ namespace ++ ".dvi: " ++ namespace ++ ".tex",+ "\t${LATEX} " ++ namespace ++ ".tex",+ "",+ "" ++ namespace ++ ".ps: " ++ namespace ++ ".dvi",+ "\t${DVIPS} " ++ namespace ++ ".dvi -o " ++ namespace ++ ".ps",+ ""+ ]++writeVisualStudioFiles :: Namespace -> IO ()+writeVisualStudioFiles namespace = do+ guid <- projectguid+ writeFileRep (namespace ++ ".csproj") (csproj guid)+ writeFileRep (namespace ++ ".sln") (sln guid)+ writeFileRep "run-gp.bat" batchfile+ putStrLn ""+ putStrLn "-----------------------------------------------------------------------------"+ putStrLn "Visual Studio solution (.sln) and project (.csproj) files were written."+ putStrLn "The project file has a reference to GPLEX/GPPG's ShiftReduceParser. You will"+ putStrLn "have to either copy this file to bin\\ShiftReduceParser.dll or change the"+ putStrLn "reference so that it points to the right location (you can do this from"+ putStrLn "within Visual Studio)."+ putStrLn "Additionally, the project includes Parser.cs and Scanner.cs. These have not"+ putStrLn "been generated yet. You can use the run-gp.bat file to generate them, but"+ putStrLn "note that it requires gppg and gplex to be in your PATH."+ putStrLn "-----------------------------------------------------------------------------"+ putStrLn ""+ where+ batchfile = unlines [+ "@echo off",+ "gppg /gplex " ++ namespace ++ ".y > Parser.cs",+ "gplex /verbose /out:Scanner.cs " ++ namespace ++ ".l"+ ]+ sln guid = unlines [+ "Microsoft Visual Studio Solution File, Format Version 9.00",+ "# Visual Studio 2005",+ "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"" ++ namespace ++ "\", \"" ++ namespace ++ ".csproj\", \"" ++ guid ++ "\"",+ "EndProject",+ "Global",+ " GlobalSection(SolutionConfigurationPlatforms) = preSolution",+ " Debug|Any CPU = Debug|Any CPU",+ " Release|Any CPU = Release|Any CPU",+ " EndGlobalSection",+ " GlobalSection(ProjectConfigurationPlatforms) = postSolution",+ " " ++ guid ++ ".Debug|Any CPU.ActiveCfg = Debug|Any CPU",+ " " ++ guid ++ ".Debug|Any CPU.Build.0 = Debug|Any CPU",+ " " ++ guid ++ ".Release|Any CPU.ActiveCfg = Release|Any CPU",+ " " ++ guid ++ ".Release|Any CPU.Build.0 = Release|Any CPU",+ " EndGlobalSection",+ " GlobalSection(SolutionProperties) = preSolution",+ " HideSolutionNode = FALSE",+ " EndGlobalSection",+ "EndGlobal"+ ]+ csproj guid = unlines [+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>",+ "<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">",+ " <PropertyGroup>",+ " <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>",+ " <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>",+ " <ProductVersion>8.0.50727</ProductVersion>",+ " <SchemaVersion>2.0</SchemaVersion>",+ " <ProjectGuid>" ++ guid ++ "</ProjectGuid>",+ " <OutputType>Library</OutputType>",+ " <AppDesignerFolder>Properties</AppDesignerFolder>",+ " <RootNamespace>" ++ namespace ++ "</RootNamespace>",+ " <AssemblyName>" ++ namespace ++ "</AssemblyName>",+ " <StartupObject>",+ " </StartupObject>",+ " </PropertyGroup>",+ " <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \">",+ " <DebugSymbols>true</DebugSymbols>",+ " <DebugType>full</DebugType>",+ " <Optimize>false</Optimize>",+ " <OutputPath>bin\\Debug\\</OutputPath>",+ " <DefineConstants>DEBUG;TRACE</DefineConstants>",+ " <ErrorReport>prompt</ErrorReport>",+ " <WarningLevel>4</WarningLevel>",+ " </PropertyGroup>",+ " <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' \">",+ " <DebugType>pdbonly</DebugType>",+ " <Optimize>true</Optimize>",+ " <OutputPath>bin\\Release\\</OutputPath>",+ " <DefineConstants>TRACE</DefineConstants>",+ " <ErrorReport>prompt</ErrorReport>",+ " <WarningLevel>4</WarningLevel>",+ " </PropertyGroup>",+ " <Import Project=\"$(MSBuildBinPath)\\Microsoft.CSharp.targets\" />",+ " <!-- To modify your build process, add your task inside one of the targets below and uncomment it. ",+ " Other similar extension points exist, see Microsoft.Common.targets.",+ " <Target Name=\"BeforeBuild\">",+ " </Target>",+ " <Target Name=\"AfterBuild\">",+ " </Target>",+ " -->",+ " <ItemGroup>",+ " <Compile Include=\"AbstractVisitSkeleton.cs\" />",+ " <Compile Include=\"Absyn.cs\" />",+ " <Compile Include=\"Parser.cs\" />",+ " <Compile Include=\"Printer.cs\" />",+ " <Compile Include=\"Scanner.cs\" />",+ " <Compile Include=\"Test.cs\" />",+ " <Compile Include=\"VisitSkeleton.cs\" />",+ " </ItemGroup>",+ " <ItemGroup>",+ " <Reference Include=\"ShiftReduceParser, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL\">",+ " <SpecificVersion>False</SpecificVersion>",+ " <HintPath>bin\\ShiftReduceParser.dll</HintPath>",+ " </Reference>",+ " </ItemGroup>",+ " <ItemGroup>",+ " <None Include=\"" ++ namespace ++ ".cf\" />",+ " <None Include=\"" ++ namespace ++ ".l\" />",+ " <None Include=\"" ++ namespace ++ ".y\" />",+ " <None Include=\"" ++ namespace ++ ".tex\" />",+ " <None Include=\"run-gp.bat\" />",+ " </ItemGroup>",+ " <PropertyGroup>",+ " <PreBuildEvent>",+ " </PreBuildEvent>",+ " </PropertyGroup>",+ "</Project>"+ ]++csharptest :: Namespace -> CF -> String+csharptest namespace cf = unlines [+ "/*** Compiler Front-End Test automatically generated by the BNF Converter ***/",+ "/* */",+ "/* This test will parse a file, print the abstract syntax tree, and then */",+ "/* pretty-print the result. */",+ "/* */",+ "/****************************************************************************/",+ "using System;",+ "using System.IO;",+ "using " ++ namespace ++ ".Absyn;",+ "",+ "namespace " ++ namespace,+ "{",+ " public class Test",+ " {",+ " public static void Main(string[] args)",+ " {",+ " if (args.Length > 0)",+ " {",+ " Stream stream = File.OpenRead(args[0]);",+ " /* The default entry point is used. For other options see class Parser */",+ " Parser parser = new Parser();",+ " Scanner scanner = Scanner.CreateScanner(stream);",+ " // Uncomment to enable trace information:",+ " // parser.Trace shows what the parser is doing",+ " // parser.Trace = true;",+ " // scanner.Trace prints the tokens as they are parsed, one token per line",+ " // scanner.Trace = true;",+ " parser.scanner = scanner;",+ " try",+ " {",+ " " ++ def ++ " parse_tree = parser.Parse" ++ def ++ "();",+ " if (parse_tree != null)",+ " {",+ " Console.Out.WriteLine(\"Parse Successful!\");",+ " Console.Out.WriteLine(\"\");",+ " Console.Out.WriteLine(\"[Abstract Syntax]\");",+ " Console.Out.WriteLine(\"{0}\", PrettyPrinter.Show(parse_tree));",+ " Console.Out.WriteLine(\"\");",+ " Console.Out.WriteLine(\"[Linearized Tree]\");",+ " Console.Out.WriteLine(\"{0}\", PrettyPrinter.Print(parse_tree));",+ " }",+ " else",+ " {",+ " Console.Out.WriteLine(\"Parse NOT Successful!\");",+ " }",+ " }",+ " catch(Exception e)",+ " {",+ " Console.Out.WriteLine(\"Parse NOT Successful:\");",+ " Console.Out.WriteLine(e.Message);",+ " Console.Out.WriteLine(\"\");",+ " Console.Out.WriteLine(\"Stack Trace:\");",+ " Console.Out.WriteLine(e.StackTrace);",+ " }",+ " }",+ " else",+ " {",+ " Console.Out.WriteLine(\"You must specify a filename!\");",+ " }",+ " }",+ " }",+ "}"+ ]+ where+ def = head (allEntryPoints cf)++filepathtonamespace :: FilePath -> Namespace+filepathtonamespace file = take (length file - 3) (basename file)++projectguid :: IO String+projectguid = do+ maybeFilePath <- findDirectory+ guid <- maybe getBadGUID getGoodGUID maybeFilePath + return guid+ where+ getBadGUID :: IO String+ getBadGUID = do+ putStrLn "-----------------------------------------------------------------------------"+ putStrLn "Could not find Visual Studio tool uuidgen.exe to generate project GUID!"+ putStrLn "You might want to put this tool in your PATH."+ putStrLn "-----------------------------------------------------------------------------"+ return "{00000000-0000-0000-0000-000000000000}"+ getGoodGUID :: FilePath -> IO String+ getGoodGUID filepath = do + let filepath' = "\"" ++ filepath ++ "\""+ (hIn, hOut, hErr, processHandle) <- runInteractiveCommand filepath'+ guid <- hGetLine hOut+ return ('{' : init guid ++ "}")+ findDirectory :: IO (Maybe FilePath)+ findDirectory = do+ -- This works with Visual Studio 2005. + -- We will probably have to be modify this to include another environment variable name for Orcas. + -- I doubt there is any need to support VS2003? (I doubt they have patched it up to have 2.0 support?)+ toolpath <- catch (getEnv "VS80COMNTOOLS") (\_ -> return "C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\Tools")+ exists <- doesDirectoryExist toolpath+ if exists + then return (Just (toolpath ++ "\\uuidgen.exe"))+ -- this handles the case when the user was clever enough to add the directory to his/her PATH+ else findExecutable "uuidgen.exe"
@@ -40,9 +40,9 @@ import CF import Control.Monad.ST -- Control.Monad.State-import Char (toLower)+import Data.Char (toLower) import Data.Maybe-import List+import Data.List import OOAbstract hiding (basetypes) type Namespace = String
@@ -3,7 +3,7 @@ -- modified from RegToFlex import AbsBNF-import Char+import Data.Char -- the top-level printing method printRegGPLEX :: Reg -> String
@@ -42,9 +42,9 @@ module CFtoBisonC (cf2Bison) where import CF-import List (intersperse, isPrefixOf)+import Data.List (intersperse, isPrefixOf) import NamedVariables hiding (varName)-import Char (toLower)+import Data.Char (toLower) import Utils ((+++), (++++)) --This follows the basic structure of CFtoHappy.
@@ -43,8 +43,8 @@ import CF import Utils((+++),(++++)) import NamedVariables-import List-import Char(toLower)+import Data.List+import Data.Char(toLower) --The result is two files (.H file, .C file)
@@ -44,8 +44,8 @@ import CF import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper)+import Data.List+import Data.Char(toLower, toUpper) --Produces (.h file, .c file) cf2CPrinter :: CF -> (String, String)
@@ -42,8 +42,8 @@ import CF import Utils ( (+++) ) import NamedVariables-import List ( isPrefixOf )-import Char ( toLower, toUpper )+import Data.List ( isPrefixOf )+import Data.Char ( toLower, toUpper ) --Produces (.H file, .C file) cf2CSkel :: CF -> (String, String)
@@ -41,7 +41,7 @@ import RegToFlex -- import Utils((+++), (++++)) import NamedVariables-import List+import Data.List --The environment must be returned for the parser to use. cf2flex :: String -> CF -> (String, SymEnv)
@@ -26,15 +26,16 @@ import CFtoCSkel import CFtoCPrinter import CFtoLatex--- import System+-- import System.IO import GetCF-import Char-import System+import Data.Char+import System.IO+import System.Exit makeC :: Bool -> String -> FilePath -> IO () makeC make name file = do (cf, isOK) <- tryReadCF file- if isOK then do + if isOK then do let (hfile, cfile) = cf2CAbs name cf writeFileRep "Absyn.h" hfile writeFileRep "Absyn.c" cfile@@ -61,7 +62,7 @@ exitFailure makefile :: String -> String-makefile name = unlines +makefile name = unlines [ "CC = gcc", "CCFLAGS = -g -W -Wall",@@ -197,19 +198,19 @@ mkVar _ = "" mkDefines n [] = mkString n mkDefines n ((_,s):ss) = ("#define " ++ s +++ (show n) ++ "\n") ++ (mkDefines (n+1) ss)- mkString n = if isUsedCat cf "String" + mkString n = if isUsedCat cf "String" then ("#define _STRING_ " ++ show n ++ "\n") ++ mkChar (n+1) else mkChar n- mkChar n = if isUsedCat cf "Char" + mkChar n = if isUsedCat cf "Char" then ("#define _CHAR_ " ++ show n ++ "\n") ++ mkInteger (n+1) else mkInteger n- mkInteger n = if isUsedCat cf "Integer" + mkInteger n = if isUsedCat cf "Integer" then ("#define _INTEGER_ " ++ show n ++ "\n") ++ mkDouble (n+1) else mkDouble n- mkDouble n = if isUsedCat cf "Double" + mkDouble n = if isUsedCat cf "Double" then ("#define _DOUBLE_ " ++ show n ++ "\n") ++ mkIdent(n+1) else mkIdent n- mkIdent n = if isUsedCat cf "Ident" + mkIdent n = if isUsedCat cf "Ident" then ("#define _IDENT_ " ++ show n ++ "\n") else "" mkFunc s | (normCat s == s) = (identCat s) ++ " p" ++ (identCat s) ++ "(FILE *inp);\n"
@@ -0,0 +1,217 @@+{-+ BNF Converter: C Main file+ Copyright (C) 2004 Author: Michael Pellauer++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}+module CTop (makeC) where++import Utils+import CF+import CFtoCAbs+import CFtoFlexC+import CFtoBisonC+import CFtoCSkel+import CFtoCPrinter+import CFtoLatex+-- import System.IO+import GetCF+import Data.Char+import System.IO++makeC :: Bool -> String -> FilePath -> IO ()+makeC make name file = do+ (cf, isOK) <- tryReadCF file+ if isOK then do + let (hfile, cfile) = cf2CAbs name cf+ writeFileRep "Absyn.h" hfile+ writeFileRep "Absyn.c" cfile+ let (flex, env) = cf2flex name cf+ writeFileRep (name ++ ".l") flex+ putStrLn " (Tested with flex 2.5.31)"+ let bison = cf2Bison name cf env+ writeFileRep (name ++ ".y") bison+ putStrLn " (Tested with bison 1.875a)"+ let header = mkHeaderFile cf (allCats cf) (allEntryPoints cf) env+ writeFileRep "Parser.h" header+ let (skelH, skelC) = cf2CSkel cf+ writeFileRep "Skeleton.h" skelH+ writeFileRep "Skeleton.c" skelC+ let (prinH, prinC) = cf2CPrinter cf+ writeFileRep "Printer.h" prinH+ writeFileRep "Printer.c" prinC+ writeFileRep "Test.c" (ctest cf)+ let latex = cfToLatex name cf+ writeFileRep (name ++ ".tex") latex+ if make then (writeFileRep "Makefile" $ makefile name) else return ()+ putStrLn "Done!"+ else do putStrLn $ "Failed"+ exitFailure++makefile :: String -> String+makefile name = unlines + [+ "CC = gcc",+ "CCFLAGS = -g -W -Wall",+ "",+ "FLEX = flex",+ "FLEX_OPTS = -P" ++ name,+ "",+ "BISON = bison",+ "BISON_OPTS = -t -p" ++ name,+ "",+ "LATEX = latex",+ "DVIPS = dvips",+ "",+ "all: test" ++ name ++ " " ++ name ++ ".ps",+ "",+ ".PHONY: clean distclean",+ "",+ "clean:",+ -- peteg: don't nuke what we generated - move that to the "vclean" target.+ "\trm -f *.o " ++ name ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps test" ++ name,+ "",+ "distclean: clean", -- FIXME+ "\trm -f *.o Absyn.c Absyn.h Test.c Parser.c Parser.h Lexer.c Skeleton.c Skeleton.h Printer.c Printer.h " ++ name ++ ".l " ++ name ++ ".y " ++ name ++ ".tex " ++ name ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps test" ++ name ++ " Makefile",+ "",+ "test" ++ name ++ ": Absyn.o Lexer.o Parser.o Printer.o Test.o",+ "\t@echo \"Linking test" ++ name ++ "...\"",+ "\t${CC} ${CCFLAGS} *.o -o test" ++ name ++ "",+ "",+ "Absyn.o: Absyn.c Absyn.h",+ "\t${CC} ${CCFLAGS} -c Absyn.c",+ "",+ "Lexer.c: " ++ name ++ ".l",+ "\t${FLEX} ${FLEX_OPTS} -oLexer.c " ++ name ++ ".l",+ "",+ "Parser.c: " ++ name ++ ".y",+ "\t${BISON} ${BISON_OPTS} " ++ name ++ ".y -o Parser.c",+ "",+ "Lexer.o: Lexer.c Parser.h",+ "\t${CC} ${CCFLAGS} -c Lexer.c ",+ "",+ "Parser.o: Parser.c Absyn.h",+ "\t${CC} ${CCFLAGS} -c Parser.c",+ "",+ "Printer.o: Printer.c Printer.h Absyn.h",+ "\t${CC} ${CCFLAGS} -c Printer.c",+ "",+ "Test.o: Test.c Parser.h Printer.h Absyn.h",+ "\t${CC} ${CCFLAGS} -c Test.c",+ "",+ "" ++ name ++ ".dvi: " ++ name ++ ".tex",+ "\t${LATEX} " ++ name ++ ".tex",+ "",+ "" ++ name ++ ".ps: " ++ name ++ ".dvi",+ "\t${DVIPS} " ++ name ++ ".dvi -o " ++ name ++ ".ps",+ ""+ ]++ctest :: CF -> String+ctest cf =+ unlines+ [+ "/*** Compiler Front-End Test automatically generated by the BNF Converter ***/",+ "/* */",+ "/* This test will parse a file, print the abstract syntax tree, and then */",+ "/* pretty-print the result. */",+ "/* */",+ "/****************************************************************************/",+ "",+ "#include <stdio.h>",+ "#include <stdlib.h>",+ "",+ "#include \"Parser.h\"",+ "#include \"Printer.h\"",+ "#include \"Absyn.h\"",+ "",+ "int main(int argc, char ** argv)",+ "{",+ " FILE *input;",+ " " ++ def ++ " parse_tree;",+ " if (argc > 1) ",+ " {",+ " input = fopen(argv[1], \"r\");",+ " if (!input)",+ " {",+ " fprintf(stderr, \"Error opening input file.\\n\");",+ " exit(1);",+ " }",+ " }",+ " else input = stdin;",+ " /* The default entry point is used. For other options see Parser.h */",+ " parse_tree = p" ++ def ++ "(input);",+ " if (parse_tree)",+ " {",+ " printf(\"\\nParse Succesful!\\n\");",+ " printf(\"\\n[Abstract Syntax]\\n\");",+ " printf(\"%s\\n\\n\", show" ++ def ++ "(parse_tree));",+ " printf(\"[Linearized Tree]\\n\");",+ " printf(\"%s\\n\\n\", print" ++ def ++ "(parse_tree));",+ " return 0;",+ " }",+ " return 1;",+ "}",+ ""+ ]+ where+ def = head (allEntryPoints cf)++mkHeaderFile :: CF -> [Cat] -> [Cat] -> [(a, String)] -> String+mkHeaderFile cf cats eps env = unlines+ [+ "#ifndef PARSER_HEADER_FILE",+ "#define PARSER_HEADER_FILE",+ "",+ "#include \"Absyn.h\"",+ "",+ "typedef union",+ "{",+ " int int_;",+ " char char_;",+ " double double_;",+ " char* string_;",+ (concatMap mkVar cats) ++ "} YYSTYPE;",+ "",+ "#define _ERROR_ 258",+ mkDefines (259::Int) env,+ "extern YYSTYPE yylval;",+ concatMap mkFunc eps,+ "",+ "#endif"+ ]+ where+ mkVar s | (normCat s == s) = " " ++ (identCat s) +++ (map toLower (identCat s)) ++ "_;\n"+ mkVar _ = ""+ mkDefines n [] = mkString n+ mkDefines n ((_,s):ss) = ("#define " ++ s +++ (show n) ++ "\n") ++ (mkDefines (n+1) ss)+ mkString n = if isUsedCat cf "String" + then ("#define _STRING_ " ++ show n ++ "\n") ++ mkChar (n+1)+ else mkChar n+ mkChar n = if isUsedCat cf "Char" + then ("#define _CHAR_ " ++ show n ++ "\n") ++ mkInteger (n+1)+ else mkInteger n+ mkInteger n = if isUsedCat cf "Integer" + then ("#define _INTEGER_ " ++ show n ++ "\n") ++ mkDouble (n+1)+ else mkDouble n+ mkDouble n = if isUsedCat cf "Double" + then ("#define _DOUBLE_ " ++ show n ++ "\n") ++ mkIdent(n+1)+ else mkIdent n+ mkIdent n = if isUsedCat cf "Ident" + then ("#define _IDENT_ " ++ show n ++ "\n")+ else ""+ mkFunc s | (normCat s == s) = (identCat s) ++ " p" ++ (identCat s) ++ "(FILE *inp);\n"+ mkFunc _ = ""+
@@ -61,9 +61,9 @@ module CFtoBison (cf2Bison) where import CF-import List (intersperse, isPrefixOf)+import Data.List (intersperse, isPrefixOf) import NamedVariables hiding (varName)-import Char (toLower,isUpper)+import Data.Char (toLower,isUpper) import Utils ((+++), (++++)) import TypeChecker import ErrM
@@ -43,8 +43,8 @@ import CF import Utils((+++),(++++)) import NamedVariables-import List-import Char(toLower)+import Data.List+import Data.Char(toLower) --The result is two files (.H file, .C file)
@@ -25,8 +25,8 @@ import CF import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper)+import Data.List+import Data.Char(toLower, toUpper) --Produces (.H file, .C file) cf2CPPPrinter :: CF -> (String, String)
@@ -42,8 +42,8 @@ import CF import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper)+import Data.List+import Data.Char(toLower, toUpper) --Produces (.H file, .C file) cf2CVisitSkel :: CF -> (String, String)
@@ -41,7 +41,7 @@ import RegToFlex import Utils((+++), (++++)) import NamedVariables-import List+import Data.List import STLUtils --The environment must be returned for the parser to use.
@@ -27,15 +27,16 @@ import CFtoCVisitSkel import CFtoCPPPrinter import CFtoLatex-import System+import System.IO import GetCF-import Char-import System+import Data.Char+import System.IO+import System.Exit makeCPP :: Bool -> String -> FilePath -> IO () makeCPP make name file = do (cf, isOK) <- tryReadCF file- if isOK then do + if isOK then do let (hfile, cfile) = cf2CPPAbs name cf writeFileRep "Absyn.H" hfile writeFileRep "Absyn.C" cfile@@ -62,7 +63,7 @@ exitFailure makefile :: String -> String-makefile name = unlines +makefile name = unlines [ "CC = g++", "CCFLAGS = -g",@@ -112,7 +113,7 @@ "\t${DVIPS} " ++ name ++ ".dvi -o " ++ name ++ ".ps", "" ]- + cpptest :: CF -> String cpptest cf = unlines@@ -189,19 +190,19 @@ mkVar _ = "" mkDefines n [] = mkString n mkDefines n ((_,s):ss) = ("#define " ++ s +++ (show n) ++ "\n") ++ (mkDefines (n+1) ss)- mkString n = if isUsedCat cf "String" + mkString n = if isUsedCat cf "String" then ("#define _STRING_ " ++ show n ++ "\n") ++ mkChar (n+1) else mkChar n- mkChar n = if isUsedCat cf "Char" + mkChar n = if isUsedCat cf "Char" then ("#define _CHAR_ " ++ show n ++ "\n") ++ mkInteger (n+1) else mkInteger n- mkInteger n = if isUsedCat cf "Integer" + mkInteger n = if isUsedCat cf "Integer" then ("#define _INTEGER_ " ++ show n ++ "\n") ++ mkDouble (n+1) else mkDouble n- mkDouble n = if isUsedCat cf "Double" + mkDouble n = if isUsedCat cf "Double" then ("#define _DOUBLE_ " ++ show n ++ "\n") ++ mkIdent(n+1) else mkIdent n- mkIdent n = if isUsedCat cf "Ident" + mkIdent n = if isUsedCat cf "Ident" then ("#define _IDENT_ " ++ show n ++ "\n") else "" mkFunc s | (normCat s == s) = (identCat s) ++ "*" +++ "p" ++ (identCat s) ++ "(FILE *inp);\n"
@@ -0,0 +1,208 @@+{-+ BNF Converter: C++ Main file+ Copyright (C) 2004 Author: Markus Forsberg, Michael Pellauer++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++module CPPTop (makeCPP) where++import Utils+import CF+import CFtoCPPAbs+import CFtoFlex+import CFtoBison+import CFtoCVisitSkel+import CFtoCPPPrinter+import CFtoLatex+import System.IO+import GetCF+import Data.Char+import System.IO++makeCPP :: Bool -> String -> FilePath -> IO ()+makeCPP make name file = do+ (cf, isOK) <- tryReadCF file+ if isOK then do + let (hfile, cfile) = cf2CPPAbs name cf+ writeFileRep "Absyn.H" hfile+ writeFileRep "Absyn.C" cfile+ let (flex, env) = cf2flex Nothing name cf+ writeFileRep (name ++ ".l") flex+ putStrLn " (Tested with flex 2.5.31)"+ let bison = cf2Bison name cf env+ writeFileRep (name ++ ".y") bison+ putStrLn " (Tested with bison 1.875a)"+ let header = mkHeaderFile cf (allCats cf) (allEntryPoints cf) env+ writeFileRep "Parser.H" header+ let (skelH, skelC) = cf2CVisitSkel cf+ writeFileRep "Skeleton.H" skelH+ writeFileRep "Skeleton.C" skelC+ let (prinH, prinC) = cf2CPPPrinter cf+ writeFileRep "Printer.H" prinH+ writeFileRep "Printer.C" prinC+ writeFileRep "Test.C" (cpptest cf)+ let latex = cfToLatex name cf+ writeFileRep (name ++ ".tex") latex+ if make then (writeFileRep "Makefile" $ makefile name) else return ()+ putStrLn "Done!"+ else do putStrLn $ "Failed"+ exitFailure++makefile :: String -> String+makefile name = unlines + [+ "CC = g++",+ "CCFLAGS = -g",+ "FLEX = flex",+ "BISON = bison",+ "LATEX = latex",+ "DVIPS = dvips",+ "",+ "all: test" ++ name ++ " " ++ name ++ ".ps",+ "",+ "clean:",+ -- peteg: don't nuke what we generated - move that to the "vclean" target.+ "\trm -f *.o " ++ name ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps test" ++ name,+ "",+ "distclean:",+ "\t rm -f *.o Absyn.C Absyn.H Test.C Parser.C Parser.H Lexer.C Skeleton.C Skeleton.H Printer.C Printer.H " ++ name ++ ".l " ++ name ++ ".y " ++ name ++ ".tex " ++ name ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps test" ++ name ++ " Makefile",+ "",+ "test" ++ name ++ ": Absyn.o Lexer.o Parser.o Printer.o Test.o",+ "\t@echo \"Linking test" ++ name ++ "...\"",+ "\t${CC} ${CCFLAGS} *.o -o test" ++ name ++ "",+ " ",+ "Absyn.o: Absyn.C Absyn.H",+ "\t${CC} ${CCFLAGS} -c Absyn.C",+ "",+ "Lexer.C: " ++ name ++ ".l",+ "\t${FLEX} -oLexer.C " ++ name ++ ".l",+ "",+ "Parser.C: " ++ name ++ ".y",+ "\t${BISON} " ++ name ++ ".y -o Parser.C",+ "",+ "Lexer.o: Lexer.C Parser.H",+ "\t${CC} ${CCFLAGS} -c Lexer.C ",+ "",+ "Parser.o: Parser.C Absyn.H",+ "\t${CC} ${CCFLAGS} -c Parser.C",+ "",+ "Printer.o: Printer.C Printer.H Absyn.H",+ "\t${CC} ${CCFLAGS} -c Printer.C",+ "",+ "Test.o: Test.C Parser.H Printer.H Absyn.H",+ "\t${CC} ${CCFLAGS} -c Test.C",+ "",+ "" ++ name ++ ".dvi: " ++ name ++ ".tex",+ "\t${LATEX} " ++ name ++ ".tex",+ "",+ "" ++ name ++ ".ps: " ++ name ++ ".dvi",+ "\t${DVIPS} " ++ name ++ ".dvi -o " ++ name ++ ".ps",+ ""+ ]+ +cpptest :: CF -> String+cpptest cf =+ unlines+ [+ "/*** Compiler Front-End Test automatically generated by the BNF Converter ***/",+ "/* */",+ "/* This test will parse a file, print the abstract syntax tree, and then */",+ "/* pretty-print the result. */",+ "/* */",+ "/****************************************************************************/",+ "#include <stdio.h>",+ "#include \"Parser.H\"",+ "#include \"Printer.H\"",+ "#include \"Absyn.H\"",+ "",+ "int main(int argc, char ** argv)",+ "{",+ " FILE *input;",+ " if (argc > 1) ",+ " {",+ " input = fopen(argv[1], \"r\");",+ " if (!input)",+ " {",+ " fprintf(stderr, \"Error opening input file.\\n\");",+ " exit(1);",+ " }",+ " }",+ " else input = stdin;",+ " /* The default entry point is used. For other options see Parser.H */",+ " " ++ def ++ " *parse_tree = p" ++ def ++ "(input);",+ " if (parse_tree)",+ " {",+ " printf(\"\\nParse Succesful!\\n\");",+ " printf(\"\\n[Abstract Syntax]\\n\");",+ " ShowAbsyn *s = new ShowAbsyn();",+ " printf(\"%s\\n\\n\", s->show(parse_tree));",+ " printf(\"[Linearized Tree]\\n\");",+ " PrintAbsyn *p = new PrintAbsyn();",+ " printf(\"%s\\n\\n\", p->print(parse_tree));",+ " return 0;",+ " }",+ " return 1;",+ "}",+ ""+ ]+ where+ def = head (allEntryPoints cf)++mkHeaderFile cf cats eps env = unlines+ [+ "#ifndef PARSER_HEADER_FILE",+ "#define PARSER_HEADER_FILE",+ "",+ concatMap mkForwardDec cats,+ "typedef union",+ "{",+ " int int_;",+ " char char_;",+ " double double_;",+ " char* string_;",+ (concatMap mkVar cats) ++ "} YYSTYPE;",+ "",+ "#define _ERROR_ 258",+ mkDefines (259 :: Int) env,+ "extern YYSTYPE yylval;",+ concatMap mkFunc eps,+ "",+ "#endif"+ ]+ where+ mkForwardDec s | (normCat s == s) = "class " ++ (identCat s) ++ ";\n"+ mkForwardDec _ = ""+ mkVar s | (normCat s == s) = " " ++ (identCat s) ++"*" +++ (map toLower (identCat s)) ++ "_;\n"+ mkVar _ = ""+ mkDefines n [] = mkString n+ mkDefines n ((_,s):ss) = ("#define " ++ s +++ (show n) ++ "\n") ++ (mkDefines (n+1) ss)+ mkString n = if isUsedCat cf "String" + then ("#define _STRING_ " ++ show n ++ "\n") ++ mkChar (n+1)+ else mkChar n+ mkChar n = if isUsedCat cf "Char" + then ("#define _CHAR_ " ++ show n ++ "\n") ++ mkInteger (n+1)+ else mkInteger n+ mkInteger n = if isUsedCat cf "Integer" + then ("#define _INTEGER_ " ++ show n ++ "\n") ++ mkDouble (n+1)+ else mkDouble n+ mkDouble n = if isUsedCat cf "Double" + then ("#define _DOUBLE_ " ++ show n ++ "\n") ++ mkIdent(n+1)+ else mkIdent n+ mkIdent n = if isUsedCat cf "Ident" + then ("#define _IDENT_ " ++ show n ++ "\n")+ else ""+ mkFunc s | (normCat s == s) = (identCat s) ++ "*" +++ "p" ++ (identCat s) ++ "(FILE *inp);\n"+ mkFunc _ = ""
@@ -3,7 +3,7 @@ -- modified from pretty-printer generated by the BNF converter import AbsBNF-import Char+import Data.Char -- the top-level printing method printRegFlex :: Reg -> String
@@ -45,9 +45,9 @@ module CFtoBisonSTL (cf2Bison) where import CF-import List (intersperse, isPrefixOf)+import Data.List (intersperse, isPrefixOf) import NamedVariables hiding (varName)-import Char (toLower,isUpper,isDigit)+import Data.Char (toLower,isUpper,isDigit) import Utils ((+++), (++++)) import TypeChecker import ErrM
@@ -42,8 +42,8 @@ import CF import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper)+import Data.List+import Data.Char(toLower, toUpper) import OOAbstract import STLUtils
@@ -44,8 +44,8 @@ import CF import Utils((+++),(++++)) import NamedVariables-import List-import Char(toLower)+import Data.List+import Data.Char(toLower) import STLUtils --The result is two files (.H file, .C file)
@@ -25,8 +25,8 @@ import CF import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper)+import Data.List+import Data.Char(toLower, toUpper) import STLUtils --Produces (.H file, .C file)
@@ -29,16 +29,17 @@ import CFtoCVisitSkelSTL import CFtoSTLPrinter import CFtoLatex-import System+import System.IO import GetCF-import Char-import System+import Data.Char+import System.IO+import System.Exit import STLUtils makeSTL :: Bool -> Bool -> Maybe String -> String -> FilePath -> IO () makeSTL make linenumbers inPackage name file = do (cf, isOK) <- tryReadCF file- if isOK then do + if isOK then do let (hfile, cfile) = cf2CPPAbs linenumbers inPackage name cf writeFileRep "Absyn.H" hfile writeFileRep "Absyn.C" cfile@@ -65,7 +66,7 @@ exitFailure makefile :: String -> String-makefile name = unlines +makefile name = unlines [ "CC = g++", "CCFLAGS = -g",@@ -118,7 +119,7 @@ "\t${DVIPS} " ++ name ++ ".dvi -o " ++ name ++ ".ps", "" ]- + cpptest :: Maybe String -> CF -> String cpptest inPackage cf = unlines@@ -203,19 +204,19 @@ mkVar _ = "" mkDefines n [] = mkString n mkDefines n ((_,s):ss) = ("#define " ++ s +++ (show n) ++ "\n") ++ (mkDefines (n+1) ss) -- "nsDefine inPackage s" not needed (see cf2flex::makeSymEnv)- mkString n = if isUsedCat cf "String" + mkString n = if isUsedCat cf "String" then ("#define " ++ nsDefine inPackage "_STRING_ " ++ show n ++ "\n") ++ mkChar (n+1) else mkChar n- mkChar n = if isUsedCat cf "Char" + mkChar n = if isUsedCat cf "Char" then ("#define " ++ nsDefine inPackage "_CHAR_ " ++ show n ++ "\n") ++ mkInteger (n+1) else mkInteger n- mkInteger n = if isUsedCat cf "Integer" + mkInteger n = if isUsedCat cf "Integer" then ("#define " ++ nsDefine inPackage "_INTEGER_ " ++ show n ++ "\n") ++ mkDouble (n+1) else mkDouble n- mkDouble n = if isUsedCat cf "Double" + mkDouble n = if isUsedCat cf "Double" then ("#define " ++ nsDefine inPackage "_DOUBLE_ " ++ show n ++ "\n") ++ mkIdent(n+1) else mkIdent n- mkIdent n = if isUsedCat cf "Ident" + mkIdent n = if isUsedCat cf "Ident" then ("#define " ++ nsDefine inPackage "_IDENT_ " ++ show n ++ "\n") else "" mkFuncs s | (normCat s == s) = (identCat s) ++ "*" +++ "p" ++ (identCat s) ++ "(FILE *inp);\n" ++
@@ -0,0 +1,223 @@+{-+ BNF Converter: C++ Main file+ Copyright (C) 2004 Author: Markus Forsberg, Michael Pellauer++ Modified from CPPTop to STLTop 2006 by Aarne Ranta.++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++module STLTop (makeSTL) where++import Utils+import CF+import CFtoSTLAbs+import CFtoFlex+import CFtoBisonSTL+import CFtoCVisitSkelSTL+import CFtoSTLPrinter+import CFtoLatex+import System.IO+import GetCF+import Data.Char+import System.IO+import STLUtils++makeSTL :: Bool -> Bool -> Maybe String -> String -> FilePath -> IO ()+makeSTL make linenumbers inPackage name file = do+ (cf, isOK) <- tryReadCF file+ if isOK then do + let (hfile, cfile) = cf2CPPAbs linenumbers inPackage name cf+ writeFileRep "Absyn.H" hfile+ writeFileRep "Absyn.C" cfile+ let (flex, env) = cf2flex inPackage name cf+ writeFileRep (name ++ ".l") flex+ putStrLn " (Tested with flex 2.5.31)"+ let bison = cf2Bison linenumbers inPackage name cf env+ writeFileRep (name ++ ".y") bison+ putStrLn " (Tested with bison 1.875a)"+ let header = mkHeaderFile inPackage cf (allCats cf) (allEntryPoints cf) env+ writeFileRep "Parser.H" header+ let (skelH, skelC) = cf2CVisitSkel inPackage cf+ writeFileRep "Skeleton.H" skelH+ writeFileRep "Skeleton.C" skelC+ let (prinH, prinC) = cf2CPPPrinter inPackage cf+ writeFileRep "Printer.H" prinH+ writeFileRep "Printer.C" prinC+ writeFileRep "Test.C" (cpptest inPackage cf)+ let latex = cfToLatex name cf+ writeFileRep (name ++ ".tex") latex+ if make then (writeFileRep "Makefile" $ makefile name) else return ()+ putStrLn "Done!"+ else do putStrLn $ "Failed"+ exitFailure++makefile :: String -> String+makefile name = unlines + [+ "CC = g++",+ "CCFLAGS = -g",+ "FLEX = flex",+ "BISON = bison",+ "LATEX = latex",+ "DVIPS = dvips",+ "",+ "all: test" ++ name ++ " " ++ name ++ ".ps",+ "",+ "clean:",+ -- peteg: don't nuke what we generated - move that to the "vclean" target.+ "\trm -f *.o " ++ name ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps test" ++ name,+ "",+ "distclean:",+ "\t rm -f *.o Absyn.C Absyn.H Test.C Parser.C Parser.H Lexer.C Skeleton.C Skeleton.H Printer.C Printer.H " ++ name ++ ".l " ++ name ++ ".y " ++ name ++ ".tex " ++ name ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps test" ++ name ++ " Makefile",+ "",+ "test" ++ name ++ ": Absyn.o Lexer.o Parser.o Printer.o Test.o",+ "\t@echo \"Linking test" ++ name ++ "...\"",+ "\t${CC} ${CCFLAGS} *.o -o test" ++ name ++ "",+ " ",+ "Absyn.o: Absyn.C Absyn.H",+ "\t${CC} ${CCFLAGS} -c Absyn.C",+ "",+ "Lexer.C: " ++ name ++ ".l",+ "\t${FLEX} -oLexer.C " ++ name ++ ".l",+ "",+ "Parser.C: " ++ name ++ ".y",+ "\t${BISON} " ++ name ++ ".y -o Parser.C",+ "",+ "Lexer.o: Lexer.C Parser.H",+ "\t${CC} ${CCFLAGS} -c Lexer.C ",+ "",+ "Parser.o: Parser.C Absyn.H",+ "\t${CC} ${CCFLAGS} -c Parser.C",+ "",+ "Printer.o: Printer.C Printer.H Absyn.H",+ "\t${CC} ${CCFLAGS} -c Printer.C",+ "",+ "Skeleton.o: Skeleton.C Skeleton.H Absyn.H",+ "\t${CC} ${CCFLAGS} -c Skeleton.C",+ "",+ "Test.o: Test.C Parser.H Printer.H Absyn.H",+ "\t${CC} ${CCFLAGS} -c Test.C",+ "",+ "" ++ name ++ ".dvi: " ++ name ++ ".tex",+ "\t${LATEX} " ++ name ++ ".tex",+ "",+ "" ++ name ++ ".ps: " ++ name ++ ".dvi",+ "\t${DVIPS} " ++ name ++ ".dvi -o " ++ name ++ ".ps",+ ""+ ]+ +cpptest :: Maybe String -> CF -> String+cpptest inPackage cf =+ unlines+ [+ "/*** Compiler Front-End Test automatically generated by the BNF Converter ***/",+ "/* */",+ "/* This test will parse a file, print the abstract syntax tree, and then */",+ "/* pretty-print the result. */",+ "/* */",+ "/****************************************************************************/",+ "#include <stdio.h>",+ "#include \"Parser.H\"",+ "#include \"Printer.H\"",+ "#include \"Absyn.H\"",+ "",+ "int main(int argc, char ** argv)",+ "{",+ " FILE *input;",+ " if (argc > 1) ",+ " {",+ " input = fopen(argv[1], \"r\");",+ " if (!input)",+ " {",+ " fprintf(stderr, \"Error opening input file.\\n\");",+ " exit(1);",+ " }",+ " }",+ " else input = stdin;",+ " /* The default entry point is used. For other options see Parser.H */",+ " " ++ scope ++ def ++ " *parse_tree = " ++ scope ++ "p" ++ def ++ "(input);",+ " if (parse_tree)",+ " {",+ " printf(\"\\nParse Succesful!\\n\");",+ " printf(\"\\n[Abstract Syntax]\\n\");",+ " " ++ scope ++ "ShowAbsyn *s = new " ++ scope ++ "ShowAbsyn();",+ " printf(\"%s\\n\\n\", s->show(parse_tree));",+ " printf(\"[Linearized Tree]\\n\");",+ " " ++ scope ++ "PrintAbsyn *p = new " ++ scope ++ "PrintAbsyn();",+ " printf(\"%s\\n\\n\", p->print(parse_tree));",+ " return 0;",+ " }",+ " return 1;",+ "}",+ ""+ ]+ where+ def = head (allEntryPoints cf)+ scope = nsScope inPackage++mkHeaderFile inPackage cf cats eps env = unlines+ [+ "#ifndef " ++ hdef,+ "#define " ++ hdef,+ "",+ "#include<vector>",+ "#include<string>",+ "",+ nsStart inPackage,+ concatMap mkForwardDec cats,+ "typedef union",+ "{",+ " int int_;",+ " char char_;",+ " double double_;",+ " char* string_;",+ (concatMap mkVar cats) ++ "} YYSTYPE;",+ "",+ concatMap mkFuncs eps,+ nsEnd inPackage,+ "",+ "#define " ++ nsDefine inPackage "_ERROR_" ++ " 258",+ mkDefines (259 :: Int) env,+ "extern " ++ nsScope inPackage ++ "YYSTYPE " ++ nsString inPackage ++ "yylval;",+ "",+ "#endif"+ ]+ where+ hdef = nsDefine inPackage "PARSER_HEADER_FILE"+ mkForwardDec s | (normCat s == s) = "class " ++ (identCat s) ++ ";\n"+ mkForwardDec _ = ""+ mkVar s | (normCat s == s) = " " ++ (identCat s) ++"*" +++ (map toLower (identCat s)) ++ "_;\n"+ mkVar _ = ""+ mkDefines n [] = mkString n+ mkDefines n ((_,s):ss) = ("#define " ++ s +++ (show n) ++ "\n") ++ (mkDefines (n+1) ss) -- "nsDefine inPackage s" not needed (see cf2flex::makeSymEnv)+ mkString n = if isUsedCat cf "String" + then ("#define " ++ nsDefine inPackage "_STRING_ " ++ show n ++ "\n") ++ mkChar (n+1)+ else mkChar n+ mkChar n = if isUsedCat cf "Char" + then ("#define " ++ nsDefine inPackage "_CHAR_ " ++ show n ++ "\n") ++ mkInteger (n+1)+ else mkInteger n+ mkInteger n = if isUsedCat cf "Integer" + then ("#define " ++ nsDefine inPackage "_INTEGER_ " ++ show n ++ "\n") ++ mkDouble (n+1)+ else mkDouble n+ mkDouble n = if isUsedCat cf "Double" + then ("#define " ++ nsDefine inPackage "_DOUBLE_ " ++ show n ++ "\n") ++ mkIdent(n+1)+ else mkIdent n+ mkIdent n = if isUsedCat cf "Ident" + then ("#define " ++ nsDefine inPackage "_IDENT_ " ++ show n ++ "\n")+ else ""+ mkFuncs s | (normCat s == s) = (identCat s) ++ "*" +++ "p" ++ (identCat s) ++ "(FILE *inp);\n" +++ (identCat s) ++ "*" +++ "p" ++ (identCat s) ++ "(const char *str);\n"+ mkFuncs _ = ""
@@ -19,7 +19,7 @@ module STLUtils where -import Char+import Data.Char nsDefine :: Maybe String -> String -> String nsDefine inPackage h = maybe h (\ns -> map toUpper ns ++ "_" ++ h) inPackage
@@ -21,7 +21,7 @@ -- based on BNFC O'Caml backend -module FSharpTop (makeFSharp) where +module FSharpTop (makeFSharp) where import CF import CFtoOCamlYacc@@ -36,10 +36,11 @@ import GetCF import Utils -import Char+import Data.Char import Data.Maybe (fromMaybe,maybe)-import System-import Monad(when)+import System.IO+import System.Exit+import Control.Monad(when) -- naming conventions @@ -50,12 +51,12 @@ withLang opts name = name ++ lang opts mkMod :: (Options -> String -> String) -> String -> Options -> String-mkMod addLang name opts = +mkMod addLang name opts = pref ++ if inDir opts then lang opts ++ "." ++ name else addLang opts name where pref = maybe "" (++".") (inPackage opts) mkFile :: (Options -> String -> String) -> String -> String -> Options -> FilePath-mkFile addLang name ext opts = +mkFile addLang name ext opts = pref ++ if inDir opts then lang opts ++ [pathSep] ++ name ++ ext' else addLang opts name ++ if null ext then "" else ext'@@ -65,11 +66,11 @@ absFile, absFileM, ocamllexFile, ocamllexFileM, dviFile, ocamlyaccFile, ocamlyaccFileM, latexFile, utilFile, utilFileM,- templateFile, templateFileM, + templateFile, templateFileM, printerFile, printerFileM, psFile, tFile, tFileM :: Options -> String absFile = mkFile withLang "Abs" "ml"-absFileM = mkMod withLang "Abs" +absFileM = mkMod withLang "Abs" ocamllexFile = mkFile withLang "Lex" "mll" ocamllexFileM = mkMod withLang "Lex" ocamlyaccFile = mkFile withLang "Par" "mly"@@ -89,8 +90,8 @@ utilFileM = mkMod noLang "BNFC_Util" xmlFileM = mkMod withLang "XML" -data Options = Options - { +data Options = Options+ { make :: Bool, alex1 :: Bool, inDir :: Bool,@@ -101,7 +102,7 @@ } -- FIXME: we probably don't need all these arguments-makeFSharp :: Bool -> Bool -> Bool -> Bool -> Bool -> Int +makeFSharp :: Bool -> Bool -> Bool -> Bool -> Bool -> Int -> Maybe String -- ^ The hierarchical package to put the modules -- in, or Nothing. -> String -> FilePath -> IO ()@@ -124,14 +125,14 @@ prepareDir dir writeFileRep (absFile opts) $ cf2Abstract absMod cf writeFileRep (ocamllexFile opts) $ cf2ocamllex lexMod parMod cf- writeFileRep (ocamlyaccFile opts) $ + writeFileRep (ocamlyaccFile opts) $ cf2ocamlyacc parMod absMod lexMod cf writeFileRep (latexFile opts) $ cfToLatex (lang opts) cf writeFileRep (templateFile opts) $ cf2Template (templateFileM opts) absMod cf writeFileRep (printerFile opts) $ cf2Printer prMod absMod cf writeFileRep (showFile opts) $ cf2show showMod absMod cf writeFileRep (tFile opts) $ ocamlTestfile absMod lexMod parMod prMod showMod cf- writeFileRep (utilFile opts) $ utilM + writeFileRep (utilFile opts) $ utilM when (make opts) $ writeFileRep "Makefile" $ makefile opts case xml opts of 2 -> makeXML (lang opts) True cf@@ -148,19 +149,19 @@ codeDir opts = let pref = maybe "" pkgToDir (inPackage opts) dir = if inDir opts then lang opts else "" sep = if null pref || null dir then "" else [pathSep]- in pref ++ sep ++ dir + in pref ++ sep ++ dir makefile :: Options -> String makefile opts = makeA where dir = let d = codeDir opts in if null d then "" else d ++ [pathSep] cd c = if null dir then c else "(cd " ++ dir ++ "; " ++ c ++ ")"- makeA = unlines + makeA = unlines [ "all:",- "\tfsyacc " ++ ocamlyaccFile opts, + "\tfsyacc " ++ ocamlyaccFile opts, "\tfslex " ++ ocamllexFile opts, "\t" ++ cd ("latex " ++ basename (latexFile opts)- ++ "; " ++ "dvips " ++ basename (dviFile opts) + ++ "; " ++ "dvips " ++ basename (dviFile opts) ++ " -o " ++ basename (psFile opts)), "\tfsc -o " ++ mkFile withLang "Test" "exe" opts +++ utilFile opts +++@@ -169,11 +170,11 @@ mkFile withLang "Par" "mli" opts +++ mkFile withLang "Par" "ml" opts +++ mkFile withLang "Lex" "fs" opts +++- tFile opts, + tFile opts, "", "clean:", "\t-rm -f " ++ unwords (map (dir++) [- "*.log", "*.aux", "*.cmi", + "*.log", "*.aux", "*.cmi", "*.cmo", "*.o", "*.dvi" ]), "\t-rm -f " ++ psFile opts,@@ -197,7 +198,7 @@ utilM :: String-utilM = unlines +utilM = unlines ["(* automatically generated by BNFC *)", "", "open Lexing",
@@ -0,0 +1,208 @@+{-+ BNF Converter: F# main file+ Copyright (C) 2005 Author: Kristofer Johannisson+ Copyright (C) 2007 Author: Bjorn Bringert++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++-- based on BNFC O'Caml backend+++module FSharpTop (makeFSharp) where++import CF+import CFtoOCamlYacc+import CFtoOCamlLex+import CFtoLatex+import CFtoOCamlAbs+import CFtoOCamlTemplate+import CFtoOCamlPrinter+import CFtoOCamlShow+import CFtoOCamlTest+import CFtoXML+import GetCF+import Utils++import Data.Char+import Data.Maybe (fromMaybe,maybe)+import System.IO+import Control.Monad(when)++-- naming conventions++noLang :: Options -> String -> String+noLang _ name = name++withLang :: Options -> String -> String+withLang opts name = name ++ lang opts++mkMod :: (Options -> String -> String) -> String -> Options -> String+mkMod addLang name opts =+ pref ++ if inDir opts then lang opts ++ "." ++ name else addLang opts name+ where pref = maybe "" (++".") (inPackage opts)++mkFile :: (Options -> String -> String) -> String -> String -> Options -> FilePath+mkFile addLang name ext opts =+ pref ++ if inDir opts+ then lang opts ++ [pathSep] ++ name ++ ext'+ else addLang opts name ++ if null ext then "" else ext'+ where pref = maybe "" (\p->pkgToDir p++[pathSep]) (inPackage opts)+ ext' = if null ext then "" else "." ++ ext++absFile, absFileM, ocamllexFile, ocamllexFileM, dviFile,+ ocamlyaccFile, ocamlyaccFileM,+ latexFile, utilFile, utilFileM,+ templateFile, templateFileM,+ printerFile, printerFileM,+ psFile, tFile, tFileM :: Options -> String+absFile = mkFile withLang "Abs" "ml"+absFileM = mkMod withLang "Abs"+ocamllexFile = mkFile withLang "Lex" "mll"+ocamllexFileM = mkMod withLang "Lex"+ocamlyaccFile = mkFile withLang "Par" "mly"+ocamlyaccFileM = mkMod withLang "Par"+latexFile = mkFile withLang "Doc" "tex"+templateFile = mkFile withLang "Skel" "ml"+templateFileM = mkMod withLang "Skel"+printerFile = mkFile withLang "Print" "ml"+printerFileM = mkMod withLang "Print"+showFile = mkFile withLang "Show" "ml"+showFileM = mkMod withLang "Show"+dviFile = mkFile withLang "Doc" "dvi"+psFile = mkFile withLang "Doc" "ps"+tFile = mkFile withLang "Test" "ml"+tFileM = mkMod withLang "Test"+utilFile = mkFile noLang "BNFC_Util" "ml"+utilFileM = mkMod noLang "BNFC_Util"+xmlFileM = mkMod withLang "XML"++data Options = Options+ {+ make :: Bool,+ alex1 :: Bool,+ inDir :: Bool,+ shareStrings :: Bool,+ xml :: Int,+ inPackage :: Maybe String,+ lang :: String+ }++-- FIXME: we probably don't need all these arguments+makeFSharp :: Bool -> Bool -> Bool -> Bool -> Bool -> Int+ -> Maybe String -- ^ The hierarchical package to put the modules+ -- in, or Nothing.+ -> String -> FilePath -> IO ()+makeFSharp m a1 d ss g x p n file = do+ let opts = Options { make = m, alex1 = a1, inDir = d, shareStrings = ss,+ xml = x, inPackage = p, lang = n }++ absMod = absFileM opts+ lexMod = ocamllexFileM opts+ parMod = ocamlyaccFileM opts+ prMod = printerFileM opts+ showMod = showFileM opts+-- layMod = layoutFileM opts+ utilMod = utilFileM opts+ (cf, isOK) <- tryReadCF file+ if isOK then do+ let dir = codeDir opts+ when (not (null dir)) $ do+ putStrLn $ "Creating directory " ++ dir+ prepareDir dir+ writeFileRep (absFile opts) $ cf2Abstract absMod cf+ writeFileRep (ocamllexFile opts) $ cf2ocamllex lexMod parMod cf+ writeFileRep (ocamlyaccFile opts) $+ cf2ocamlyacc parMod absMod lexMod cf+ writeFileRep (latexFile opts) $ cfToLatex (lang opts) cf+ writeFileRep (templateFile opts) $ cf2Template (templateFileM opts) absMod cf+ writeFileRep (printerFile opts) $ cf2Printer prMod absMod cf+ writeFileRep (showFile opts) $ cf2show showMod absMod cf+ writeFileRep (tFile opts) $ ocamlTestfile absMod lexMod parMod prMod showMod cf+ writeFileRep (utilFile opts) $ utilM+ when (make opts) $ writeFileRep "Makefile" $ makefile opts+ case xml opts of+ 2 -> makeXML (lang opts) True cf+ 1 -> makeXML (lang opts) False cf+ _ -> return ()+ putStrLn $ "Done!"+ else do putStrLn $ "Failed!"+ exitFailure++pkgToDir :: String -> FilePath+pkgToDir s = replace '.' pathSep s++codeDir :: Options -> FilePath+codeDir opts = let pref = maybe "" pkgToDir (inPackage opts)+ dir = if inDir opts then lang opts else ""+ sep = if null pref || null dir then "" else [pathSep]+ in pref ++ sep ++ dir++makefile :: Options -> String+makefile opts = makeA where+ dir = let d = codeDir opts in if null d then "" else d ++ [pathSep]+ cd c = if null dir then c else "(cd " ++ dir ++ "; " ++ c ++ ")"+ makeA = unlines+ [+ "all:",+ "\tfsyacc " ++ ocamlyaccFile opts,+ "\tfslex " ++ ocamllexFile opts,+ "\t" ++ cd ("latex " ++ basename (latexFile opts)+ ++ "; " ++ "dvips " ++ basename (dviFile opts)+ ++ " -o " ++ basename (psFile opts)),+ "\tfsc -o " ++ mkFile withLang "Test" "exe" opts ++++ utilFile opts ++++ absFile opts +++ templateFile opts ++++ showFile opts +++ printerFile opts ++++ mkFile withLang "Par" "mli" opts ++++ mkFile withLang "Par" "ml" opts ++++ mkFile withLang "Lex" "fs" opts ++++ tFile opts,+ "",+ "clean:",+ "\t-rm -f " ++ unwords (map (dir++) [+ "*.log", "*.aux", "*.cmi",+ "*.cmo", "*.o", "*.dvi"+ ]),+ "\t-rm -f " ++ psFile opts,+ "",+ "distclean: clean",+ "\t-rm -f " ++ unwords [+ mkFile withLang "Doc" "*" opts,+ mkFile withLang "Lex" "*" opts,+ mkFile withLang "Par" "*" opts,+ mkFile withLang "Layout" "*" opts,+ mkFile withLang "Skel" "*" opts,+ mkFile withLang "Print" "*" opts,+ mkFile withLang "Show" "*" opts,+ mkFile withLang "Test" "*" opts,+ mkFile withLang "Abs" "*" opts,+ mkFile withLang "Test" "" opts,+ utilFile opts,+ "Makefile*"+ ]+ ]+++utilM :: String+utilM = unlines+ ["(* automatically generated by BNFC *)",+ "",+ "open Lexing",+ "",+ "(* this should really be in the parser, but ocamlyacc won't put it in the .mli *)",+ "exception Parse_error of Lexing.position * Lexing.position"+ ]+
@@ -21,7 +21,7 @@ import CF import Utils((+++),(++++)) -import List(intersperse,nub) +import Data.List(intersperse,nub) import HaskellGADTCommon
@@ -22,8 +22,8 @@ import CF import Utils import CFtoTemplate-import List (intersperse)-import Char(toLower)+import Data.List (intersperse)+import Data.Char(toLower) import HaskellGADTCommon
@@ -24,7 +24,7 @@ import CF import Utils((+++))-import List (delete,groupBy)+import Data.List (delete,groupBy) import HaskellGADTCommon
@@ -21,7 +21,7 @@ import CF -import Char +import Data.Char data Constructor = Constructor { consCat :: Cat,
@@ -1,6 +1,6 @@ {- BNF Converter: Haskell main file - Copyright (C) 2004-2005 Author: Markus Forberg, Peter Gammie, + Copyright (C) 2004-2005 Author: Markus Forberg, Peter Gammie, Aarne Ranta, Björn Bringert This program is free software; you can redistribute it and/or modify @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -} -module HaskellTopGADT (makeAllGADT) where +module HaskellTopGADT (makeAllGADT) where @@ -36,14 +36,15 @@ import MkErrM import MkSharedString -- import CFtoGF ( cf2AbsGF, cf2ConcGF ) --- import System +-- import System.IO import GetCF import Utils -import Char +import Data.Char import Data.Maybe (fromMaybe,maybe) -import System -import Monad(when) +import System.IO +import System.Exit +import Control.Monad(when) -- naming conventions @@ -54,12 +55,12 @@ withLang opts name = name ++ lang opts mkMod :: (Options -> String -> String) -> String -> Options -> String -mkMod addLang name opts = +mkMod addLang name opts = pref ++ if inDir opts then lang opts ++ "." ++ name else addLang opts name where pref = maybe "" (++".") (inPackage opts) mkFile :: (Options -> String -> String) -> String -> String -> Options -> FilePath -mkFile addLang name ext opts = +mkFile addLang name ext opts = pref ++ if inDir opts then lang opts ++ [pathSep] ++ name ++ ext' else addLang opts name ++ if null ext then "" else ext' @@ -71,12 +72,12 @@ gfAbs, gfConc, happyFile, happyFileM, latexFile, errFile, errFileM, - templateFile, templateFileM, + templateFile, templateFileM, printerFile, printerFileM, - layoutFile, layoutFileM, + layoutFile, layoutFileM, psFile, tFile, tFileM :: Options -> String absFile = mkFile withLang "Abs" "hs" -absFileM = mkMod withLang "Abs" +absFileM = mkMod withLang "Abs" alexFile = mkFile withLang "Lex" "x" alexFileM = mkMod withLang "Lex" composOpFile = mkFile noLang "ComposOp" "hs" @@ -102,8 +103,8 @@ xmlFileM = mkMod withLang "XML" layoutFile = mkFile withLang "Layout" "hs" -data Options = Options - { +data Options = Options + { make :: Bool, alex1 :: Bool, inDir :: Bool, @@ -115,13 +116,13 @@ lang :: String } -makeAllGADT :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int +makeAllGADT :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int -> Maybe String -- ^ The hierarchical package to put the modules -- in, or Nothing. -> String -> FilePath -> IO () makeAllGADT m a1 d ss bs g x p n file = do let opts = Options { make = m, alex1 = a1, inDir = d, shareStrings = ss, byteStrings = bs, - glr = if g then GLR else Standard, xml = x, + glr = if g then GLR else Standard, xml = x, inPackage = p, lang = n } absMod = absFileM opts @@ -142,11 +143,11 @@ writeFileRep (composOpFile opts) $ composOp composOpMod if alex1 opts then do writeFileRep (alexFile opts) $ cf2alex lexMod errMod cf - putStrLn " (Use Alex 1.1 to compile.)" + putStrLn " (Use Alex 1.1 to compile.)" else do writeFileRep (alexFile opts) $ cf2alex2 lexMod errMod shareMod (shareStrings opts) (byteStrings opts) cf putStrLn " (Use Alex 2.0 to compile.)" - writeFileRep (happyFile opts) $ + writeFileRep (happyFile opts) $ cf2HappyS parMod absMod lexMod errMod (glr opts) (byteStrings opts) cf putStrLn " (Tested with Happy 1.15)" writeFileRep (latexFile opts) $ cfToLatex (lang opts) cf @@ -172,25 +173,25 @@ codeDir opts = let pref = maybe "" pkgToDir (inPackage opts) dir = if inDir opts then lang opts else "" sep = if null pref || null dir then "" else [pathSep] - in pref ++ sep ++ dir + in pref ++ sep ++ dir makefile :: Options -> String makefile opts = makeA where - glr_params = if glr opts == GLR then "--glr --decode " else "" + glr_params = if glr opts == GLR then "--glr --decode " else "" dir = let d = codeDir opts in if null d then "" else d ++ [pathSep] cd c = if null dir then c else "(cd " ++ dir ++ "; " ++ c ++ ")" - makeA = unlines + makeA = unlines [ - "all:", - "\thappy -gca " ++ glr_params ++ happyFile opts, + "all:", + "\thappy -gca " ++ glr_params ++ happyFile opts, "\talex -g " ++ alexFile opts, "\t" ++ cd ("latex " ++ basename (latexFile opts) - ++ "; " ++ "dvips " ++ basename (dviFile opts) + ++ "; " ++ "dvips " ++ basename (dviFile opts) ++ " -o " ++ basename (psFile opts)), "\tghc --make " ++ tFile opts ++ " -o " ++ mkFile withLang "Test" "" opts, "clean:", "\t-rm -f " ++ unwords (map (dir++) [ - "*.log", "*.aux", "*.hi", + "*.log", "*.aux", "*.hi", "*.o", "*.dvi" ]), "\t-rm -f " ++ psFile opts, @@ -210,7 +211,7 @@ mkFile noLang "ErrM" "*" opts, mkFile noLang "SharedString" "*" opts, dir ++ lang opts ++ ".dtd", - mkFile withLang "XML" "*" opts, + mkFile withLang "XML" "*" opts, "Makefile*" ], if null dir then "" else "\t-rmdir -p " ++ dir @@ -219,7 +220,7 @@ testfile :: Options -> CF -> String testfile opts cf - = let lay = hasLayout cf + = let lay = hasLayout cf use_xml = xml opts > 0 xpr = if use_xml then "XPrint a, " else "" use_glr = glr opts == GLR @@ -231,8 +232,8 @@ ["-- automatically generated by BNF Converter", "module Main where\n", "", - "import IO ( stdin, hGetContents )", - "import System ( getArgs, getProgName )", + "import System.IO ( stdin, hGetContents )", + "import System.IO ( getArgs, getProgName )", "", "import " ++ alexFileM opts, "import " ++ happyFileM opts, @@ -242,14 +243,14 @@ if lay then ("import " ++ layoutFileM opts) else "", if use_xml then ("import " ++ xmlFileM opts) else "", if_glr "import Data.FiniteMap(FiniteMap, lookupFM, fmToList)", - if_glr "import Maybe(fromJust)", + if_glr "import Data.Maybe(fromJust)", "import " ++ errFileM opts, "", if use_glr then "type ParseFun a = [[Token]] -> (GLRResult, GLR_Output (Err a))" else "type ParseFun a = [Token] -> Err a", "", - "myLLexer = " ++ if lay then "resolveLayout True . myLexer" + "myLLexer = " ++ if lay then "resolveLayout True . myLexer" else "myLexer", "", "type Verbosity = Int", @@ -283,7 +284,7 @@ ] run_std xml - = unlines + = unlines [ "run v p s = let ts = myLLexer s in case p ts of" , " Bad s -> do putStrLn \"\\nParse Failed...\\n\"" , " putStrV v \"Tokens:\"" @@ -297,7 +298,7 @@ ] run_glr - = unlines + = unlines [ "run v p s" , " = let ts = map (:[]) $ myLLexer s" , " (raw_output, simple_output) = p ts in" @@ -321,10 +322,10 @@ , " | (Ok t,n) <- zip trees [1..]" , " ]" ] - + lift_parser - = unlines + = unlines [ "type Forest = FiniteMap ForestId [Branch] -- omitted in ParX export." , "data GLR_Output a" , " = GLR_Result { pruned_decode :: (Forest -> Forest) -> [a]"
@@ -0,0 +1,387 @@+{- + BNF Converter: Haskell main file + Copyright (C) 2004-2005 Author: Markus Forberg, Peter Gammie, + Aarne Ranta, Björn Bringert + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-} + +module HaskellTopGADT (makeAllGADT) where + + + +-- import Utils +import CF +import CFtoHappy +import CFtoAlex +import CFtoAlex2 +import CFtoLatex +import CFtoAbstractGADT +import CFtoTemplateGADT +import CFtoPrinterGADT +import CFtoLayout +import CFtoXML +import MkErrM +import MkSharedString +-- import CFtoGF ( cf2AbsGF, cf2ConcGF ) +-- import System.IO +import GetCF +import Utils + +import Data.Char +import Data.Maybe (fromMaybe,maybe) +import System.IO +import Control.Monad(when) + +-- naming conventions + +noLang :: Options -> String -> String +noLang _ name = name + +withLang :: Options -> String -> String +withLang opts name = name ++ lang opts + +mkMod :: (Options -> String -> String) -> String -> Options -> String +mkMod addLang name opts = + pref ++ if inDir opts then lang opts ++ "." ++ name else addLang opts name + where pref = maybe "" (++".") (inPackage opts) + +mkFile :: (Options -> String -> String) -> String -> String -> Options -> FilePath +mkFile addLang name ext opts = + pref ++ if inDir opts + then lang opts ++ [pathSep] ++ name ++ ext' + else addLang opts name ++ if null ext then "" else ext' + where pref = maybe "" (\p->pkgToDir p++[pathSep]) (inPackage opts) + ext' = if null ext then "" else "." ++ ext + +absFile, absFileM, alexFile, alexFileM, dviFile, + composOpFile, composOpFileM, + gfAbs, gfConc, + happyFile, happyFileM, + latexFile, errFile, errFileM, + templateFile, templateFileM, + printerFile, printerFileM, + layoutFile, layoutFileM, + psFile, tFile, tFileM :: Options -> String +absFile = mkFile withLang "Abs" "hs" +absFileM = mkMod withLang "Abs" +alexFile = mkFile withLang "Lex" "x" +alexFileM = mkMod withLang "Lex" +composOpFile = mkFile noLang "ComposOp" "hs" +composOpFileM = mkMod noLang "ComposOp" +happyFile = mkFile withLang "Par" "y" +happyFileM = mkMod withLang "Par" +latexFile = mkFile withLang "Doc" "tex" +templateFile = mkFile withLang "Skel" "hs" +templateFileM = mkMod withLang "Skel" +printerFile = mkFile withLang "Print" "hs" +printerFileM = mkMod withLang "Print" +dviFile = mkFile withLang "Doc" "dvi" +psFile = mkFile withLang "Doc" "ps" +gfAbs = mkFile withLang "" "Abs.gf" +gfConc = mkFile withLang "" "Conc.gf" +tFile = mkFile withLang "Test" "hs" +tFileM = mkMod withLang "Test" +errFile = mkFile noLang "ErrM" "hs" +errFileM = mkMod noLang "ErrM" +shareFile = mkFile noLang "SharedString" "hs" +shareFileM = mkMod noLang "SharedString" +layoutFileM = mkMod withLang "Layout" +xmlFileM = mkMod withLang "XML" +layoutFile = mkFile withLang "Layout" "hs" + +data Options = Options + { + make :: Bool, + alex1 :: Bool, + inDir :: Bool, + shareStrings :: Bool, + byteStrings :: Bool, + glr :: HappyMode, + xml :: Int, + inPackage :: Maybe String, + lang :: String + } + +makeAllGADT :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int + -> Maybe String -- ^ The hierarchical package to put the modules + -- in, or Nothing. + -> String -> FilePath -> IO () +makeAllGADT m a1 d ss bs g x p n file = do + let opts = Options { make = m, alex1 = a1, inDir = d, shareStrings = ss, byteStrings = bs, + glr = if g then GLR else Standard, xml = x, + inPackage = p, lang = n } + + absMod = absFileM opts + composOpMod = composOpFileM opts + lexMod = alexFileM opts + parMod = happyFileM opts + prMod = printerFileM opts + layMod = layoutFileM opts + errMod = errFileM opts + shareMod = shareFileM opts + (cf, isOK) <- tryReadCF file + if isOK then do + let dir = codeDir opts + when (not (null dir)) $ do + putStrLn $ "Creating directory " ++ dir + prepareDir dir + writeFileRep (absFile opts) $ cf2Abstract (byteStrings opts) absMod cf composOpMod + writeFileRep (composOpFile opts) $ composOp composOpMod + if alex1 opts then do + writeFileRep (alexFile opts) $ cf2alex lexMod errMod cf + putStrLn " (Use Alex 1.1 to compile.)" + else do + writeFileRep (alexFile opts) $ cf2alex2 lexMod errMod shareMod (shareStrings opts) (byteStrings opts) cf + putStrLn " (Use Alex 2.0 to compile.)" + writeFileRep (happyFile opts) $ + cf2HappyS parMod absMod lexMod errMod (glr opts) (byteStrings opts) cf + putStrLn " (Tested with Happy 1.15)" + writeFileRep (latexFile opts) $ cfToLatex (lang opts) cf + writeFileRep (templateFile opts) $ cf2Template (templateFileM opts) absMod errMod cf + writeFileRep (printerFile opts) $ cf2Printer prMod absMod cf + when (hasLayout cf) $ writeFileRep (layoutFile opts) $ cf2Layout (alex1 opts) (inDir opts) layMod lexMod cf + writeFileRep (tFile opts) $ testfile opts cf + writeFileRep (errFile opts) $ errM errMod cf + when (shareStrings opts) $ writeFileRep (shareFile opts) $ sharedString shareMod (byteStrings opts) cf + when (make opts) $ writeFileRep "Makefile" $ makefile opts + case xml opts of + 2 -> makeXML (lang opts) True cf + 1 -> makeXML (lang opts) False cf + _ -> return () + putStrLn $ "Done!" + else do putStrLn $ "Failed!" + exitFailure + +pkgToDir :: String -> FilePath +pkgToDir s = replace '.' pathSep s + +codeDir :: Options -> FilePath +codeDir opts = let pref = maybe "" pkgToDir (inPackage opts) + dir = if inDir opts then lang opts else "" + sep = if null pref || null dir then "" else [pathSep] + in pref ++ sep ++ dir + +makefile :: Options -> String +makefile opts = makeA where + glr_params = if glr opts == GLR then "--glr --decode " else "" + dir = let d = codeDir opts in if null d then "" else d ++ [pathSep] + cd c = if null dir then c else "(cd " ++ dir ++ "; " ++ c ++ ")" + makeA = unlines + [ + "all:", + "\thappy -gca " ++ glr_params ++ happyFile opts, + "\talex -g " ++ alexFile opts, + "\t" ++ cd ("latex " ++ basename (latexFile opts) + ++ "; " ++ "dvips " ++ basename (dviFile opts) + ++ " -o " ++ basename (psFile opts)), + "\tghc --make " ++ tFile opts ++ " -o " ++ mkFile withLang "Test" "" opts, + "clean:", + "\t-rm -f " ++ unwords (map (dir++) [ + "*.log", "*.aux", "*.hi", + "*.o", "*.dvi" + ]), + "\t-rm -f " ++ psFile opts, + + "distclean: clean", + "\t-rm -f " ++ unwords [ + mkFile withLang "Doc" "*" opts, + mkFile withLang "Lex" "*" opts, + mkFile withLang "Par" "*" opts, + mkFile withLang "Layout" "*" opts, + mkFile withLang "Skel" "*" opts, + mkFile withLang "Print" "*" opts, + mkFile withLang "Test" "*" opts, + mkFile withLang "Abs" "*" opts, + mkFile withLang "ComposOp" "*" opts, + mkFile withLang "Test" "" opts, + mkFile noLang "ErrM" "*" opts, + mkFile noLang "SharedString" "*" opts, + dir ++ lang opts ++ ".dtd", + mkFile withLang "XML" "*" opts, + "Makefile*" + ], + if null dir then "" else "\t-rmdir -p " ++ dir + ] + + +testfile :: Options -> CF -> String +testfile opts cf + = let lay = hasLayout cf + use_xml = xml opts > 0 + xpr = if use_xml then "XPrint a, " else "" + use_glr = glr opts == GLR + if_glr s = if use_glr then s else "" + firstParser = if use_glr then "the_parser" else parserName + parserName = 'p' : topType + topType = firstEntry cf + in unlines + ["-- automatically generated by BNF Converter", + "module Main where\n", + "", + "import System.IO ( stdin, hGetContents )", + "import System.IO ( getArgs, getProgName )", + "", + "import " ++ alexFileM opts, + "import " ++ happyFileM opts, + "import " ++ templateFileM opts, + "import " ++ printerFileM opts, + "import " ++ absFileM opts, + if lay then ("import " ++ layoutFileM opts) else "", + if use_xml then ("import " ++ xmlFileM opts) else "", + if_glr "import Data.FiniteMap(FiniteMap, lookupFM, fmToList)", + if_glr "import Data.Maybe(fromJust)", + "import " ++ errFileM opts, + "", + if use_glr + then "type ParseFun a = [[Token]] -> (GLRResult, GLR_Output (Err a))" + else "type ParseFun a = [Token] -> Err a", + "", + "myLLexer = " ++ if lay then "resolveLayout True . myLexer" + else "myLexer", + "", + "type Verbosity = Int", + "", + "putStrV :: Verbosity -> String -> IO ()", + "putStrV v s = if v > 1 then putStrLn s else return ()", + "", + "runFile :: (" ++ xpr ++ if_glr "TreeDecode a, " ++ "Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO ()", + "runFile v p f = putStrLn f >> readFile f >>= run v p", + "", + "run :: (" ++ xpr ++ if_glr "TreeDecode a, " ++ "Print a, Show a) => Verbosity -> ParseFun a -> String -> IO ()", + if use_glr then run_glr else run_std use_xml, + "", + "showTree :: (Show a, Print a) => Int -> a -> IO ()", + "showTree v tree", + " = do", + " putStrV v $ \"\\n[Abstract Syntax]\\n\\n\" ++ show tree", + " putStrV v $ \"\\n[Linearized tree]\\n\\n\" ++ printTree tree", + "", + "main :: IO ()", + "main = do args <- getArgs", + " case args of", + " [] -> hGetContents stdin >>= run 2 " ++ firstParser, + " \"-s\":fs -> mapM_ (runFile 0 " ++ firstParser ++ ") fs", + " fs -> mapM_ (runFile 2 " ++ firstParser ++ ") fs", + "", + if_glr $ "the_parser :: ParseFun " ++ topType, + if_glr $ "the_parser = lift_parser " ++ parserName, + if_glr $ "", + if_glr $ lift_parser + ] + +run_std xml + = unlines + [ "run v p s = let ts = myLLexer s in case p ts of" + , " Bad s -> do putStrLn \"\\nParse Failed...\\n\"" + , " putStrV v \"Tokens:\"" + , " putStrV v $ show ts" + , " putStrLn s" + , " Ok tree -> do putStrLn \"\\nParse Successful!\"" + , " showTree v tree" + , if xml then + " putStrV v $ \"\\n[XML]\\n\\n\" ++ printXML tree" + else "" + ] + +run_glr + = unlines + [ "run v p s" + , " = let ts = map (:[]) $ myLLexer s" + , " (raw_output, simple_output) = p ts in" + , " case simple_output of" + , " GLR_Fail major minor -> do" + , " putStrLn major" + , " putStrV v minor" + , " GLR_Result df trees -> do" + , " putStrLn \"\\nParse Successful!\"" + , " case trees of" + , " [] -> error \"No results but parse succeeded?\"" + , " [Ok x] -> showTree v x" + , " xs@(_:_) -> showSeveralTrees v xs" + , " where" + , " showSeveralTrees :: (Print b, Show b) => Int -> [Err b] -> IO ()" + , " showSeveralTrees v trees" + , " = sequence_ " + , " [ do putStrV v (replicate 40 '-')" + , " putStrV v $ \"Parse number: \" ++ show n" + , " showTree v t" + , " | (Ok t,n) <- zip trees [1..]" + , " ]" + ] + + +lift_parser + = unlines + [ "type Forest = FiniteMap ForestId [Branch] -- omitted in ParX export." + , "data GLR_Output a" + , " = GLR_Result { pruned_decode :: (Forest -> Forest) -> [a]" + , " , semantic_result :: [a]" + , " }" + , " | GLR_Fail { main_message :: String" + , " , extra_info :: String" + , " }" + , "" + , "lift_parser" + , " :: (TreeDecode a, Show a, Print a)" + , " => ([[Token]] -> GLRResult) -> ParseFun a" + , "lift_parser parser ts" + , " = let result = parser ts in" + , " (\\o -> (result, o)) $" + , " case result of" + , " ParseError ts f -> GLR_Fail \"Parse failed, unexpected token(s)\\n\"" + , " (\"Tokens: \" ++ show ts)" + , " ParseEOF f -> GLR_Fail \"Parse failed, unexpected EOF\\n\"" + , " (\"Partial forest:\\n\"" + , " ++ unlines (map show $ fmToList f))" + , " ParseOK r f -> let find f = fromJust . lookupFM f" + , " dec_fn f = decode (find f) r" + , " in GLR_Result (\\ff -> dec_fn $ ff f) (dec_fn f)" + ] + +composOp :: String -> String +composOp composOpMod = unlines + [ + "{-# OPTIONS_GHC -fglasgow-exts #-}", + "module " ++ composOpMod ++ " (Compos(..),composOp,composOpM,composOpM_,composOpMonoid,", + " composOpMPlus,composOpFold) where", + "", + "import Control.Monad.Identity", + "import Data.Monoid", + "", + "class Compos t where", + " compos :: (forall a. a -> m a) -> (forall a b. m (a -> b) -> m a -> m b)", + " -> (forall a. t a -> m (t a)) -> t c -> m (t c)", + "", + "composOp :: Compos t => (forall a. t a -> t a) -> t c -> t c", + "composOp f = runIdentity . composOpM (Identity . f)", + "", + "composOpM :: (Compos t, Monad m) => (forall a. t a -> m (t a)) -> t c -> m (t c)", + "composOpM = compos return ap", + "", + "composOpM_ :: (Compos t, Monad m) => (forall a. t a -> m ()) -> t c -> m ()", + "composOpM_ = composOpFold (return ()) (>>)", + "", + "composOpMonoid :: (Compos t, Monoid m) => (forall a. t a -> m) -> t c -> m", + "composOpMonoid = composOpFold mempty mappend", + "", + "composOpMPlus :: (Compos t, MonadPlus m) => (forall a. t a -> m b) -> t c -> m b", + "composOpMPlus = composOpFold mzero mplus", + "", + "composOpFold :: Compos t => b -> (b -> b -> b) -> (forall a. t a -> b) -> t c -> b", + "composOpFold z c f = unC . compos (\\_ -> C z) (\\(C x) (C y) -> C (c x y)) (C . f)", + "", + "newtype C b a = C { unC :: b }" + ]
@@ -21,7 +21,7 @@ import CF import Utils((+++),(++++)) -import List(intersperse) +import Data.List(intersperse) -- to produce a Haskell module cf2Abstract :: Bool -> String -> CF -> String
@@ -22,7 +22,7 @@ import CF import RegToAlex-import List+import Data.List cf2alex :: String -> String -> CF -> String cf2alex name errMod cf = unlines $ concat $ intersperse [""] [
@@ -33,11 +33,11 @@ module CFtoAlex2 (cf2alex2) where import CF-import List+import Data.List -- For RegToAlex, see below. import AbsBNF-import Char+import Data.Char cf2alex2 :: String -> String -> String -> Bool -> Bool -> CF -> String cf2alex2 name errMod shareMod shareStrings byteStrings cf =
@@ -26,8 +26,8 @@ import CF --import Lexer-import List (intersperse, sort)-import Char+import Data.List (intersperse, sort)+import Data.Char -- Type declarations
@@ -22,8 +22,8 @@ import CF import Utils import CFtoTemplate-import List (intersperse)-import Char(toLower)+import Data.List (intersperse)+import Data.Char(toLower) -- derive pretty-printer from a BNF grammar. AR 15/2/2002 cf2Printer :: Bool -> String -> String -> CF -> String
@@ -23,8 +23,8 @@ ) where import CF-import Char-import List (delete)+import Data.Char+import Data.List (delete) type ModuleName = String type Constructor = String
@@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -} -module HaskellTop (makeAll) where +module HaskellTop (makeAll) where @@ -36,14 +36,15 @@ import MkErrM import MkSharedString -- import CFtoGF ( cf2AbsGF, cf2ConcGF ) --- import System +-- import System.IO import GetCF import Utils -import Char +import Data.Char import Data.Maybe (fromMaybe,maybe) -import System -import Monad(when) +import System.IO +import System.Exit +import Control.Monad(when) -- naming conventions @@ -56,17 +57,17 @@ withLangAbs :: Options -> String -> String withLangAbs opts name = postp $ name ++ lang opts where - postp nam = if multi opts + postp nam = if multi opts then takeWhile (/='_') nam else nam mkMod :: (Options -> String -> String) -> String -> Options -> String -mkMod addLang name opts = +mkMod addLang name opts = pref ++ if inDir opts then lang opts ++ "." ++ name else addLang opts name where pref = maybe "" (++".") (inPackage opts) mkFile :: (Options -> String -> String) -> String -> String -> Options -> FilePath -mkFile addLang name ext opts = +mkFile addLang name ext opts = pref ++ if inDir opts then lang opts ++ [pathSep] ++ name ++ ext' else addLang opts name ++ if null ext then "" else ext' @@ -77,12 +78,12 @@ gfAbs, gfConc, happyFile, happyFileM, latexFile, errFile, errFileM, - templateFile, templateFileM, + templateFile, templateFileM, printerFile, printerFileM, - layoutFile, layoutFileM, + layoutFile, layoutFileM, psFile, tFile, tFileM :: Options -> String absFile = mkFile withLangAbs "Abs" "hs" -absFileM = mkMod withLangAbs "Abs" +absFileM = mkMod withLangAbs "Abs" alexFile = mkFile withLang "Lex" "x" alexFileM = mkMod withLang "Lex" happyFile = mkFile withLang "Par" "y" @@ -107,8 +108,8 @@ xmlFileM = mkMod withLang "XML" layoutFile = mkFile withLang "Layout" "hs" -data Options = Options - { +data Options = Options + { make :: Bool, alex1 :: Bool, inDir :: Bool, @@ -121,13 +122,13 @@ multi :: Bool } -makeAll :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int +makeAll :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int -> Maybe String -- ^ The hierarchical package to put the modules -- in, or Nothing. -> String -> Bool -> FilePath -> IO () makeAll m a1 d ss bs g x p n mu file = do let opts = Options { make = m, alex1 = a1, inDir = d, shareStrings = ss, byteStrings=bs, - glr = if g then GLR else Standard, xml = x, + glr = if g then GLR else Standard, xml = x, inPackage = p, lang = n, multi = mu} absMod = absFileM opts @@ -146,11 +147,11 @@ writeFileRep (absFile opts) $ cf2Abstract (byteStrings opts) absMod cf if alex1 opts then do writeFileRep (alexFile opts) $ cf2alex lexMod errMod cf - putStrLn " (Use Alex 1.1 to compile.)" + putStrLn " (Use Alex 1.1 to compile.)" else do writeFileRep (alexFile opts) $ cf2alex2 lexMod errMod shareMod (shareStrings opts) (byteStrings opts) cf putStrLn " (Use Alex 2.0 to compile.)" - writeFileRep (happyFile opts) $ + writeFileRep (happyFile opts) $ cf2HappyS parMod absMod lexMod errMod (glr opts) (byteStrings opts) cf putStrLn " (Tested with Happy 1.15)" writeFileRep (latexFile opts) $ cfToLatex (lang opts) cf @@ -177,25 +178,25 @@ codeDir opts = let pref = maybe "" pkgToDir (inPackage opts) dir = if inDir opts then lang opts else "" sep = if null pref || null dir then "" else [pathSep] - in pref ++ sep ++ dir + in pref ++ sep ++ dir makefile :: Options -> String makefile opts = makeA where - glr_params = if glr opts == GLR then "--glr --decode " else "" + glr_params = if glr opts == GLR then "--glr --decode " else "" dir = let d = codeDir opts in if null d then "" else d ++ [pathSep] cd c = if null dir then c else "(cd " ++ dir ++ "; " ++ c ++ ")" - makeA = unlines + makeA = unlines [ - "all:", - "\thappy -gca " ++ glr_params ++ happyFile opts, + "all:", + "\thappy -gca " ++ glr_params ++ happyFile opts, "\talex -g " ++ alexFile opts, "\t" ++ cd ("latex " ++ basename (latexFile opts) - ++ "; " ++ "dvips " ++ basename (dviFile opts) + ++ "; " ++ "dvips " ++ basename (dviFile opts) ++ " -o " ++ basename (psFile opts)), "\tghc --make " ++ tFile opts ++ " -o " ++ mkFile withLang "Test" "" opts, "clean:", "\t-rm -f " ++ unwords (map (dir++) [ - "*.log", "*.aux", "*.hi", + "*.log", "*.aux", "*.hi", "*.o", "*.dvi" ]), "\t-rm -f " ++ psFile opts, @@ -214,7 +215,7 @@ mkFile noLang "ErrM" "*" opts, mkFile noLang "SharedString" "*" opts, dir ++ lang opts ++ ".dtd", - mkFile withLang "XML" "*" opts, + mkFile withLang "XML" "*" opts, "Makefile*" ], if null dir then "" else "\t-rmdir -p " ++ dir @@ -223,7 +224,7 @@ testfile :: Options -> CF -> String testfile opts cf - = let lay = hasLayout cf + = let lay = hasLayout cf use_xml = xml opts > 0 xpr = if use_xml then "XPrint a, " else "" use_glr = glr opts == GLR @@ -235,8 +236,8 @@ ["-- automatically generated by BNF Converter", "module Main where\n", "", - "import IO ( stdin, hGetContents )", - "import System ( getArgs, getProgName )", + "import System.IO ( stdin, hGetContents )", + "import System.IO ( getArgs, getProgName )", "", "import " ++ alexFileM opts, "import " ++ happyFileM opts, @@ -246,14 +247,14 @@ if lay then ("import " ++ layoutFileM opts) else "", if use_xml then ("import " ++ xmlFileM opts) else "", if_glr "import Data.FiniteMap(FiniteMap, lookupFM, fmToList)", - if_glr "import Maybe(fromJust)", + if_glr "import Data.Maybe(fromJust)", "import " ++ errFileM opts, "", if use_glr then "type ParseFun a = [[Token]] -> (GLRResult, GLR_Output (Err a))" else "type ParseFun a = [Token] -> Err a", "", - "myLLexer = " ++ if lay then "resolveLayout True . myLexer" + "myLLexer = " ++ if lay then "resolveLayout True . myLexer" else "myLexer", "", "type Verbosity = Int", @@ -287,7 +288,7 @@ ] run_std xml - = unlines + = unlines [ "run v p s = let ts = myLLexer s in case p ts of" , " Bad s -> do putStrLn \"\\nParse Failed...\\n\"" , " putStrV v \"Tokens:\"" @@ -301,7 +302,7 @@ ] run_glr - = unlines + = unlines [ "run v p s" , " = let ts = map (:[]) $ myLLexer s" , " (raw_output, simple_output) = p ts in" @@ -325,10 +326,10 @@ , " | (Ok t,n) <- zip trees [1..]" , " ]" ] - + lift_parser - = unlines + = unlines [ "type Forest = FiniteMap ForestId [Branch] -- omitted in ParX export." , "data GLR_Output a" , " = GLR_Result { pruned_decode :: (Forest -> Forest) -> [a]"
@@ -0,0 +1,356 @@+{- + BNF Converter: Haskell main file + Copyright (C) 2004 Author: Markus Forberg, Peter Gammie, Aarne Ranta + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-} + +module HaskellTop (makeAll) where + + + +-- import Utils +import CF +import CFtoHappy +import CFtoAlex +import CFtoAlex2 +import CFtoLatex +import CFtoTxt +import CFtoAbstract +import CFtoTemplate +import CFtoPrinter +import CFtoLayout +import CFtoXML +import MkErrM +import MkSharedString +-- import CFtoGF ( cf2AbsGF, cf2ConcGF ) +-- import System.IO +import GetCF +import Utils + +import Data.Char +import Data.Maybe (fromMaybe,maybe) +import System.IO +import Control.Monad(when) + +-- naming conventions + +noLang :: Options -> String -> String +noLang _ name = name + +withLang :: Options -> String -> String +withLang opts name = name ++ lang opts + +withLangAbs :: Options -> String -> String +withLangAbs opts name = postp $ name ++ lang opts + where + postp nam = if multi opts + then takeWhile (/='_') nam + else nam + +mkMod :: (Options -> String -> String) -> String -> Options -> String +mkMod addLang name opts = + pref ++ if inDir opts then lang opts ++ "." ++ name else addLang opts name + where pref = maybe "" (++".") (inPackage opts) + +mkFile :: (Options -> String -> String) -> String -> String -> Options -> FilePath +mkFile addLang name ext opts = + pref ++ if inDir opts + then lang opts ++ [pathSep] ++ name ++ ext' + else addLang opts name ++ if null ext then "" else ext' + where pref = maybe "" (\p->pkgToDir p++[pathSep]) (inPackage opts) + ext' = if null ext then "" else "." ++ ext + +absFile, absFileM, alexFile, alexFileM, dviFile, + gfAbs, gfConc, + happyFile, happyFileM, + latexFile, errFile, errFileM, + templateFile, templateFileM, + printerFile, printerFileM, + layoutFile, layoutFileM, + psFile, tFile, tFileM :: Options -> String +absFile = mkFile withLangAbs "Abs" "hs" +absFileM = mkMod withLangAbs "Abs" +alexFile = mkFile withLang "Lex" "x" +alexFileM = mkMod withLang "Lex" +happyFile = mkFile withLang "Par" "y" +happyFileM = mkMod withLang "Par" +latexFile = mkFile withLang "Doc" "tex" +txtFile = mkFile withLang "Doc" "txt" +templateFile = mkFile withLang "Skel" "hs" +templateFileM = mkMod withLang "Skel" +printerFile = mkFile withLang "Print" "hs" +printerFileM = mkMod withLang "Print" +dviFile = mkFile withLang "Doc" "dvi" +psFile = mkFile withLang "Doc" "ps" +gfAbs = mkFile withLangAbs "" "Abs.gf" +gfConc = mkFile withLang "" "Conc.gf" +tFile = mkFile withLang "Test" "hs" +tFileM = mkMod withLang "Test" +errFile = mkFile noLang "ErrM" "hs" +errFileM = mkMod noLang "ErrM" +shareFile = mkFile noLang "SharedString" "hs" +shareFileM = mkMod noLang "SharedString" +layoutFileM = mkMod withLang "Layout" +xmlFileM = mkMod withLang "XML" +layoutFile = mkFile withLang "Layout" "hs" + +data Options = Options + { + make :: Bool, + alex1 :: Bool, + inDir :: Bool, + shareStrings :: Bool, + byteStrings :: Bool, + glr :: HappyMode, + xml :: Int, + inPackage :: Maybe String, + lang :: String, + multi :: Bool + } + +makeAll :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int + -> Maybe String -- ^ The hierarchical package to put the modules + -- in, or Nothing. + -> String -> Bool -> FilePath -> IO () +makeAll m a1 d ss bs g x p n mu file = do + let opts = Options { make = m, alex1 = a1, inDir = d, shareStrings = ss, byteStrings=bs, + glr = if g then GLR else Standard, xml = x, + inPackage = p, lang = n, multi = mu} + + absMod = absFileM opts + lexMod = alexFileM opts + parMod = happyFileM opts + prMod = printerFileM opts + layMod = layoutFileM opts + errMod = errFileM opts + shareMod = shareFileM opts + (cf, isOK) <- tryReadCF file + if isOK then do + let dir = codeDir opts + when (not (null dir)) $ do + putStrLn $ "Creating directory " ++ dir + prepareDir dir + writeFileRep (absFile opts) $ cf2Abstract (byteStrings opts) absMod cf + if alex1 opts then do + writeFileRep (alexFile opts) $ cf2alex lexMod errMod cf + putStrLn " (Use Alex 1.1 to compile.)" + else do + writeFileRep (alexFile opts) $ cf2alex2 lexMod errMod shareMod (shareStrings opts) (byteStrings opts) cf + putStrLn " (Use Alex 2.0 to compile.)" + writeFileRep (happyFile opts) $ + cf2HappyS parMod absMod lexMod errMod (glr opts) (byteStrings opts) cf + putStrLn " (Tested with Happy 1.15)" + writeFileRep (latexFile opts) $ cfToLatex (lang opts) cf + writeFileRep (txtFile opts) $ cfToTxt (lang opts) cf + writeFileRep (templateFile opts) $ cf2Template (templateFileM opts) absMod errMod cf + writeFileRep (printerFile opts) $ cf2Printer (byteStrings opts) prMod absMod cf + when (hasLayout cf) $ writeFileRep (layoutFile opts) $ cf2Layout (alex1 opts) (inDir opts) layMod lexMod cf + writeFileRep (tFile opts) $ testfile opts cf + writeFileRep (errFile opts) $ errM errMod cf + when (shareStrings opts) $ writeFileRep (shareFile opts) $ sharedString shareMod (byteStrings opts) cf + when (make opts) $ writeFileRep "Makefile" $ makefile opts + case xml opts of + 2 -> makeXML (lang opts) True cf + 1 -> makeXML (lang opts) False cf + _ -> return () + putStrLn $ "Done!" + else do putStrLn $ "Failed!" + exitFailure + +pkgToDir :: String -> FilePath +pkgToDir s = replace '.' pathSep s + +codeDir :: Options -> FilePath +codeDir opts = let pref = maybe "" pkgToDir (inPackage opts) + dir = if inDir opts then lang opts else "" + sep = if null pref || null dir then "" else [pathSep] + in pref ++ sep ++ dir + +makefile :: Options -> String +makefile opts = makeA where + glr_params = if glr opts == GLR then "--glr --decode " else "" + dir = let d = codeDir opts in if null d then "" else d ++ [pathSep] + cd c = if null dir then c else "(cd " ++ dir ++ "; " ++ c ++ ")" + makeA = unlines + [ + "all:", + "\thappy -gca " ++ glr_params ++ happyFile opts, + "\talex -g " ++ alexFile opts, + "\t" ++ cd ("latex " ++ basename (latexFile opts) + ++ "; " ++ "dvips " ++ basename (dviFile opts) + ++ " -o " ++ basename (psFile opts)), + "\tghc --make " ++ tFile opts ++ " -o " ++ mkFile withLang "Test" "" opts, + "clean:", + "\t-rm -f " ++ unwords (map (dir++) [ + "*.log", "*.aux", "*.hi", + "*.o", "*.dvi" + ]), + "\t-rm -f " ++ psFile opts, + + "distclean: clean", + "\t-rm -f " ++ unwords [ + mkFile withLang "Doc" "*" opts, + mkFile withLang "Lex" "*" opts, + mkFile withLang "Par" "*" opts, + mkFile withLang "Layout" "*" opts, + mkFile withLang "Skel" "*" opts, + mkFile withLang "Print" "*" opts, + mkFile withLang "Test" "*" opts, + mkFile withLang "Abs" "*" opts, + mkFile withLang "Test" "" opts, + mkFile noLang "ErrM" "*" opts, + mkFile noLang "SharedString" "*" opts, + dir ++ lang opts ++ ".dtd", + mkFile withLang "XML" "*" opts, + "Makefile*" + ], + if null dir then "" else "\t-rmdir -p " ++ dir + ] + + +testfile :: Options -> CF -> String +testfile opts cf + = let lay = hasLayout cf + use_xml = xml opts > 0 + xpr = if use_xml then "XPrint a, " else "" + use_glr = glr opts == GLR + if_glr s = if use_glr then s else "" + firstParser = if use_glr then "the_parser" else parserName + parserName = 'p' : topType + topType = firstEntry cf + in unlines + ["-- automatically generated by BNF Converter", + "module Main where\n", + "", + "import System.IO ( stdin, hGetContents )", + "import System.IO ( getArgs, getProgName )", + "", + "import " ++ alexFileM opts, + "import " ++ happyFileM opts, + "import " ++ templateFileM opts, + "import " ++ printerFileM opts, + "import " ++ absFileM opts, + if lay then ("import " ++ layoutFileM opts) else "", + if use_xml then ("import " ++ xmlFileM opts) else "", + if_glr "import Data.FiniteMap(FiniteMap, lookupFM, fmToList)", + if_glr "import Data.Maybe(fromJust)", + "import " ++ errFileM opts, + "", + if use_glr + then "type ParseFun a = [[Token]] -> (GLRResult, GLR_Output (Err a))" + else "type ParseFun a = [Token] -> Err a", + "", + "myLLexer = " ++ if lay then "resolveLayout True . myLexer" + else "myLexer", + "", + "type Verbosity = Int", + "", + "putStrV :: Verbosity -> String -> IO ()", + "putStrV v s = if v > 1 then putStrLn s else return ()", + "", + "runFile :: (" ++ xpr ++ if_glr "TreeDecode a, " ++ "Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO ()", + "runFile v p f = putStrLn f >> readFile f >>= run v p", + "", + "run :: (" ++ xpr ++ if_glr "TreeDecode a, " ++ "Print a, Show a) => Verbosity -> ParseFun a -> String -> IO ()", + if use_glr then run_glr else run_std use_xml, + "", + "showTree :: (Show a, Print a) => Int -> a -> IO ()", + "showTree v tree", + " = do", + " putStrV v $ \"\\n[Abstract Syntax]\\n\\n\" ++ show tree", + " putStrV v $ \"\\n[Linearized tree]\\n\\n\" ++ printTree tree", + "", + "main :: IO ()", + "main = do args <- getArgs", + " case args of", + " [] -> hGetContents stdin >>= run 2 " ++ firstParser, + " \"-s\":fs -> mapM_ (runFile 0 " ++ firstParser ++ ") fs", + " fs -> mapM_ (runFile 2 " ++ firstParser ++ ") fs", + "", + if_glr $ "the_parser :: ParseFun " ++ topType, + if_glr $ "the_parser = lift_parser " ++ parserName, + if_glr $ "", + if_glr $ lift_parser + ] + +run_std xml + = unlines + [ "run v p s = let ts = myLLexer s in case p ts of" + , " Bad s -> do putStrLn \"\\nParse Failed...\\n\"" + , " putStrV v \"Tokens:\"" + , " putStrV v $ show ts" + , " putStrLn s" + , " Ok tree -> do putStrLn \"\\nParse Successful!\"" + , " showTree v tree" + , if xml then + " putStrV v $ \"\\n[XML]\\n\\n\" ++ printXML tree" + else "" + ] + +run_glr + = unlines + [ "run v p s" + , " = let ts = map (:[]) $ myLLexer s" + , " (raw_output, simple_output) = p ts in" + , " case simple_output of" + , " GLR_Fail major minor -> do" + , " putStrLn major" + , " putStrV v minor" + , " GLR_Result df trees -> do" + , " putStrLn \"\\nParse Successful!\"" + , " case trees of" + , " [] -> error \"No results but parse succeeded?\"" + , " [Ok x] -> showTree v x" + , " xs@(_:_) -> showSeveralTrees v xs" + , " where" + , " showSeveralTrees :: (Print b, Show b) => Int -> [Err b] -> IO ()" + , " showSeveralTrees v trees" + , " = sequence_ " + , " [ do putStrV v (replicate 40 '-')" + , " putStrV v $ \"Parse number: \" ++ show n" + , " showTree v t" + , " | (Ok t,n) <- zip trees [1..]" + , " ]" + ] + + +lift_parser + = unlines + [ "type Forest = FiniteMap ForestId [Branch] -- omitted in ParX export." + , "data GLR_Output a" + , " = GLR_Result { pruned_decode :: (Forest -> Forest) -> [a]" + , " , semantic_result :: [a]" + , " }" + , " | GLR_Fail { main_message :: String" + , " , extra_info :: String" + , " }" + , "" + , "lift_parser" + , " :: (TreeDecode a, Show a, Print a)" + , " => ([[Token]] -> GLRResult) -> ParseFun a" + , "lift_parser parser ts" + , " = let result = parser ts in" + , " (\\o -> (result, o)) $" + , " case result of" + , " ParseError ts f -> GLR_Fail \"Parse failed, unexpected token(s)\\n\"" + , " (\"Tokens: \" ++ show ts)" + , " ParseEOF f -> GLR_Fail \"Parse failed, unexpected EOF\\n\"" + , " (\"Partial forest:\\n\"" + , " ++ unlines (map show $ fmToList f))" + , " ParseOK r f -> let find f = fromJust . lookupFM f" + , " dec_fn f = decode (find f) r" + , " in GLR_Result (\\ff -> dec_fn $ ff f) (dec_fn f)" + ]
@@ -22,7 +22,7 @@ -- modified from pretty-printer generated by the BNF converter import AbsBNF-import Char+import Data.Char -- the top-level printing method printRegAlex :: Reg -> String
@@ -38,7 +38,7 @@ module CFtoCup ( cf2Cup ) where import CF-import List (intersperse, isPrefixOf)+import Data.List (intersperse, isPrefixOf) import Data.Char (isUpper) import NamedVariables import TypeChecker -- We need to (re-)typecheck to figure out list instances in
@@ -42,7 +42,7 @@ import RegToJLex import Utils ( (+++) ) import NamedVariables-import List+import Data.List --The environment must be returned for the parser to use. cf2jlex :: String -> String -> CF -> (String, SymEnv)
@@ -47,8 +47,8 @@ import CF import Utils((+++),(++++)) import NamedVariables hiding (IVar, getVars, varName)-import List-import Char(toLower)+import Data.List+import Data.Char(toLower) --Produces abstract data types in Java. --These follow Appel's "non-object oriented" version.
@@ -48,8 +48,8 @@ import CF import NamedVariables import Utils ( (+++) )-import List-import Char ( toLower )+import Data.List+import Data.Char ( toLower ) --Produces the PrettyPrinter class. --It will generate two methods "print" and "show"
@@ -21,8 +21,8 @@ import CF import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower)+import Data.List+import Data.Char(toLower) cf2JavaSkeleton :: String -> String -> CF -> String
@@ -42,8 +42,8 @@ import CF import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper)+import Data.List+import Data.Char(toLower, toUpper) --Produces a Skeleton using the Visitor Design Pattern. --Thus the user can choose which Skeleton to use.
@@ -22,7 +22,7 @@ -- Module : JavaTop -- Copyright : (C)opyright 2003, {markus, aarne, pellauer, peteg} at cs dot chalmers dot se -- License : GPL (see COPYING for details)--- +-- -- Maintainer : {markus, aarne} at cs dot chalmers dot se -- Stability : alpha -- Portability : Haskell98@@ -32,13 +32,13 @@ -- > $Id: JavaTop.hs,v 1.10 2005/09/21 13:06:10 bringert Exp $ ------------------------------------------------------------------- -module JavaTop ( makeJava ) where +module JavaTop ( makeJava ) where ------------------------------------------------------------------- -- Dependencies. --------------------------------------------------------------------import Directory ( createDirectory )-import IO ( try, isAlreadyExistsError )+import System.Directory ( createDirectory )+import System.IO.Error ( try, isAlreadyExistsError ) import Utils import CF@@ -49,10 +49,11 @@ import CFtoJavaSkeleton import CFtoVisitSkel import CFtoLatex-import System+import System.IO+import System.Exit import GetCF ( tryReadCF, writeFileRep )-import Char-import List(intersperse)+import Data.Char+import Data.List(intersperse) ------------------------------------------------------------------- -- | Build the Java output.@@ -125,7 +126,7 @@ -- Replace with an ANT script? makefile :: String -> FilePath -> FilePath -> [String] -> String makefile name dirBase dirAbsyn absynFileNames =- unlines + unlines [ "JAVAC = javac", "JAVAC_FLAGS = -sourcepath .",@@ -197,7 +198,7 @@ "\t rm -f " ++ unwords (map (dirBase ++) ["Yylex", name ++ ".cup", "Yylex.java",- "sym.java", + "sym.java", "parser.java", "Visitor.java", "Visitable.java",@@ -236,7 +237,7 @@ ] where prUser u = " public void visit" ++ u' ++ "(String p);\n"- where + where u' = ((toUpper (head u)) : (map toLower (tail u))) --this is a hack to fix a potential capitalization problem. footer = unlines [ --later only include used categories@@ -282,7 +283,7 @@ " /* " ++ (concat (intersperse ", " (showOpts (tail eps)))) ++ " */", " try", " {",- " " ++ packageAbsyn ++ "." ++ def +++ "parse_tree = p.p" + " " ++ packageAbsyn ++ "." ++ def +++ "parse_tree = p.p" ++ def ++ "();", " System.out.println();", " System.out.println(\"Parse Succesful!\");",@@ -309,5 +310,5 @@ showOpts [] = [] showOpts (x:[]) = if normCat x /= x then [] else ['p' : (identCat x)]- showOpts (x:xs) = if normCat x /= x then (showOpts xs) + showOpts (x:xs) = if normCat x /= x then (showOpts xs) else ('p' : (identCat x)) : (showOpts xs)
@@ -0,0 +1,313 @@+{-+ BNF Converter: Java Top File+ Copyright (C) 2004 Author: Markus Forsberg, Peter Gammie, Michael Pellauer++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++-------------------------------------------------------------------+-- |+-- Module : JavaTop+-- Copyright : (C)opyright 2003, {markus, aarne, pellauer, peteg} at cs dot chalmers dot se+-- License : GPL (see COPYING for details)+-- +-- Maintainer : {markus, aarne} at cs dot chalmers dot se+-- Stability : alpha+-- Portability : Haskell98+--+-- Top-level for the Java back end.+--+-- > $Id: JavaTop.hs,v 1.10 2005/09/21 13:06:10 bringert Exp $+-------------------------------------------------------------------++module JavaTop ( makeJava ) where ++-------------------------------------------------------------------+-- Dependencies.+-------------------------------------------------------------------+import System.Directory ( createDirectory )+import System.IO ( try, isAlreadyExistsError )++import Utils+import CF+import CFtoCup ( cf2Cup )+import CFtoJLex+import CFtoJavaAbs ( cf2JavaAbs )+import CFtoJavaPrinter+import CFtoJavaSkeleton+import CFtoVisitSkel+import CFtoLatex+import System.IO+import GetCF ( tryReadCF, writeFileRep )+import Data.Char+import Data.List(intersperse)++-------------------------------------------------------------------+-- | Build the Java output.+-- FIXME: get everything to put the files in the right places.+-- Adapt Makefile to do the business.+-------------------------------------------------------------------+makeJava :: Bool -> String -> FilePath -> IO ()+makeJava make name file =+ do (cf, isOK) <- tryReadCF file+ if isOK+ then do mkFiles make name cf+ putStrLn $ "Done!"+ else do putStrLn $ "Failed!"+ exitFailure++mkFiles :: Bool -> String -> CF -> IO ()+mkFiles make name cf =+ do -- Create the package directories if necessary.+ let packageBase = name+ packageAbsyn = packageBase ++ "." ++ "Absyn"+ dirBase = pkgToDir packageBase+ dirAbsyn = pkgToDir packageAbsyn+ chkExists dirBase+ chkExists dirAbsyn+ let absynFiles = remDups $ cf2JavaAbs packageBase packageAbsyn cf+ absynBaseNames = map fst absynFiles+ absynFileNames = map (dirAbsyn ++) absynBaseNames+ let writeAbsyn (filename, contents) =+ writeFileRep (dirAbsyn ++ filename ++ ".java") contents+ mapM writeAbsyn absynFiles+ writeFileRep (dirBase ++ "PrettyPrinter.java") $ cf2JavaPrinter packageBase packageAbsyn cf+ writeFileRep (dirBase ++ "Skeleton.java") $ cf2JavaSkeleton packageBase packageAbsyn cf+ writeFileRep (dirBase ++ "Visitable.java") $ prVisitable packageBase+ let user = fst $ unzip $ tokenPragmas cf -- FIXME better var name+ writeFileRep (dirBase ++ "Visitor.java") $ prVisitor packageBase packageAbsyn absynBaseNames user+ writeFileRep (dirBase ++ "VisitSkel.java") $ cf2VisitSkel packageBase packageAbsyn cf+ writeFileRep (dirBase ++ "Test.java") $ javaTest packageBase packageAbsyn cf+ let (lex, env) = cf2jlex packageBase packageAbsyn cf+ writeFileRep (dirBase ++ "Yylex") lex+ putStrLn " (Tested with JLex 1.2.6.)"+ writeFileRep (dirBase ++ name ++ ".cup") $ cf2Cup packageBase packageAbsyn cf env+ -- FIXME: put in a doc directory?+ putStrLn $ " (Parser created for category " ++ firstEntry cf ++ ")"+ putStrLn " (Tested with CUP 0.10k)"+ writeFileRep (name ++ ".tex") $ cfToLatex name cf+ if make+ then writeFileRep "Makefile" $ makefile name dirBase dirAbsyn absynFileNames+ else return ()+ where+ remDups [] = []+ remDups ((a,b):as) = case lookup a as of+ Just {} -> remDups as+ Nothing -> (a, b) : (remDups as)++ pkgToDir :: String -> FilePath+ pkgToDir p = [ if c == '.' then '/' else c | c <- p] ++ "/"++ chkExists :: FilePath -> IO ()+ chkExists dir =+ do eErr <- try $ createDirectory dir+ case eErr of+ Left ioerr -> if isAlreadyExistsError ioerr+ then return ()+ else fail $ show ioerr+ Right () -> putStrLn $ "Created directory: " ++ dir++-- FIXME get filenames right.+-- FIXME It's almost certainly better to just feed all the Java source+-- files to javac in one go.+-- Replace with an ANT script?+makefile :: String -> FilePath -> FilePath -> [String] -> String+makefile name dirBase dirAbsyn absynFileNames =+ unlines + [+ "JAVAC = javac",+ "JAVAC_FLAGS = -sourcepath .",+ "",+ "JAVA = java",+ "",+ "CUP = java_cup.Main",+ "CUPFLAGS = -nopositions -expect 100",+ "",+ "JLEX = JLex.Main",+ "",+ "LATEX = latex",+ "DVIPS = dvips",+ "",+ "all: test " ++ name ++ ".ps",+ "",+ "test: absyn "+ ++ unwords (map (dirBase ++) ["Visitor.class",+ "Visitable.class",+ "Test.class"]),+ "",+ ".PHONE: absyn",+ "",+ "absyn: " ++ absynJavaClass,+ "",+ "%.class: " ++ "%.java",+ "\t${JAVAC} ${JAVAC_FLAGS} $*.java",+ "",+ dirBase ++ "Visitable.class: " ++ dirBase ++ "Visitable.java",+ "\t${JAVAC} ${JAVAC_FLAGS} " ++ dirBase ++ "Visitable.java",+ "",+ dirBase ++ "Visitor.class: " ++ dirBase ++ "Visitor.java",+ "\t${JAVAC} ${JAVAC_FLAGS} " ++ dirBase ++ "Visitor.java",+ "",+ dirBase ++ "Yylex.java: " ++ dirBase ++ "Yylex",+ "\t${JAVA} ${JLEX} " ++ dirBase ++ "Yylex",+ "",+ -- FIXME+ dirBase ++ "sym.java" ++ " " ++ dirBase ++ "parser.java: " ++ dirBase ++ name ++ ".cup",+ "\t${JAVA} ${CUP} ${CUPFLAGS} " ++ dirBase ++ name ++ ".cup ; mv sym.java parser.java " ++ dirBase,+ "",+ dirBase ++ "Yylex.class: " ++ dirBase ++ "Yylex.java "+ ++ dirBase ++ "sym.java",+ "\t${JAVAC} ${JAVAC_FLAGS} " ++ dirBase ++ "Yylex.java",+ "",+ dirBase ++ "Test.class: "+ ++ unwords (map (dirBase ++) ["Test.java",+ "PrettyPrinter.class",+ "Yylex.class",+ "parser.class",+ "sym.class"]),+ "\t${JAVAC} ${JAVAC_FLAGS} " ++ dirBase ++ "Test.java",+ "",+ "" ++ name ++ ".dvi: " ++ name ++ ".tex",+ "\t${LATEX} " ++ name ++ ".tex",+ "",+ "" ++ name ++ ".ps: " ++ name ++ ".dvi",+ "\t${DVIPS} " ++ name ++ ".dvi -o " ++ name ++ ".ps",+-- FIXME+ "",+ "clean:",+ "\t rm -f " ++ absynJavaClass,+ "\t rm -f " ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps " ++ " *.class Makefile",+ "",+ "distclean:",+ "\t rm -f " ++ absynJavaSrc ++ " " ++ absynJavaClass,+ "\t rmdir " ++ dirAbsyn,+ "\t rm -f " ++ name ++ ".tex " ++ name ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps ",+ "\t rm -f " ++ unwords (map (dirBase ++) ["Yylex",+ name ++ ".cup",+ "Yylex.java",+ "sym.java", + "parser.java",+ "Visitor.java",+ "Visitable.java",+ "VisitSkel.java",+ "PrettyPrinter.java",+ "Skeleton.java",+ "Test.java",+ "*.class"]),+ "\t rmdir " ++ dirBase,+ "\t rm -f Makefile",+ ""+ ]+ where absynJavaSrc = unwords (map (++ ".java") absynFileNames)+ absynJavaClass = unwords (map (++ ".class") absynFileNames)++prVisitable :: String -> String+prVisitable packageBase = unlines+ [+ "package" +++ packageBase ++ ";\n",+ "public interface Visitable",+ "{",+ " public void accept(" ++ packageBase ++ ".Visitor v);",+ "}"+ ]++prVisitor :: String -> String -> [String] -> [String]-> String+prVisitor packageBase packageAbsyn funs user =+ unlines+ [+ "package" +++ packageBase ++ ";\n",+ "public interface Visitor",+ "{",+ concatMap prVisitFun funs,+ concatMap prUser user,+ footer+ ]+ where+ prUser u = " public void visit" ++ u' ++ "(String p);\n"+ where + u' = ((toUpper (head u)) : (map toLower (tail u))) --this is a hack to fix a potential capitalization problem.+ footer = unlines+ [ --later only include used categories+ " public void visitIdent(String i);",+ " public void visitInteger(Integer i);",+ " public void visitDouble(Double d);",+ " public void visitChar(Character c);",+ " public void visitString(String s);",+ "}"+ ]+ prVisitFun f = " public void visit" ++ f ++ "(" ++ packageAbsyn+ ++ "." ++ f ++ " p);\n"++javaTest :: String -> String -> CF -> String+javaTest packageBase packageAbsyn cf =+ unlines+ [+ "package" +++ packageBase ++ ";",+ "import java_cup.runtime.*;",+ "import" +++ packageBase ++ ".*;",+ "import" +++ packageAbsyn ++ ".*;",+ "import java.io.*;",+ "",+ "public class Test",+ "{",+ " public static void main(String args[]) throws Exception",+ " {",+ " Yylex l = null;",+ " parser p;",+ " try",+ " {",+ " if (args.length == 0) l = new Yylex(System.in);",+ " else l = new Yylex(new FileReader(args[0]));",+ " }",+ " catch(FileNotFoundException e)",+ " {",+ " System.err.println(\"Error: File not found: \" + args[0]);",+ " System.exit(1);",+ " }",+ " p = new parser(l);",+ " /* The default parser is the first-defined entry point. */",+ " /* You may want to change this. Other options are: */",+ " /* " ++ (concat (intersperse ", " (showOpts (tail eps)))) ++ " */",+ " try",+ " {",+ " " ++ packageAbsyn ++ "." ++ def +++ "parse_tree = p.p" + ++ def ++ "();",+ " System.out.println();",+ " System.out.println(\"Parse Succesful!\");",+ " System.out.println();",+ " System.out.println(\"[Abstract Syntax]\");",+ " System.out.println();",+ " System.out.println(PrettyPrinter.show(parse_tree));",+ " System.out.println();",+ " System.out.println(\"[Linearized Tree]\");",+ " System.out.println();",+ " System.out.println(PrettyPrinter.print(parse_tree));",+ " }",+ " catch(Throwable e)",+ " {",+ " System.err.println(\"At line \" + String.valueOf(l.line_num()) + \", near \\\"\" + l.buff() + \"\\\" :\");",+ " System.err.println(\" \" + e.getMessage());",+ " System.exit(1);",+ " }",+ " }",+ "}"+ ]+ where eps = allEntryPoints cf+ def = head eps+ showOpts [] = []++ showOpts (x:[]) = if normCat x /= x then [] else ['p' : (identCat x)]+ showOpts (x:xs) = if normCat x /= x then (showOpts xs) + else ('p' : (identCat x)) : (showOpts xs)
@@ -3,7 +3,7 @@ -- modified from pretty-printer generated by the BNF converter import AbsBNF-import Char+import Data.Char -- the top-level printing method printRegJLex :: Reg -> String
@@ -24,8 +24,8 @@ import CFtoJavaAbs15 (typename) import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper, isDigit)+import Data.List+import Data.Char(toLower, toUpper, isDigit) cf2AbstractVisitor :: String -> String -> CF -> String cf2AbstractVisitor packageBase packageAbsyn cf =
@@ -24,8 +24,8 @@ import CFtoJavaAbs15 (typename) import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper, isDigit)+import Data.List+import Data.Char(toLower, toUpper, isDigit) cf2AllVisitor :: String -> String -> CF -> String cf2AllVisitor packageBase packageAbsyn cf =
@@ -24,8 +24,8 @@ import CFtoJavaAbs15 (typename) import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper, isDigit)+import Data.List+import Data.Char(toLower, toUpper, isDigit) cf2ComposVisitor :: String -> String -> CF -> String cf2ComposVisitor packageBase packageAbsyn cf =
@@ -40,7 +40,7 @@ module CFtoCup15 ( cf2Cup ) where import CF-import List (intersperse, isPrefixOf)+import Data.List (intersperse, isPrefixOf) import NamedVariables import Utils ( (+++) ) import TypeChecker -- We need to (re-)typecheck to figure out list instances in
@@ -24,8 +24,8 @@ import CFtoJavaAbs15 (typename) import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper, isDigit)+import Data.List+import Data.Char(toLower, toUpper, isDigit) cf2FoldVisitor :: String -> String -> CF -> String cf2FoldVisitor packageBase packageAbsyn cf =
@@ -43,7 +43,7 @@ import RegToJLex import Utils ( (+++) ) import NamedVariables-import List+import Data.List --The environment must be returned for the parser to use. cf2jlex :: String -> String -> CF -> (String, SymEnv)
@@ -48,9 +48,9 @@ import CF import Utils((+++),(++++)) import NamedVariables hiding (IVar, getVars, varName)-import List-import Char(toLower, isDigit)-import Maybe(catMaybes,fromMaybe)+import Data.List+import Data.Char(toLower, isDigit)+import Data.Maybe(catMaybes,fromMaybe) --Produces abstract data types in Java. --These follow Appel's "non-object oriented" version.
@@ -51,8 +51,8 @@ import CF import NamedVariables import Utils ( (+++) )-import List-import Char ( toLower, isSpace )+import Data.List+import Data.Char ( toLower, isSpace ) --Produces the PrettyPrinter class. --It will generate two methods "print" and "show"
@@ -44,8 +44,8 @@ import CFtoJavaAbs15 (typename) import Utils ((+++), (++++)) import NamedVariables-import List-import Char(toLower, toUpper, isDigit)+import Data.List+import Data.Char(toLower, toUpper, isDigit) --Produces a Skeleton using the Visitor Design Pattern. --Thus the user can choose which Skeleton to use.
@@ -1,6 +1,6 @@ {- BNF Converter: Java Top File- Copyright (C) 2004 Author: Markus Forsberg, Peter Gammie, + Copyright (C) 2004 Author: Markus Forsberg, Peter Gammie, Michael Pellauer, Bjorn Bringert This program is free software; you can redistribute it and/or modify@@ -23,7 +23,7 @@ -- Module : JavaTop -- Copyright : (C)opyright 2003, {markus, aarne, pellauer, peteg, bringert} at cs dot chalmers dot se -- License : GPL (see COPYING for details)--- +-- -- Maintainer : {markus, aarne} at cs dot chalmers dot se -- Stability : alpha -- Portability : Haskell98@@ -33,13 +33,13 @@ -- > $Id: JavaTop15.hs,v 1.12 2007/01/08 18:20:23 aarne Exp $ ------------------------------------------------------------------- -module JavaTop15 ( makeJava15 ) where +module JavaTop15 ( makeJava15 ) where ------------------------------------------------------------------- -- Dependencies. --------------------------------------------------------------------import Directory ( createDirectory )-import IO ( try, isAlreadyExistsError )+import System.Directory ( createDirectory )+import System.IO.Error ( try, isAlreadyExistsError ) import Utils import CF@@ -54,17 +54,17 @@ import CFtoFoldVisitor import CFtoAllVisitor import CFtoLatex-import System+import System.Exit import GetCF ( tryReadCF, writeFileRep )-import Char-import List(intersperse)+import Data.Char+import Data.List(intersperse) ------------------------------------------------------------------- -- | Build the Java output. -- FIXME: get everything to put the files in the right places. -- Adapt Makefile to do the business. --------------------------------------------------------------------makeJava15 :: Bool +makeJava15 :: Bool -> Maybe String -- ^ Java package name to put the classes in -> String -- ^ Name of grammar -> FilePath -- ^ Grammar file@@ -129,7 +129,7 @@ -- Replace with an ANT script? makefile :: String -> FilePath -> FilePath -> [String] -> String makefile name dirBase dirAbsyn absynFileNames =- unlines + unlines [ "JAVAC = javac", "JAVAC_FLAGS = -sourcepath .",@@ -254,7 +254,7 @@ " /* " ++ (concat (intersperse ", " (showOpts (tail eps)))) ++ " */", " try", " {",- " " ++ packageAbsyn ++ "." ++ def +++ "parse_tree = p.p" + " " ++ packageAbsyn ++ "." ++ def +++ "parse_tree = p.p" ++ def ++ "();", " System.out.println();", " System.out.println(\"Parse Succesful!\");",@@ -281,5 +281,5 @@ showOpts [] = [] showOpts (x:[]) = if normCat x /= x then [] else ['p' : (identCat x)]- showOpts (x:xs) = if normCat x /= x then (showOpts xs) + showOpts (x:xs) = if normCat x /= x then (showOpts xs) else ('p' : (identCat x)) : (showOpts xs)
@@ -0,0 +1,285 @@+{-+ BNF Converter: Java Top File+ Copyright (C) 2004 Author: Markus Forsberg, Peter Gammie, + Michael Pellauer, Bjorn Bringert++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++-------------------------------------------------------------------+-- |+-- Module : JavaTop+-- Copyright : (C)opyright 2003, {markus, aarne, pellauer, peteg, bringert} at cs dot chalmers dot se+-- License : GPL (see COPYING for details)+-- +-- Maintainer : {markus, aarne} at cs dot chalmers dot se+-- Stability : alpha+-- Portability : Haskell98+--+-- Top-level for the Java back end.+--+-- > $Id: JavaTop15.hs,v 1.12 2007/01/08 18:20:23 aarne Exp $+-------------------------------------------------------------------++module JavaTop15 ( makeJava15 ) where ++-------------------------------------------------------------------+-- Dependencies.+-------------------------------------------------------------------+import System.Directory ( createDirectory )+import System.IO ( try, isAlreadyExistsError )++import Utils+import CF+import CFtoCup15 ( cf2Cup )+import CFtoJLex15+import CFtoJavaAbs15 ( cf2JavaAbs )+import CFtoJavaPrinter15+--import CFtoJavaSkeleton+import CFtoVisitSkel15+import CFtoComposVisitor+import CFtoAbstractVisitor+import CFtoFoldVisitor+import CFtoAllVisitor+import CFtoLatex+import System.IO+import GetCF ( tryReadCF, writeFileRep )+import Data.Char+import Data.List(intersperse)++-------------------------------------------------------------------+-- | Build the Java output.+-- FIXME: get everything to put the files in the right places.+-- Adapt Makefile to do the business.+-------------------------------------------------------------------+makeJava15 :: Bool + -> Maybe String -- ^ Java package name to put the classes in+ -> String -- ^ Name of grammar+ -> FilePath -- ^ Grammar file+ -> IO ()+makeJava15 make inPackage name file =+ do (cf, isOK) <- tryReadCF file+ if isOK+ then do mkFiles make inPackage name cf+ putStrLn $ "Done!"+ else do putStrLn $ "Failed!"+ exitFailure++mkFiles :: Bool -> Maybe String -> String -> CF -> IO ()+mkFiles make inPackage name cf =+ do -- Create the package directories if necessary.+ let packageBase = case inPackage of+ Nothing -> name+ Just p -> p ++ "." ++ name+ packageAbsyn = packageBase ++ "." ++ "Absyn"+ dirBase = pkgToDir packageBase+ dirAbsyn = pkgToDir packageAbsyn+ prepareDir dirBase+ prepareDir dirAbsyn+ let absynFiles = remDups $ cf2JavaAbs packageBase packageAbsyn cf+ absynBaseNames = map fst absynFiles+ absynFileNames = map (dirAbsyn ++) absynBaseNames+ absynFuns = [ f | (_,ps) <- cf2data cf, (f,_) <- ps ]+ let writeAbsyn (filename, contents) =+ writeFileRep (dirAbsyn ++ filename ++ ".java") contents+ mapM writeAbsyn absynFiles+ writeFileRep (dirBase ++ "PrettyPrinter.java") $ cf2JavaPrinter packageBase packageAbsyn cf+ writeFileRep (dirBase ++ "VisitSkel.java") $ cf2VisitSkel packageBase packageAbsyn cf+ writeFileRep (dirBase ++ "ComposVisitor.java") $ cf2ComposVisitor packageBase packageAbsyn cf+ writeFileRep (dirBase ++ "AbstractVisitor.java") $ cf2AbstractVisitor packageBase packageAbsyn cf+ writeFileRep (dirBase ++ "FoldVisitor.java") $ cf2FoldVisitor packageBase packageAbsyn cf+ writeFileRep (dirBase ++ "AllVisitor.java") $ cf2AllVisitor packageBase packageAbsyn cf+ writeFileRep (dirBase ++ "Test.java") $ javaTest packageBase packageAbsyn cf+ let (lex, env) = cf2jlex packageBase packageAbsyn cf+ writeFileRep (dirBase ++ "Yylex") lex+ putStrLn " (Tested with JLex 1.2.6.)"+ writeFileRep (dirBase ++ name ++ ".cup") $ cf2Cup packageBase packageAbsyn cf env+ -- FIXME: put in a doc directory?+ putStrLn $ " (Parser created for category " ++ firstEntry cf ++ ")"+ putStrLn " (Tested with CUP 0.10k)"+ writeFileRep (name ++ ".tex") $ cfToLatex name cf+ if make+ then writeFileRep "Makefile" $ makefile name dirBase dirAbsyn absynFileNames+ else return ()+ where+ remDups [] = []+ remDups ((a,b):as) = case lookup a as of+ Just {} -> remDups as+ Nothing -> (a, b) : (remDups as)++ pkgToDir :: String -> FilePath+ pkgToDir s = replace '.' pathSep s ++ [pathSep]+++-- FIXME get filenames right.+-- FIXME It's almost certainly better to just feed all the Java source+-- files to javac in one go.+-- Replace with an ANT script?+makefile :: String -> FilePath -> FilePath -> [String] -> String+makefile name dirBase dirAbsyn absynFileNames =+ unlines + [+ "JAVAC = javac",+ "JAVAC_FLAGS = -sourcepath .",+ "",+ "JAVA = java",+ "JAVA_FLAGS =",+ "",+ "CUP = java_cup.Main",+ "CUPFLAGS = -nopositions -expect 100",+ "",+ "JLEX = JLex.Main",+ "",+ "LATEX = latex",+ "DVIPS = dvips",+ "",+ "all: test " ++ name ++ ".ps",+ "",+ "test: absyn "+ ++ unwords (map (dirBase ++) [+ "Yylex.class",+ "PrettyPrinter.class",+ "Test.class",+ "ComposVisitor.class",+ "AbstractVisitor.class",+ "FoldVisitor.class",+ "AllVisitor.class",+ "parser.class",+ "sym.class",+ "Test.class"]),+ "",+ ".PHONY: absyn",+ "",+ "%.class: %.java",+ "\t${JAVAC} ${JAVAC_FLAGS} $^",+ "",+ "absyn: " ++ absynJavaSrc,+ "\t${JAVAC} ${JAVAC_FLAGS} $^",+ "",+ dirBase ++ "Yylex.java: " ++ dirBase ++ "Yylex",+ "\t${JAVA} ${JAVA_FLAGS} ${JLEX} " ++ dirBase ++ "Yylex",+ "",+ dirBase ++ "sym.java " ++ dirBase ++ "parser.java: " ++ dirBase ++ name ++ ".cup",+ "\t${JAVA} ${JAVA_FLAGS} ${CUP} ${CUPFLAGS} " ++ dirBase ++ name ++ ".cup",+ "\tmv sym.java parser.java " ++ dirBase,+ "",+ dirBase ++ "Yylex.class: " ++ dirBase ++ "Yylex.java"+ ++ " " ++ dirBase ++ "sym.java",+ "",+ dirBase ++ "sym.class: " ++ dirBase ++ "sym.java",+ "",+ dirBase ++ "parser.class: " ++ dirBase ++ "parser.java " ++ dirBase ++ "sym.java",+ "",+ dirBase ++ "PrettyPrinter.class: " ++ dirBase ++ "PrettyPrinter.java",+ "",+ "" ++ name ++ ".dvi: " ++ name ++ ".tex",+ "\t${LATEX} " ++ name ++ ".tex",+ "",+ "" ++ name ++ ".ps: " ++ name ++ ".dvi",+ "\t${DVIPS} " ++ name ++ ".dvi -o " ++ name ++ ".ps",+-- FIXME+ "",+ "clean:",+ "\t rm -f " ++ dirAbsyn ++ "*.class" ++ " " ++ dirBase ++ "*.class",+ "\t rm -f " ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps " ++ " *.class",+ "",+ "vclean:",+ "\t rm -f " ++ absynJavaSrc ++ " " ++ absynJavaClass,+ "\t rm -f " ++ dirAbsyn ++ "*.class",+ "\t rmdir " ++ dirAbsyn,+ "\t rm -f " ++ name ++ ".tex " ++ name ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps ",+ "\t rm -f " ++ unwords (map (dirBase ++) [+ "Yylex",+ name ++ ".cup",+ "Yylex.java",+ "VisitSkel.java",+ "ComposVisitor.java",+ "AbstractVisitor.java",+ "FoldVisitor.java",+ "AllVisitor.java",+ "PrettyPrinter.java",+ "Skeleton.java",+ "Test.java",+ "sym.java",+ "parser.java",+ "*.class"]),+ "\t rm -f Makefile",+ "\t rmdir -p " ++ dirBase,+ ""+ ]+ where absynJavaSrc = unwords (map (++ ".java") absynFileNames)+ absynJavaClass = unwords (map (++ ".class") absynFileNames)++javaTest :: String -> String -> CF -> String+javaTest packageBase packageAbsyn cf =+ unlines+ [+ "package" +++ packageBase ++ ";",+ "import java_cup.runtime.*;",+ "import" +++ packageBase ++ ".*;",+ "import" +++ packageAbsyn ++ ".*;",+ "import java.io.*;",+ "",+ "public class Test",+ "{",+ " public static void main(String args[]) throws Exception",+ " {",+ " Yylex l = null;",+ " parser p;",+ " try",+ " {",+ " if (args.length == 0) l = new Yylex(System.in);",+ " else l = new Yylex(new FileReader(args[0]));",+ " }",+ " catch(FileNotFoundException e)",+ " {",+ " System.err.println(\"Error: File not found: \" + args[0]);",+ " System.exit(1);",+ " }",+ " p = new parser(l);",+ " /* The default parser is the first-defined entry point. */",+ " /* You may want to change this. Other options are: */",+ " /* " ++ (concat (intersperse ", " (showOpts (tail eps)))) ++ " */",+ " try",+ " {",+ " " ++ packageAbsyn ++ "." ++ def +++ "parse_tree = p.p" + ++ def ++ "();",+ " System.out.println();",+ " System.out.println(\"Parse Succesful!\");",+ " System.out.println();",+ " System.out.println(\"[Abstract Syntax]\");",+ " System.out.println();",+ " System.out.println(PrettyPrinter.show(parse_tree));",+ " System.out.println();",+ " System.out.println(\"[Linearized Tree]\");",+ " System.out.println();",+ " System.out.println(PrettyPrinter.print(parse_tree));",+ " }",+ " catch(Throwable e)",+ " {",+ " System.err.println(\"At line \" + String.valueOf(l.line_num()) + \", near \\\"\" + l.buff() + \"\\\" :\");",+ " System.err.println(\" \" + e.getMessage());",+ " System.exit(1);",+ " }",+ " }",+ "}"+ ]+ where eps = allEntryPoints cf+ def = head eps+ showOpts [] = []++ showOpts (x:[]) = if normCat x /= x then [] else ['p' : (identCat x)]+ showOpts (x:xs) = if normCat x /= x then (showOpts xs) + else ('p' : (identCat x)) : (showOpts xs)
@@ -23,7 +23,7 @@ import CF import Utils((+++),(++++))-import List(intersperse)+import Data.List(intersperse) import OCamlUtil -- to produce an OCaml module
@@ -22,8 +22,8 @@ module CFtoOCamlLex (cf2ocamllex) where -import List-import Char+import Data.List+import Data.Char import CF import AbsBNF
@@ -24,8 +24,8 @@ import CF import Utils import CFtoTemplate-import List (intersperse)-import Char(toLower,isDigit)+import Data.List (intersperse)+import Data.Char(toLower,isDigit) import OCamlUtil -- derive pretty-printer from a BNF grammar. AR 15/2/2002
@@ -26,8 +26,8 @@ import CF import Utils import CFtoTemplate-import List (intersperse)-import Char(toLower,isDigit)+import Data.List (intersperse)+import Data.Char(toLower,isDigit) import OCamlUtil cf2show :: String -> String -> CF -> String
@@ -25,8 +25,8 @@ ) where import CF-import Char-import List (delete)+import Data.Char+import Data.List (delete) import Utils((+++)) import OCamlUtil
@@ -27,8 +27,8 @@ where import CF-import List (intersperse,nub)-import Char+import Data.List (intersperse,nub)+import Data.Char import Utils ((+++)) import OCamlUtil
@@ -20,7 +20,7 @@ -- based on BNFC Haskell backend -module OCamlTop (makeOCaml) where +module OCamlTop (makeOCaml) where import CF import CFtoOCamlYacc@@ -35,10 +35,11 @@ import GetCF import Utils -import Char+import Data.Char import Data.Maybe (fromMaybe,maybe)-import System-import Monad(when)+import System.IO+import System.Exit+import Control.Monad(when) -- naming conventions @@ -49,12 +50,12 @@ withLang opts name = name ++ lang opts mkMod :: (Options -> String -> String) -> String -> Options -> String-mkMod addLang name opts = +mkMod addLang name opts = pref ++ if inDir opts then lang opts ++ "." ++ name else addLang opts name where pref = maybe "" (++".") (inPackage opts) mkFile :: (Options -> String -> String) -> String -> String -> Options -> FilePath-mkFile addLang name ext opts = +mkFile addLang name ext opts = pref ++ if inDir opts then lang opts ++ [pathSep] ++ name ++ ext' else addLang opts name ++ if null ext then "" else ext'@@ -64,11 +65,11 @@ absFile, absFileM, ocamllexFile, ocamllexFileM, dviFile, ocamlyaccFile, ocamlyaccFileM, latexFile, utilFile, utilFileM,- templateFile, templateFileM, + templateFile, templateFileM, printerFile, printerFileM, psFile, tFile, tFileM :: Options -> String absFile = mkFile withLang "Abs" "ml"-absFileM = mkMod withLang "Abs" +absFileM = mkMod withLang "Abs" ocamllexFile = mkFile withLang "Lex" "mll" ocamllexFileM = mkMod withLang "Lex" ocamlyaccFile = mkFile withLang "Par" "mly"@@ -88,8 +89,8 @@ utilFileM = mkMod noLang "BNFC_Util" xmlFileM = mkMod withLang "XML" -data Options = Options - { +data Options = Options+ { make :: Bool, alex1 :: Bool, inDir :: Bool,@@ -100,7 +101,7 @@ } -- FIXME: we probably don't need all these arguments-makeOCaml :: Bool -> Bool -> Bool -> Bool -> Bool -> Int +makeOCaml :: Bool -> Bool -> Bool -> Bool -> Bool -> Int -> Maybe String -- ^ The hierarchical package to put the modules -- in, or Nothing. -> String -> FilePath -> IO ()@@ -123,14 +124,14 @@ prepareDir dir writeFileRep (absFile opts) $ cf2Abstract absMod cf writeFileRep (ocamllexFile opts) $ cf2ocamllex lexMod parMod cf- writeFileRep (ocamlyaccFile opts) $ + writeFileRep (ocamlyaccFile opts) $ cf2ocamlyacc parMod absMod lexMod cf writeFileRep (latexFile opts) $ cfToLatex (lang opts) cf writeFileRep (templateFile opts) $ cf2Template (templateFileM opts) absMod cf writeFileRep (printerFile opts) $ cf2Printer prMod absMod cf writeFileRep (showFile opts) $ cf2show showMod absMod cf writeFileRep (tFile opts) $ ocamlTestfile absMod lexMod parMod prMod showMod cf- writeFileRep (utilFile opts) $ utilM + writeFileRep (utilFile opts) $ utilM when (make opts) $ writeFileRep "Makefile" $ makefile opts case xml opts of 2 -> makeXML (lang opts) True cf@@ -147,19 +148,19 @@ codeDir opts = let pref = maybe "" pkgToDir (inPackage opts) dir = if inDir opts then lang opts else "" sep = if null pref || null dir then "" else [pathSep]- in pref ++ sep ++ dir + in pref ++ sep ++ dir makefile :: Options -> String makefile opts = makeA where dir = let d = codeDir opts in if null d then "" else d ++ [pathSep] cd c = if null dir then c else "(cd " ++ dir ++ "; " ++ c ++ ")"- makeA = unlines + makeA = unlines [ "all:",- "\tocamlyacc " ++ ocamlyaccFile opts, + "\tocamlyacc " ++ ocamlyaccFile opts, "\tocamllex " ++ ocamllexFile opts, "\t" ++ cd ("latex " ++ basename (latexFile opts)- ++ "; " ++ "dvips " ++ basename (dviFile opts) + ++ "; " ++ "dvips " ++ basename (dviFile opts) ++ " -o " ++ basename (psFile opts)), "\tocamlc -o " ++ mkFile withLang "Test" "" opts +++ utilFile opts +++@@ -168,11 +169,11 @@ mkFile withLang "Par" "mli" opts +++ mkFile withLang "Par" "ml" opts +++ mkFile withLang "Lex" "ml" opts +++- tFile opts, + tFile opts, "", "clean:", "\t-rm -f " ++ unwords (map (dir++) [- "*.log", "*.aux", "*.cmi", + "*.log", "*.aux", "*.cmi", "*.cmo", "*.o", "*.dvi" ]), "\t-rm -f " ++ psFile opts,@@ -196,7 +197,7 @@ utilM :: String-utilM = unlines +utilM = unlines ["(* automatically generated by BNFC *)", "", "open Lexing",
@@ -0,0 +1,207 @@+{-+ BNF Converter: OCaml main file+ Copyright (C) 2005 Author: Kristofer Johannisson++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++-- based on BNFC Haskell backend+++module OCamlTop (makeOCaml) where ++import CF+import CFtoOCamlYacc+import CFtoOCamlLex+import CFtoLatex+import CFtoOCamlAbs+import CFtoOCamlTemplate+import CFtoOCamlPrinter+import CFtoOCamlShow+import CFtoOCamlTest+import CFtoXML+import GetCF+import Utils++import Data.Char+import Data.Maybe (fromMaybe,maybe)+import System.IO+import Control.Monad(when)++-- naming conventions++noLang :: Options -> String -> String+noLang _ name = name++withLang :: Options -> String -> String+withLang opts name = name ++ lang opts++mkMod :: (Options -> String -> String) -> String -> Options -> String+mkMod addLang name opts = + pref ++ if inDir opts then lang opts ++ "." ++ name else addLang opts name+ where pref = maybe "" (++".") (inPackage opts)++mkFile :: (Options -> String -> String) -> String -> String -> Options -> FilePath+mkFile addLang name ext opts = + pref ++ if inDir opts+ then lang opts ++ [pathSep] ++ name ++ ext'+ else addLang opts name ++ if null ext then "" else ext'+ where pref = maybe "" (\p->pkgToDir p++[pathSep]) (inPackage opts)+ ext' = if null ext then "" else "." ++ ext++absFile, absFileM, ocamllexFile, ocamllexFileM, dviFile,+ ocamlyaccFile, ocamlyaccFileM,+ latexFile, utilFile, utilFileM,+ templateFile, templateFileM, + printerFile, printerFileM,+ psFile, tFile, tFileM :: Options -> String+absFile = mkFile withLang "Abs" "ml"+absFileM = mkMod withLang "Abs" +ocamllexFile = mkFile withLang "Lex" "mll"+ocamllexFileM = mkMod withLang "Lex"+ocamlyaccFile = mkFile withLang "Par" "mly"+ocamlyaccFileM = mkMod withLang "Par"+latexFile = mkFile withLang "Doc" "tex"+templateFile = mkFile withLang "Skel" "ml"+templateFileM = mkMod withLang "Skel"+printerFile = mkFile withLang "Print" "ml"+printerFileM = mkMod withLang "Print"+showFile = mkFile withLang "Show" "ml"+showFileM = mkMod withLang "Show"+dviFile = mkFile withLang "Doc" "dvi"+psFile = mkFile withLang "Doc" "ps"+tFile = mkFile withLang "Test" "ml"+tFileM = mkMod withLang "Test"+utilFile = mkFile noLang "BNFC_Util" "ml"+utilFileM = mkMod noLang "BNFC_Util"+xmlFileM = mkMod withLang "XML"++data Options = Options + { + make :: Bool,+ alex1 :: Bool,+ inDir :: Bool,+ shareStrings :: Bool,+ xml :: Int,+ inPackage :: Maybe String,+ lang :: String+ }++-- FIXME: we probably don't need all these arguments+makeOCaml :: Bool -> Bool -> Bool -> Bool -> Bool -> Int + -> Maybe String -- ^ The hierarchical package to put the modules+ -- in, or Nothing.+ -> String -> FilePath -> IO ()+makeOCaml m a1 d ss g x p n file = do+ let opts = Options { make = m, alex1 = a1, inDir = d, shareStrings = ss,+ xml = x, inPackage = p, lang = n }++ absMod = absFileM opts+ lexMod = ocamllexFileM opts+ parMod = ocamlyaccFileM opts+ prMod = printerFileM opts+ showMod = showFileM opts+-- layMod = layoutFileM opts+ utilMod = utilFileM opts+ (cf, isOK) <- tryReadCF file+ if isOK then do+ let dir = codeDir opts+ when (not (null dir)) $ do+ putStrLn $ "Creating directory " ++ dir+ prepareDir dir+ writeFileRep (absFile opts) $ cf2Abstract absMod cf+ writeFileRep (ocamllexFile opts) $ cf2ocamllex lexMod parMod cf+ writeFileRep (ocamlyaccFile opts) $ + cf2ocamlyacc parMod absMod lexMod cf+ writeFileRep (latexFile opts) $ cfToLatex (lang opts) cf+ writeFileRep (templateFile opts) $ cf2Template (templateFileM opts) absMod cf+ writeFileRep (printerFile opts) $ cf2Printer prMod absMod cf+ writeFileRep (showFile opts) $ cf2show showMod absMod cf+ writeFileRep (tFile opts) $ ocamlTestfile absMod lexMod parMod prMod showMod cf+ writeFileRep (utilFile opts) $ utilM + when (make opts) $ writeFileRep "Makefile" $ makefile opts+ case xml opts of+ 2 -> makeXML (lang opts) True cf+ 1 -> makeXML (lang opts) False cf+ _ -> return ()+ putStrLn $ "Done!"+ else do putStrLn $ "Failed!"+ exitFailure++pkgToDir :: String -> FilePath+pkgToDir s = replace '.' pathSep s++codeDir :: Options -> FilePath+codeDir opts = let pref = maybe "" pkgToDir (inPackage opts)+ dir = if inDir opts then lang opts else ""+ sep = if null pref || null dir then "" else [pathSep]+ in pref ++ sep ++ dir ++makefile :: Options -> String+makefile opts = makeA where+ dir = let d = codeDir opts in if null d then "" else d ++ [pathSep]+ cd c = if null dir then c else "(cd " ++ dir ++ "; " ++ c ++ ")"+ makeA = unlines + [+ "all:",+ "\tocamlyacc " ++ ocamlyaccFile opts, + "\tocamllex " ++ ocamllexFile opts,+ "\t" ++ cd ("latex " ++ basename (latexFile opts)+ ++ "; " ++ "dvips " ++ basename (dviFile opts) + ++ " -o " ++ basename (psFile opts)),+ "\tocamlc -o " ++ mkFile withLang "Test" "" opts ++++ utilFile opts ++++ absFile opts +++ templateFile opts ++++ showFile opts +++ printerFile opts ++++ mkFile withLang "Par" "mli" opts ++++ mkFile withLang "Par" "ml" opts ++++ mkFile withLang "Lex" "ml" opts ++++ tFile opts, + "",+ "clean:",+ "\t-rm -f " ++ unwords (map (dir++) [+ "*.log", "*.aux", "*.cmi", + "*.cmo", "*.o", "*.dvi"+ ]),+ "\t-rm -f " ++ psFile opts,+ "",+ "distclean: clean",+ "\t-rm -f " ++ unwords [+ mkFile withLang "Doc" "*" opts,+ mkFile withLang "Lex" "*" opts,+ mkFile withLang "Par" "*" opts,+ mkFile withLang "Layout" "*" opts,+ mkFile withLang "Skel" "*" opts,+ mkFile withLang "Print" "*" opts,+ mkFile withLang "Show" "*" opts,+ mkFile withLang "Test" "*" opts,+ mkFile withLang "Abs" "*" opts,+ mkFile withLang "Test" "" opts,+ utilFile opts,+ "Makefile*"+ ]+ ]+++utilM :: String+utilM = unlines + ["(* automatically generated by BNFC *)",+ "",+ "open Lexing",+ "",+ "(* this should really be in the parser, but ocamlyacc won't put it in the .mli *)",+ "exception Parse_error of Lexing.position * Lexing.position"+ ]+
@@ -21,7 +21,7 @@ import CF import Utils-import Char (toLower, toUpper)+import Data.Char (toLower, toUpper) -- Translate Haskell types to OCaml types -- Note: OCaml (data-)types start with lowercase letter
@@ -25,8 +25,8 @@ import CF --import Lexer-import List (intersperse)-import Char+import Data.List (intersperse)+import Data.Char -- Type declarations
@@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -} -module ProfileTop (makeAllProfile) where +module ProfileTop (makeAllProfile) where -- import Utils import CF@@ -32,25 +32,26 @@ ---- import CFtoLayout ---- import CFtoXML -- import CFtoGF ( cf2AbsGF, cf2ConcGF )--- import System+-- import System.IO import GetCF import Utils -import Char-import System-import Monad(when)+import Data.Char+import System.IO+import System.Exit+import Control.Monad(when) -- naming conventions nameMod :: String -> Bool -> String -> FilePath nameMod name inDir lang =- if inDir - then lang ++ "." ++ name - else name ++ lang + if inDir+ then lang ++ "." ++ name+ else name ++ lang nameFile :: String -> String -> Bool -> String -> FilePath-nameFile name ext inDir lang = - if inDir +nameFile name ext inDir lang =+ if inDir then lang ++ "/" ++ name ++ "." ++ ext else name ++ lang ++ "." ++ ext @@ -58,12 +59,12 @@ gfAbs, gfConc, happyFile, happyFileM, latexFile, errFile, errFileM,- templateFile, templateFileM, + templateFile, templateFileM, printerFile, printerFileM,- layoutFile, layoutFileM, + layoutFile, layoutFileM, psFile, tFile, tFileM, mFile :: Bool -> String -> FilePath absFile = nameFile "Abs" "hs"-absFileM = nameMod "Abs" +absFileM = nameMod "Abs" alexFile = nameFile "Lex" "x" alexFileM = nameMod "Lex" happyFile = nameFile "Par" "y"@@ -103,25 +104,25 @@ ---- writeFileRep (absFile inDir name) $ cf2Abstract (absFileM inDir name) cf if (alex1) then do writeFileRep (alexFile inDir name) $ cf2alex lexMod errMod cf- putStrLn " (Use Alex 1.1 to compile.)" + putStrLn " (Use Alex 1.1 to compile.)" else do writeFileRep (alexFile inDir name) $ cf2alex2 lexMod errMod "" False False cf putStrLn " (Use Alex 2.0 to compile.)"- writeFileRep (happyFile inDir name) $ + writeFileRep (happyFile inDir name) $ cf2HappyProfileS parMod absMod lexMod errMod cfp putStrLn " (Tested with Happy 1.13)" writeFileRep (latexFile inDir name) $ cfToLatex name cf----- writeFileRep (templateFile inDir name) $ +---- writeFileRep (templateFile inDir name) $ ---- cf2Template tplMod absMod errMod cf ---- writeFileRep (printerFile inDir name) $ cf2Printer prMod absMod cf----- if hasLayout cf then +---- if hasLayout cf then ---- writeFileRep (layoutFile inDir name) $ cf2Layout alex1 inDir layMod lexMod cf ---- else return () writeFileRep (tFile inDir name) $ testfile inDir name (xml>0) cf writeFileRep (errFile inDir name) $ errM errMod cf- if make - then (writeFileRep (mFile inDir name) $ makefile inDir name) - else return () + if make+ then (writeFileRep (mFile inDir name) $ makefile inDir name)+ else return () ---- case xml of ---- 2 -> makeXML name True cf ---- 1 -> makeXML name False cf@@ -133,16 +134,16 @@ makefile :: Bool -> String -> String makefile inDir name = makeA where name' = if inDir then "" else name -- Makefile is inDir- ghcCommand = "ghc --make "++ tFile inDir name ++ " -o " ++ + ghcCommand = "ghc --make "++ tFile inDir name ++ " -o " ++ if inDir then name ++ "/" ++ "Test" else "Test" ++ name- makeA = unlines + makeA = unlines [- "all:", - "\thappy -gca " ++ happyFile False name', + "all:",+ "\thappy -gca " ++ happyFile False name', "\talex " ++ alexFile False name', "\tlatex " ++ latexFile False name', "\tdvips " ++ dviFile False name' ++ " -o " ++ psFile False name',- "\t" ++ if inDir then + "\t" ++ if inDir then "(" ++ "cd ..; " ++ ghcCommand ++ ")" else ghcCommand, "clean:",@@ -163,11 +164,11 @@ ---- "Skel" ++ name ++ ".*", ---- "Print" ++ name ++ ".*", "Test" ++ name ++ ".*",----- "Abs" ++ name ++ ".*", +---- "Abs" ++ name ++ ".*", "Test" ++ name, "ErrM.*", ---- name ++ ".dtd",----- "XML" ++ name ++ ".*", +---- "XML" ++ name ++ ".*", "Makefile*" ] ]@@ -176,7 +177,7 @@ testfile :: Bool -> String -> Bool -> CF -> String testfile inDir name xml cf = makeA where - makeA = let lay = hasLayout cf + makeA = let lay = hasLayout cf xpr = if xml then "XPrint a, " else "" in unlines ["-- automatically generated by BNF Converter",@@ -184,8 +185,8 @@ "", "import Trees", "import Profile",- "import IO ( stdin, hGetContents )",- "import System ( getArgs, getProgName )",+ "import System.IO ( stdin, hGetContents )",+ "import System.IO ( getArgs, getProgName )", "", "import " ++ alexFileM inDir name, "import " ++ happyFileM inDir name,@@ -198,7 +199,7 @@ "", "type ParseFun = [Token] -> Err CFTree", "",- "myLLexer = " ++ if lay then "resolveLayout True . myLexer" + "myLLexer = " ++ if lay then "resolveLayout True . myLexer" else "myLexer", "", "runFile :: ParseFun -> FilePath -> IO ()",@@ -211,11 +212,11 @@ " case etree of", " Ok tree -> do", " case postParse tree of",- " Bad s -> do", + " Bad s -> do", " putStrLn \"\\nParse Failed... CFTree:\\n\"", " putStrLn $ prCFTree tree", " putStrLn s",- " Ok tree -> do", + " Ok tree -> do", " putStrLn \"\\nParse Successful!\"", " putStrLn $ \"\\n[Abstract Syntax]\\n\\n\" ++ prt tree", " Bad s -> do",
@@ -0,0 +1,234 @@+{-+ BNF Converter: Haskell main file+ Copyright (C) 2004 Author: Markus Forberg, Peter Gammie, Aarne Ranta++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++module ProfileTop (makeAllProfile) where ++-- import Utils+import CF+import CFtoHappyProfile+import CFtoAlex+import CFtoAlex2+import CFtoLatex+import MkErrM+---- import CFtoAbstract+---- import CFtoTemplate+---- import CFtoPrinter+---- import CFtoLayout+---- import CFtoXML+-- import CFtoGF ( cf2AbsGF, cf2ConcGF )+-- import System.IO+import GetCF+import Utils++import Data.Char+import System.IO+import Control.Monad(when)++-- naming conventions++nameMod :: String -> Bool -> String -> FilePath+nameMod name inDir lang =+ if inDir + then lang ++ "." ++ name + else name ++ lang ++nameFile :: String -> String -> Bool -> String -> FilePath+nameFile name ext inDir lang = + if inDir + then lang ++ "/" ++ name ++ "." ++ ext+ else name ++ lang ++ "." ++ ext++absFile, absFileM, alexFile, alexFileM, dviFile,+ gfAbs, gfConc,+ happyFile, happyFileM,+ latexFile, errFile, errFileM,+ templateFile, templateFileM, + printerFile, printerFileM,+ layoutFile, layoutFileM, + psFile, tFile, tFileM, mFile :: Bool -> String -> FilePath+absFile = nameFile "Abs" "hs"+absFileM = nameMod "Abs" +alexFile = nameFile "Lex" "x"+alexFileM = nameMod "Lex"+happyFile = nameFile "Par" "y"+happyFileM = nameMod "Par"+latexFile = nameFile "Doc" "tex"+templateFile = nameFile "Skel" "hs"+templateFileM = nameMod "Skel"+printerFile = nameFile "Print" "hs"+printerFileM = nameMod "Print"+dviFile = nameFile "Doc" "dvi"+psFile = nameFile "Doc" "ps"+gfAbs = nameFile "" "Abs.gf"+gfConc = nameFile "" "Conc.gf"+tFile = nameFile "Test" "hs"+tFileM = nameMod "Test"+mFile inDir n = if inDir then n ++ "/" ++ "Makefile" else "Makefile"+errFile b n = if b then n ++ "/" ++ "ErrM.hs" else "ErrM.hs"+errFileM b n = if b then n ++ "." ++ "ErrM" else "ErrM"+layoutFileM = nameMod "Layout"+xmlFileM = nameMod "XML"+layoutFile = nameFile "Layout" "hs"++makeAllProfile :: Bool -> Bool -> Bool -> Int -> String -> FilePath -> IO ()+makeAllProfile make alex1 inDir xml name file = do+ let absMod = absFileM inDir name+ lexMod = alexFileM inDir name+ parMod = happyFileM inDir name+ prMod = printerFileM inDir name+ layMod = layoutFileM inDir name+ tplMod = templateFileM inDir name+ errMod = errFileM inDir name+ (cfp, isOK) <- tryReadCFP file+ let cf = cfp2cf cfp+ if isOK then do++ when inDir (prepareDir name)+---- writeFileRep (absFile inDir name) $ cf2Abstract (absFileM inDir name) cf+ if (alex1) then do+ writeFileRep (alexFile inDir name) $ cf2alex lexMod errMod cf+ putStrLn " (Use Alex 1.1 to compile.)" + else do+ writeFileRep (alexFile inDir name) $ cf2alex2 lexMod errMod "" False False cf+ putStrLn " (Use Alex 2.0 to compile.)"+ writeFileRep (happyFile inDir name) $ + cf2HappyProfileS parMod absMod lexMod errMod cfp+ putStrLn " (Tested with Happy 1.13)"+ writeFileRep (latexFile inDir name) $ cfToLatex name cf+---- writeFileRep (templateFile inDir name) $ +---- cf2Template tplMod absMod errMod cf+---- writeFileRep (printerFile inDir name) $ cf2Printer prMod absMod cf+---- if hasLayout cf then +---- writeFileRep (layoutFile inDir name) $ cf2Layout alex1 inDir layMod lexMod cf+---- else return ()+ writeFileRep (tFile inDir name) $ testfile inDir name (xml>0) cf+ writeFileRep (errFile inDir name) $ errM errMod cf+ if make + then (writeFileRep (mFile inDir name) $ makefile inDir name) + else return () +---- case xml of+---- 2 -> makeXML name True cf+---- 1 -> makeXML name False cf+---- _ -> return ()+---- putStrLn $ "Done!"+ else do putStrLn $ "Failed!"+ exitFailure++makefile :: Bool -> String -> String+makefile inDir name = makeA where+ name' = if inDir then "" else name -- Makefile is inDir+ ghcCommand = "ghc --make "++ tFile inDir name ++ " -o " ++ + if inDir then name ++ "/" ++ "Test" else "Test" ++ name+ makeA = unlines + [+ "all:", + "\thappy -gca " ++ happyFile False name', + "\talex " ++ alexFile False name',+ "\tlatex " ++ latexFile False name',+ "\tdvips " ++ dviFile False name' ++ " -o " ++ psFile False name',+ "\t" ++ if inDir then + "(" ++ "cd ..; " ++ ghcCommand ++ ")"+ else ghcCommand,+ "clean:",+ "\t rm -f " ++ unwords [+ "*.log *.aux *.hi *.o *.dvi",+ psFile False name',+ "*.o"+ ],+ "distclean: " ++ if inDir then "" else "clean",+ if inDir then+ "\t rm -rf ../" ++ name -- erase this directory!+ else+ "\t rm -f " ++ unwords [+ "Doc" ++ name ++ ".*",+ "Lex" ++ name ++ ".*",+ "Par" ++ name ++ ".*",+---- "Layout" ++ name ++ ".*",+---- "Skel" ++ name ++ ".*",+---- "Print" ++ name ++ ".*",+ "Test" ++ name ++ ".*",+---- "Abs" ++ name ++ ".*", + "Test" ++ name,+ "ErrM.*",+---- name ++ ".dtd",+---- "XML" ++ name ++ ".*", + "Makefile*"+ ]+ ]+++testfile :: Bool -> String -> Bool -> CF -> String+testfile inDir name xml cf = makeA where++ makeA = let lay = hasLayout cf + xpr = if xml then "XPrint a, " else ""+ in unlines+ ["-- automatically generated by BNF Converter",+ "module Main where\n",+ "",+ "import Trees",+ "import Profile",+ "import System.IO ( stdin, hGetContents )",+ "import System.IO ( getArgs, getProgName )",+ "",+ "import " ++ alexFileM inDir name,+ "import " ++ happyFileM inDir name,+---- "import " ++ templateFileM inDir name,+---- "import " ++ printerFileM inDir name,+---- "import " ++ absFileM inDir name,+---- if lay then ("import " ++ layoutFileM inDir name) else "",+---- if xml then ("import " ++ xmlFileM inDir name) else "",+ "import " ++ errFileM inDir name,+ "",+ "type ParseFun = [Token] -> Err CFTree",+ "",+ "myLLexer = " ++ if lay then "resolveLayout True . myLexer" + else "myLexer",+ "",+ "runFile :: ParseFun -> FilePath -> IO ()",+ "runFile p f = readFile f >>= run p",+ "",+ "run :: ParseFun -> String -> IO ()",+ "run p s = do",+ " let ts = myLLexer s",+ " let etree = p ts",+ " case etree of",+ " Ok tree -> do",+ " case postParse tree of",+ " Bad s -> do", + " putStrLn \"\\nParse Failed... CFTree:\\n\"",+ " putStrLn $ prCFTree tree",+ " putStrLn s",+ " Ok tree -> do", + " putStrLn \"\\nParse Successful!\"",+ " putStrLn $ \"\\n[Abstract Syntax]\\n\\n\" ++ prt tree",+ " Bad s -> do",+ " putStrLn s",+ " putStrLn \"\\nParse failed... tokenization:\"",+ " print ts",+ "",+ "main :: IO ()",+ "main = do args <- getArgs",+ " case args of",+ " [] -> hGetContents stdin >>= run " ++ firstParser,+ " [f] -> runFile " ++ firstParser ++ " f",+ " _ -> do progName <- getProgName",+ " putStrLn $ progName ++ \": excess arguments.\""+ ]+ where firstParser = 'p' : firstEntry cf
@@ -24,8 +24,8 @@ import GetCF (writeFileRep) import Utils import CFtoTemplate-import List (intersperse, nub)-import Char(toLower)+import Data.List (intersperse, nub)+import Data.Char(toLower) type Coding = Bool ---- change to at least three values @@ -136,7 +136,7 @@ "module " ++ absMod +++ "where\n", "-- pretty-printer generated by the BNF converter\n", "import Abs" ++ name,- "import Char",+ "import Data.Char", "", "-- the top-level printing method", "printXML :: XPrint a => a -> String",