Changeset 8675
- Timestamp:
- 01/15/06 08:26:19 (3 years ago)
- Files:
-
- 3 added
- 10 modified
-
Pugs.cabal.in (modified) (2 diffs)
-
src/Data/Yaml/Syck.hsc (modified) (5 diffs)
-
src/DrIFT/RuleYAML.hs (added)
-
src/DrIFT/UserRules.hs (modified) (2 diffs)
-
src/DrIFT/YAML.hs (added)
-
src/Pugs/CodeGen.hs (modified) (3 diffs)
-
src/Pugs/CodeGen/PIL2.hs (modified) (3 diffs)
-
src/Pugs/CodeGen/YAML.hs (added)
-
src/Pugs/PIL1.hs (modified) (21 diffs)
-
src/Pugs/PIL1.hs-drift (modified) (4 diffs)
-
src/Pugs/PIL2.hs (modified) (23 diffs)
-
src/Pugs/PIL2.hs-drift (modified) (4 diffs)
-
src/Pugs/Prim/Yaml.hs (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Pugs.cabal.in
r8653 r8675 12 12 author: Audrey Tang <autrijus@autrijus.org> 13 13 tested-with: GHC -any 14 exposed-modules: Pugs Pugs.AST Pugs.AST.Internals Pugs.AST.Pad Pugs.AST.Pos Pugs.AST.Prag Pugs.AST.SIO Pugs.AST.Scope Pugs.Bind Pugs.CodeGen Pugs.CodeGen.Binary Pugs.CodeGen.JSON Pugs.CodeGen.PIL1 Pugs.CodeGen.PIL2 Pugs.CodeGen.PIR Pugs.CodeGen.PIR.Prelude Pugs.CodeGen.Perl5 Pugs.Co mpat Pugs.Compile Pugs.Compile.PIL2 Pugs.Compile.Haskell Pugs.Compile.Pugs Pugs.Config Pugs.Cont Pugs.DeepSeq Pugs.Embed Pugs.Embed.Haskell Pugs.Embed.Parrot Pugs.Embed.Perl5 Pugs.Embed.Pugs Pugs.Eval Pugs.Eval.Var Pugs.External Pugs.External.Haskell Pugs.Help Pugs.Internals Pugs.Junc Pugs.Lexer Pugs.Monads Pugs.PIL1 Pugs.PIL2 Pugs.Parser Pugs.Parser.Number Pugs.Parser.Program Pugs.Parser.Types Pugs.Parser.Unsafe Pugs.Parser.Export Pugs.Pretty Pugs.Prim Pugs.Prim.Code Pugs.Prim.Eval Pugs.Prim.FileTest Pugs.Prim.Keyed Pugs.Prim.Lifts Pugs.Prim.List Pugs.Prim.Match Pugs.Prim.Numeric Pugs.Prim.Param Pugs.Prim.Yaml Pugs.Rule Pugs.Rule.Char Pugs.Rule.Combinator Pugs.Rule.Error Pugs.Rule.Expr Pugs.Rule.Language Pugs.Rule.Pos Pugs.Rule.Prim Pugs.Rule.Token Pugs.Run Pugs.Run.Args Pugs.Run.Perl5 Pugs.Shell Pugs.Types Pugs.Version Emit.Common Emit.PIR14 exposed-modules: Pugs Pugs.AST Pugs.AST.Internals Pugs.AST.Pad Pugs.AST.Pos Pugs.AST.Prag Pugs.AST.SIO Pugs.AST.Scope Pugs.Bind Pugs.CodeGen Pugs.CodeGen.Binary Pugs.CodeGen.JSON Pugs.CodeGen.PIL1 Pugs.CodeGen.PIL2 Pugs.CodeGen.PIR Pugs.CodeGen.PIR.Prelude Pugs.CodeGen.Perl5 Pugs.CodeGen.YAML Pugs.Compat Pugs.Compile Pugs.Compile.PIL2 Pugs.Compile.Haskell Pugs.Compile.Pugs Pugs.Config Pugs.Cont Pugs.DeepSeq Pugs.Embed Pugs.Embed.Haskell Pugs.Embed.Parrot Pugs.Embed.Perl5 Pugs.Embed.Pugs Pugs.Eval Pugs.Eval.Var Pugs.External Pugs.External.Haskell Pugs.Help Pugs.Internals Pugs.Junc Pugs.Lexer Pugs.Monads Pugs.PIL1 Pugs.PIL2 Pugs.Parser Pugs.Parser.Number Pugs.Parser.Program Pugs.Parser.Types Pugs.Parser.Unsafe Pugs.Parser.Export Pugs.Pretty Pugs.Prim Pugs.Prim.Code Pugs.Prim.Eval Pugs.Prim.FileTest Pugs.Prim.Keyed Pugs.Prim.Lifts Pugs.Prim.List Pugs.Prim.Match Pugs.Prim.Numeric Pugs.Prim.Param Pugs.Prim.Yaml Pugs.Rule Pugs.Rule.Char Pugs.Rule.Combinator Pugs.Rule.Error Pugs.Rule.Expr Pugs.Rule.Language Pugs.Rule.Pos Pugs.Rule.Prim Pugs.Rule.Token Pugs.Run Pugs.Run.Args Pugs.Run.Perl5 Pugs.Shell Pugs.Types Pugs.Version Emit.Common Emit.PIR 15 15 buildable: True 16 16 c-sources: src/cbits/fpstring.c src/pcre/pcre.c __UNICODE_C__ … … 23 23 include-dirs: __INCLUDE_DIRS__ 24 24 hs-source-dir: src 25 other-modules: Data.FastPackedString Data.DeepSeq Data.Yaml.Syck DrIFT.Binary DrIFT.JSON DrIFT.Perl5 RRegex RRegex.PCRE RRegex.Syntax System.FilePath UTF8 Unicode25 other-modules: Data.FastPackedString Data.DeepSeq Data.Yaml.Syck DrIFT.Binary DrIFT.JSON DrIFT.Perl5 DrIFT.YAML RRegex RRegex.PCRE RRegex.Syntax System.FilePath UTF8 Unicode 26 26 ghc-options: __OPTIONS__ -
src/Data/Yaml/Syck.hsc
r8608 r8675 5 5 module Data.Yaml.Syck ( 6 6 parseYaml, emitYaml, 7 YamlNode(..), YamlElem(..), emptyYamlNode, tagNode7 YamlNode(..), YamlElem(..), tagNode, nilNode, mkNode, mkTagNode, 8 8 ) where 9 9 … … 58 58 deriving (Show, Ord, Eq, Enum) 59 59 60 emptyYamlNode :: YamlNode61 emptyYamlNode = MkYamlNode 0 YamlNil Nothing Nothing Nothing60 nilNode :: YamlNode 61 nilNode = MkYamlNode 0 YamlNil Nothing Nothing Nothing 62 62 63 63 tagNode :: YamlTag -> YamlNode -> YamlNode 64 64 tagNode _ MkYamlNode{tag=Just x} = error ("can't add tag: already tagged with" ++ x) 65 65 tagNode tag node = node{tag = tag} 66 67 mkNode :: YamlElem -> YamlNode 68 mkNode x = MkYamlNode 0 x Nothing Nothing Nothing 69 70 mkTagNode :: String -> YamlElem -> YamlNode 71 mkTagNode s x = MkYamlNode 0 x (Just s) Nothing Nothing 66 72 67 73 -- the extra commas here are not a bug … … 217 223 val <- readNode parser valId 218 224 return (key, val) 219 return $ emptyYamlNode{ el = YamlMap pairs, tag = tag}225 return $ nilNode{ el = YamlMap pairs, tag = tag} 220 226 221 227 parseNode SyckSeq parser syckNode len = do … … 224 230 symId <- syck_seq_read syckNode idx 225 231 readNode parser symId 226 return $ emptyYamlNode{ el = YamlSeq nodes, tag = tag }232 return $ nilNode{ el = YamlSeq nodes, tag = tag } 227 233 228 234 parseNode SyckStr _ syckNode len = do … … 230 236 cstr <- syck_str_read syckNode 231 237 str <- peekCStringLen (cstr, fromEnum len) 232 return $ emptyYamlNode{ el = YamlStr str, tag = tag }238 return $ nilNode{ el = YamlStr str, tag = tag } 233 239 234 240 foreign import ccall "wrapper" -
src/DrIFT/UserRules.hs
r6257 r8675 9 9 import UserRuleGhcBinary 10 10 import qualified RulePerl5 11 import qualified RuleYAML 11 12 import qualified RuleJSON 12 13 import qualified RuleUtility … … 17 18 -- add your rules to this list 18 19 userRules :: [RuleDef] 19 userRules = userRulesXml ++ userRulesBinary ++ userRulesGeneric ++ userRulesGhcBinary ++ RuleUtility.rules ++ RuleFunctorM.rules ++ RuleMonoid.rules ++ RulePerl5.rules ++ RuleJSON.rules 20 userRules = userRulesXml ++ userRulesBinary ++ userRulesGeneric ++ userRulesGhcBinary ++ RuleUtility.rules ++ RuleFunctorM.rules ++ RuleMonoid.rules ++ RulePerl5.rules ++ RuleJSON.rules ++ RuleYAML.rules 20 21 -
src/Pugs/CodeGen.hs
r7867 r8675 14 14 import Pugs.Internals 15 15 import Pugs.CodeGen.PIL1 (genPIL1) 16 import Pugs.CodeGen.PIL2 (genPIL2, genPIL2Perl5, genPIL2Binary, genPIL2JSON )16 import Pugs.CodeGen.PIL2 (genPIL2, genPIL2Perl5, genPIL2Binary, genPIL2JSON, genPIL2YAML) 17 17 import Pugs.CodeGen.PIR (genPIR) 18 18 import Pugs.CodeGen.Perl5 (genPerl5) 19 import Pugs.CodeGen.YAML (genYAML) 19 20 import Pugs.CodeGen.JSON (genJSON) 20 21 import Pugs.CodeGen.Binary (genBinary) … … 34 35 , ("PIL1-Binary", genBinary) 35 36 , ("PIL1-JSON", genJSON) 37 , ("PIL1-YAML", genYAML) 36 38 , ("PIL2", genPIL2) 37 39 , ("PIL2-Perl5", genPIL2Perl5) 38 40 , ("PIL2-JSON", genPIL2JSON) 41 , ("PIL2-YAML", genPIL2YAML) 39 42 , ("PIL2-Binary", genPIL2Binary) 40 43 , ("Pugs", genPugs) … … 57 60 norm' "binary" = "!PIL1-Binary" 58 61 norm' "json" = "!PIL1-JSON" 62 norm' "yaml" = "!PIL1-YAML" 59 63 norm' "pil1perl5" = "PIL1-Perl5" 60 64 norm' "pil1json" = "PIL1-JSON" 65 norm' "pil1yaml" = "PIL1-YAML" 61 66 norm' "pil1binary" = "PIL1-Binary" 62 67 norm' "pil2perl5" = "PIL2-Perl5" 63 68 norm' "pil2json" = "PIL2-JSON" 69 norm' "pil2yaml" = "PIL2-YAML" 64 70 norm' "pil2binary" = "PIL2-Binary" 65 71 norm' "pugs" = "Pugs" -
src/Pugs/CodeGen/PIL2.hs
r7866 r8675 4 4 module Pugs.CodeGen.PIL2 ( 5 5 genPIL2, 6 genPIL2Perl5, genPIL2Binary, genPIL2JSON 6 genPIL2Perl5, genPIL2Binary, genPIL2JSON, genPIL2YAML 7 7 ) where 8 8 import Pugs.Internals … … 15 15 import DrIFT.Binary 16 16 import DrIFT.JSON 17 import DrIFT.YAML 17 18 18 19 genPIL2 :: Eval Val … … 46 47 penv <- compile () :: Eval PIL_Environment 47 48 return . VStr . unlines $ [showJSON penv] 49 50 genPIL2YAML :: Eval Val 51 genPIL2YAML = do 52 penv <- compile () :: Eval PIL_Environment 53 yaml <- liftIO (showYaml penv) 54 return . VStr . unlines $ [yaml] -
src/Pugs/PIL1.hs
r7862 r8675 25 25 import Emit.PIR 26 26 import DrIFT.Perl5 27 import DrIFT.YAML 27 28 import DrIFT.Binary 28 29 import DrIFT.JSON … … 31 32 -- {-! global : Haskell2Xml !-} 32 33 33 {-! global : GhcBinary, Perl5, JSON !-}34 {-! global : GhcBinary, Perl5, JSON, YAML !-} 34 35 35 36 {-| … … 133 134 put_ _ _ = return () 134 135 get _ = return Noop 136 instance YAML Exp where 137 asYAML _ = asYAML () 135 138 instance Perl5 Exp where 136 139 showPerl5 _ = "(undef)" … … 139 142 140 143 -- Non-canonical serialization... needs work 144 instance (Show (TVar a)) => YAML (TVar a) where 145 asYAML _ = asYAML () 141 146 instance (Show (TVar a)) => Perl5 (TVar a) where 142 147 showPerl5 _ = "(warn '<ref>')" … … 162 167 showJSON (PIL_Environment aa ab) = showJSHashObj "PIL_Environment" 163 168 [("pilGlob", showJSON aa) , ("pilMain", showJSON ab)] 169 170 instance YAML PIL_Environment where 171 asYAML (PIL_Environment aa ab) = asYAMLmap "PIL_Environment" 172 [("pilGlob", asYAML aa) , ("pilMain", asYAML ab)] 164 173 165 174 instance Binary PIL_Stmts where … … 207 216 ("pStmts", showJSON ac)] 208 217 218 instance YAML PIL_Stmts where 219 asYAML (PNil) = asYAMLcls "PNil" 220 asYAML (PStmts aa ab) = asYAMLmap "PStmts" 221 [("pStmt", asYAML aa) , ("pStmts", asYAML ab)] 222 asYAML (PPad aa ab ac) = asYAMLmap "PPad" 223 [("pScope", asYAML aa) , ("pSyms", asYAML ab) , 224 ("pStmts", asYAML ac)] 225 209 226 instance Binary PIL_Stmt where 210 227 put_ bh PNoop = do … … 248 265 [("pPos", showJSON aa) , ("pExp", showJSON ab) , 249 266 ("pNode", showJSON ac)] 267 268 instance YAML PIL_Stmt where 269 asYAML (PNoop) = asYAMLcls "PNoop" 270 asYAML (PStmt aa) = asYAMLmap "PStmt" [("pExpr", asYAML aa)] 271 asYAML (PPos aa ab ac) = asYAMLmap "PPos" 272 [("pPos", asYAML aa) , ("pExp", asYAML ab) , ("pNode", asYAML ac)] 250 273 251 274 instance Binary PIL_Expr where … … 317 340 ("pBody", showJSON ae)] 318 341 342 instance YAML PIL_Expr where 343 asYAML (PRawName aa) = asYAMLmap "PRawName" 344 [("pRawName", asYAML aa)] 345 asYAML (PExp aa) = asYAMLmap "PExp" [("pLV", asYAML aa)] 346 asYAML (PLit aa) = asYAMLmap "PLit" [("pLit", asYAML aa)] 347 asYAML (PThunk aa) = asYAMLmap "PThunk" [("pThunk", asYAML aa)] 348 asYAML (PCode aa ab ac ad ae) = asYAMLmap "PCode" 349 [("pType", asYAML aa) , ("pParams", asYAML ab) , 350 ("pLValue", asYAML ac) , ("pIsMulti", asYAML ad) , 351 ("pBody", asYAML ae)] 352 319 353 instance Binary PIL_Decl where 320 354 put_ bh (PSub aa ab ac ad ae af) = do … … 346 380 ("pSubIsMulti", showJSON ae) , ("pSubBody", showJSON af)] 347 381 382 instance YAML PIL_Decl where 383 asYAML (PSub aa ab ac ad ae af) = asYAMLmap "PSub" 384 [("pSubName", asYAML aa) , ("pSubType", asYAML ab) , 385 ("pSubParams", asYAML ac) , ("pSubLValue", asYAML ad) , 386 ("pSubIsMulti", asYAML ae) , ("pSubBody", asYAML af)] 387 348 388 instance Binary PIL_Literal where 349 389 put_ bh (PVal aa) = do … … 358 398 instance JSON PIL_Literal where 359 399 showJSON (PVal aa) = showJSHashObj "PVal" [("pVal", showJSON aa)] 400 401 instance YAML PIL_Literal where 402 asYAML (PVal aa) = asYAMLmap "PVal" [("pVal", asYAML aa)] 360 403 361 404 instance Binary PIL_LValue where … … 421 464 [("pLHS", showJSON aa) , ("pRHS", showJSON ab)] 422 465 466 instance YAML PIL_LValue where 467 asYAML (PVar aa) = asYAMLmap "PVar" [("pVarName", asYAML aa)] 468 asYAML (PApp aa ab ac ad) = asYAMLmap "PApp" 469 [("pCxt", asYAML aa) , ("pFun", asYAML ab) , ("pInv", asYAML ac) , 470 ("pArgs", asYAML ad)] 471 asYAML (PAssign aa ab) = asYAMLmap "PAssign" 472 [("pLHS", asYAML aa) , ("pRHS", asYAML ab)] 473 asYAML (PBind aa ab) = asYAMLmap "PBind" 474 [("pLHS", asYAML aa) , ("pRHS", asYAML ab)] 475 423 476 instance Binary TParam where 424 477 put_ bh (MkTParam aa ab) = do … … 437 490 showJSON (MkTParam aa ab) = showJSHashObj "MkTParam" 438 491 [("tpParam", showJSON aa) , ("tpDefault", showJSON ab)] 492 493 instance YAML TParam where 494 asYAML (MkTParam aa ab) = asYAMLmap "MkTParam" 495 [("tpParam", asYAML aa) , ("tpDefault", asYAML ab)] 439 496 440 497 instance Binary TCxt where … … 491 548 showJSON (TTailCall aa) = showJSArrayObj "TTailCall" [showJSON aa] 492 549 550 instance YAML TCxt where 551 asYAML (TCxtVoid) = asYAMLcls "TCxtVoid" 552 asYAML (TCxtLValue aa) = asYAMLseq "TCxtLValue" [asYAML aa] 553 asYAML (TCxtItem aa) = asYAMLseq "TCxtItem" [asYAML aa] 554 asYAML (TCxtSlurpy aa) = asYAMLseq "TCxtSlurpy" [asYAML aa] 555 asYAML (TTailCall aa) = asYAMLseq "TTailCall" [asYAML aa] 556 493 557 instance Binary TEnv where 494 558 put_ bh (MkTEnv aa ab ac ad ae) = do … … 517 581 ("tCxt", showJSON ac) , ("tReg", showJSON ad) , 518 582 ("tLabel", showJSON ae)] 583 584 instance YAML TEnv where 585 asYAML (MkTEnv aa ab ac ad ae) = asYAMLmap "MkTEnv" 586 [("tLexDepth", asYAML aa) , ("tTokDepth", asYAML ab) , 587 ("tCxt", asYAML ac) , ("tReg", asYAML ad) , ("tLabel", asYAML ae)] 519 588 520 589 instance Binary Scope where … … 563 632 showJSON (STemp) = showJSScalar "STemp" 564 633 showJSON (SGlobal) = showJSScalar "SGlobal" 634 635 instance YAML Scope where 636 asYAML (SState) = asYAMLcls "SState" 637 asYAML (SMy) = asYAMLcls "SMy" 638 asYAML (SOur) = asYAMLcls "SOur" 639 asYAML (SLet) = asYAMLcls "SLet" 640 asYAML (STemp) = asYAMLcls "STemp" 641 asYAML (SGlobal) = asYAMLcls "SGlobal" 565 642 566 643 instance Binary SubType where … … 615 692 showJSON (SubPointy) = showJSScalar "SubPointy" 616 693 showJSON (SubPrim) = showJSScalar "SubPrim" 694 695 instance YAML SubType where 696 asYAML (SubMethod) = asYAMLcls "SubMethod" 697 asYAML (SubCoroutine) = asYAMLcls "SubCoroutine" 698 asYAML (SubMacro) = asYAMLcls "SubMacro" 699 asYAML (SubRoutine) = asYAMLcls "SubRoutine" 700 asYAML (SubBlock) = asYAMLcls "SubBlock" 701 asYAML (SubPointy) = asYAMLcls "SubPointy" 702 asYAML (SubPrim) = asYAMLcls "SubPrim" 617 703 618 704 instance Binary Val where … … 688 774 showJSON (VType aa) = showJSArrayObj "VType" [showJSON aa] 689 775 776 instance YAML Val where 777 asYAML (VUndef) = asYAMLcls "VUndef" 778 asYAML (VBool aa) = asYAMLseq "VBool" [asYAML aa] 779 asYAML (VInt aa) = asYAMLseq "VInt" [asYAML aa] 780 asYAML (VRat aa) = asYAMLseq "VRat" [asYAML aa] 781 asYAML (VNum aa) = asYAMLseq "VNum" [asYAML aa] 782 asYAML (VStr aa) = asYAMLseq "VStr" [asYAML aa] 783 asYAML (VList aa) = asYAMLseq "VList" [asYAML aa] 784 asYAML (VType aa) = asYAMLseq "VType" [asYAML aa] 785 690 786 instance Binary Cxt where 691 787 put_ bh CxtVoid = do … … 720 816 showJSON (CxtItem aa) = showJSArrayObj "CxtItem" [showJSON aa] 721 817 showJSON (CxtSlurpy aa) = showJSArrayObj "CxtSlurpy" [showJSON aa] 818 819 instance YAML Cxt where 820 asYAML (CxtVoid) = asYAMLcls "CxtVoid" 821 asYAML (CxtItem aa) = asYAMLseq "CxtItem" [asYAML aa] 822 asYAML (CxtSlurpy aa) = asYAMLseq "CxtSlurpy" [asYAML aa] 722 823 723 824 instance Binary Type where … … 763 864 [showJSON aa , showJSON ab] 764 865 866 instance YAML Type where 867 asYAML (MkType aa) = asYAMLseq "MkType" [asYAML aa] 868 asYAML (TypeOr aa ab) = asYAMLseq "TypeOr" [asYAML aa , asYAML ab] 869 asYAML (TypeAnd aa ab) = asYAMLseq "TypeAnd" 870 [asYAML aa , asYAML ab] 871 765 872 instance Binary Param where 766 873 put_ bh (MkParam aa ab ac ad ae af ag ah ai) = do … … 804 911 ("paramDefault", showJSON ai)] 805 912 913 instance YAML Param where 914 asYAML (MkParam aa ab ac ad ae af ag ah ai) = asYAMLmap "MkParam" 915 [("isInvocant", asYAML aa) , ("isOptional", asYAML ab) , 916 ("isNamed", asYAML ac) , ("isLValue", asYAML ad) , 917 ("isWritable", asYAML ae) , ("isLazy", asYAML af) , 918 ("paramName", asYAML ag) , ("paramContext", asYAML ah) , 919 ("paramDefault", asYAML ai)] 920 806 921 instance Binary Pos where 807 922 put_ bh (MkPos aa ab ac ad ae) = do … … 831 946 ("posEndColumn", showJSON ae)] 832 947 948 instance YAML Pos where 949 asYAML (MkPos aa ab ac ad ae) = asYAMLmap "MkPos" 950 [("posName", asYAML aa) , ("posBeginLine", asYAML ab) , 951 ("posBeginColumn", asYAML ac) , ("posEndLine", asYAML ad) , 952 ("posEndColumn", asYAML ae)] 953 833 954 -- Imported from other files :- -
src/Pugs/PIL1.hs-drift
r6801 r8675 23 23 import Emit.PIR 24 24 import DrIFT.Perl5 25 import DrIFT.YAML 25 26 import DrIFT.Binary 26 27 import DrIFT.JSON … … 29 30 -- {-! global : Haskell2Xml !-} 30 31 31 {-! global : GhcBinary, Perl5, JSON !-}32 {-! global : GhcBinary, Perl5, JSON, YAML !-} 32 33 33 34 {-| … … 131 132 put_ _ _ = return () 132 133 get _ = return Noop 134 instance YAML Exp where 135 asYAML _ = asYAML () 133 136 instance Perl5 Exp where 134 137 showPerl5 _ = "(undef)" … … 137 140 138 141 -- Non-canonical serialization... needs work 142 instance (Show (TVar a)) => YAML (TVar a) where 143 asYAML _ = asYAML () 139 144 instance (Show (TVar a)) => Perl5 (TVar a) where 140 145 showPerl5 _ = "(warn '<ref>')" -
src/Pugs/PIL2.hs
r8161 r8675 1 {-# OPTIONS_GHC - cpp -fglasgow-exts -funbox-strict-fields -fallow-overlapping-instances -fno-warn-orphans -fno-warn-incomplete-patterns -fallow-undecidable-instances #-}1 {-# OPTIONS_GHC -fglasgow-exts -funbox-strict-fields -fallow-overlapping-instances -fno-warn-orphans -fno-warn-incomplete-patterns -fallow-undecidable-instances #-} 2 2 {- Generated by DrIFT (Automatic class derivations for Haskell) -} 3 3 {-# LINE 1 "src/Pugs/PIL2.hs-drift" #-} … … 25 25 import Emit.PIR 26 26 import DrIFT.Perl5 27 import DrIFT.YAML 27 28 import DrIFT.Binary 28 29 import DrIFT.JSON … … 31 32 -- {-! global : Haskell2Xml !-} 32 33 33 {-! global : GhcBinary, Perl5, JSON !-} 34 35 #ifndef HADDOCK 36 -- the @s etc. here confuse Haddock. 34 {-! global : GhcBinary, Perl5, JSON, YAML !-} 35 37 36 {-| 38 37 The plan here is to first compile the environment (subroutines, … … 111 110 112 111 -} 113 #endif114 112 115 113 data PIL_Environment = PIL_Environment … … 207 205 put_ _ _ = return () 208 206 get _ = return Noop 207 instance YAML Exp where 208 asYAML _ = asYAML () 209 209 instance Perl5 Exp where 210 210 showPerl5 _ = "(undef)" … … 213 213 214 214 -- Non-canonical serialization... needs work 215 instance (Show (TVar a)) => YAML (TVar a) where 216 asYAML _ = asYAML () 215 217 instance (Show (TVar a)) => Perl5 (TVar a) where 216 218 showPerl5 _ = "(warn '<ref>')" … … 236 238 showJSON (PIL_Environment aa ab) = showJSHashObj "PIL_Environment" 237 239 [("pilGlob", showJSON aa) , ("pilMain", showJSON ab)] 240 241 instance YAML PIL_Environment where 242 asYAML (PIL_Environment aa ab) = asYAMLmap "PIL_Environment" 243 [("pilGlob", asYAML aa) , ("pilMain", asYAML ab)] 238 244 239 245 instance Binary PIL_Stmts where … … 281 287 ("pStmts", showJSON ac)] 282 288 289 instance YAML PIL_Stmts where 290 asYAML (PNil) = asYAMLcls "PNil" 291 asYAML (PStmts aa ab) = asYAMLmap "PStmts" 292 [("pStmt", asYAML aa) , ("pStmts", asYAML ab)] 293 asYAML (PPad aa ab ac) = asYAMLmap "PPad" 294 [("pScope", asYAML aa) , ("pSyms", asYAML ab) , 295 ("pStmts", asYAML ac)] 296 283 297 instance Binary PIL_Stmt where 284 298 put_ bh PNoop = do … … 322 336 [("pPos", showJSON aa) , ("pExp", showJSON ab) , 323 337 ("pNode", showJSON ac)] 338 339 instance YAML PIL_Stmt where 340 asYAML (PNoop) = asYAMLcls "PNoop" 341 asYAML (PStmt aa) = asYAMLmap "PStmt" [("pExpr", asYAML aa)] 342 asYAML (PPos aa ab ac) = asYAMLmap "PPos" 343 [("pPos", asYAML aa) , ("pExp", asYAML ab) , ("pNode", asYAML ac)] 324 344 325 345 instance Binary PIL_Expr where … … 391 411 ("pBody", showJSON ae)] 392 412 413 instance YAML PIL_Expr where 414 asYAML (PRawName aa) = asYAMLmap "PRawName" 415 [("pRawName", asYAML aa)] 416 asYAML (PExp aa) = asYAMLmap "PExp" [("pLV", asYAML aa)] 417 asYAML (PLit aa) = asYAMLmap "PLit" [("pLit", asYAML aa)] 418 asYAML (PThunk aa) = asYAMLmap "PThunk" [("pThunk", asYAML aa)] 419 asYAML (PCode aa ab ac ad ae) = asYAMLmap "PCode" 420 [("pType", asYAML aa) , ("pParams", asYAML ab) , 421 ("pLValue", asYAML ac) , ("pIsMulti", asYAML ad) , 422 ("pBody", asYAML ae)] 423 393 424 instance Binary PIL_Decl where 394 425 put_ bh (PSub aa ab ac ad ae af) = do … … 420 451 ("pSubIsMulti", showJSON ae) , ("pSubBody", showJSON af)] 421 452 453 instance YAML PIL_Decl where 454 asYAML (PSub aa ab ac ad ae af) = asYAMLmap "PSub" 455 [("pSubName", asYAML aa) , ("pSubType", asYAML ab) , 456 ("pSubParams", asYAML ac) , ("pSubLValue", asYAML ad) , 457 ("pSubIsMulti", asYAML ae) , ("pSubBody", asYAML af)] 458 422 459 instance Binary PIL_Literal where 423 460 put_ bh (PVal aa) = do … … 432 469 instance JSON PIL_Literal where 433 470 showJSON (PVal aa) = showJSHashObj "PVal" [("pVal", showJSON aa)] 471 472 instance YAML PIL_Literal where 473 asYAML (PVal aa) = asYAMLmap "PVal" [("pVal", asYAML aa)] 434 474 435 475 instance Binary PIL_LValue where … … 495 535 [("pLHS", showJSON aa) , ("pRHS", showJSON ab)] 496 536 537 instance YAML PIL_LValue where 538 asYAML (PVar aa) = asYAMLmap "PVar" [("pVarName", asYAML aa)] 539 asYAML (PApp aa ab ac ad) = asYAMLmap "PApp" 540 [("pCxt", asYAML aa) , ("pFun", asYAML ab) , ("pInv", asYAML ac) , 541 ("pArgs", asYAML ad)] 542 asYAML (PAssign aa ab) = asYAMLmap "PAssign" 543 [("pLHS", asYAML aa) , ("pRHS", asYAML ab)] 544 asYAML (PBind aa ab) = asYAMLmap "PBind" 545 [("pLHS", asYAML aa) , ("pRHS", asYAML ab)] 546 497 547 instance Binary TParam where 498 548 put_ bh (MkTParam aa ab) = do … … 511 561 showJSON (MkTParam aa ab) = showJSHashObj "MkTParam" 512 562 [("tpParam", showJSON aa) , ("tpDefault", showJSON ab)] 563 564 instance YAML TParam where 565 asYAML (MkTParam aa ab) = asYAMLmap "MkTParam" 566 [("tpParam", asYAML aa) , ("tpDefault", asYAML ab)] 513 567 514 568 instance Binary TCxt where … … 565 619 showJSON (TTailCall aa) = showJSArrayObj "TTailCall" [showJSON aa] 566 620 621 instance YAML TCxt where 622 asYAML (TCxtVoid) = asYAMLcls "TCxtVoid" 623 asYAML (TCxtLValue aa) = asYAMLseq "TCxtLValue" [asYAML aa] 624 asYAML (TCxtItem aa) = asYAMLseq "TCxtItem" [asYAML aa] 625 asYAML (TCxtSlurpy aa) = asYAMLseq "TCxtSlurpy" [asYAML aa] 626 asYAML (TTailCall aa) = asYAMLseq "TTailCall" [asYAML aa] 627 567 628 instance Binary TEnv where 568 629 put_ bh (MkTEnv aa ab ac ad ae) = do … … 591 652 ("tCxt", showJSON ac) , ("tReg", showJSON ad) , 592 653 ("tLabel", showJSON ae)] 654 655 instance YAML TEnv where 656 asYAML (MkTEnv aa ab ac ad ae) = asYAMLmap "MkTEnv" 657 [("tLexDepth", asYAML aa) , ("tTokDepth", asYAML ab) , 658 ("tCxt", asYAML ac) , ("tReg", asYAML ad) , ("tLabel", asYAML ae)] 593 659 594 660 instance Binary Scope where … … 637 703 showJSON (STemp) = showJSScalar "STemp" 638 704 showJSON (SGlobal) = showJSScalar "SGlobal" 705 706 instance YAML Scope where 707 asYAML (SState) = asYAMLcls "SState" 708 asYAML (SMy) = asYAMLcls "SMy" 709 asYAML (SOur) = asYAMLcls "SOur" 710 asYAML (SLet) = asYAMLcls "SLet" 711 asYAML (STemp) = asYAMLcls "STemp" 712 asYAML (SGlobal) = asYAMLcls "SGlobal" 639 713 640 714 instance Binary SubType where … … 689 763 showJSON (SubPointy) = showJSScalar "SubPointy" 690 764 showJSON (SubPrim) = showJSScalar "SubPrim" 765 766 instance YAML SubType where 767 asYAML (SubMethod) = asYAMLcls "SubMethod" 768 asYAML (SubCoroutine) = asYAMLcls "SubCoroutine" 769 asYAML (SubMacro) = asYAMLcls "SubMacro" 770 asYAML (SubRoutine) = asYAMLcls "SubRoutine" 771 asYAML (SubBlock) = asYAMLcls "SubBlock" 772 asYAML (SubPointy) = asYAMLcls "SubPointy" 773 asYAML (SubPrim) = asYAMLcls "SubPrim" 691 774 692 775 instance Binary Val where … … 762 845 showJSON (VType aa) = showJSArrayObj "VType" [showJSON aa] 763 846 847 instance YAML Val where 848 asYAML (VUndef) = asYAMLcls "VUndef" 849 asYAML (VBool aa) = asYAMLseq "VBool" [asYAML aa] 850 asYAML (VInt aa) = asYAMLseq "VInt" [asYAML aa] 851 asYAML (VRat aa) = asYAMLseq "VRat" [asYAML aa] 852 asYAML (VNum aa) = asYAMLseq "VNum" [asYAML aa] 853 asYAML (VStr aa) = asYAMLseq "VStr" [asYAML aa] 854 asYAML (VList aa) = asYAMLseq "VList" [asYAML aa] 855 asYAML (VType aa) = asYAMLseq "VType" [asYAML aa] 856
