Changeset 6250
- Timestamp:
- 08/14/05 19:25:02 (3 years ago)
- svk:copy_cache_prev:
- 8452
- Location:
- src
- Files:
-
- 3 added
- 6 modified
-
DrIFT/JSON.hs (added)
-
DrIFT/Perl5.hs (modified) (1 diff)
-
DrIFT/RuleJSON.hs (added)
-
DrIFT/UserRules.hs (modified) (2 diffs)
-
Pugs/CodeGen.hs (modified) (2 diffs)
-
Pugs/CodeGen/JSON.hs (added)
-
Pugs/CodeGen/Perl5.hs (modified) (1 diff)
-
Pugs/PIL1.hs (modified) (20 diffs)
-
Pugs/PIL1.hs-drift (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/DrIFT/Perl5.hs
r6248 r6250 35 35 36 36 -- XXX - overlapping instances? 37 instance Perl5 () where 38 showPerl5 _ = "undef" 37 39 38 40 instance Perl5 Int where -
src/DrIFT/UserRules.hs
r6230 r6250 9 9 import UserRuleGhcBinary 10 10 import qualified RulePerl5 11 import qualified RuleJSON 11 12 import qualified RuleUtility 12 13 import qualified RuleFunctorM … … 16 17 -- add your rules to this list 17 18 userRules :: [RuleDef] 18 userRules = userRulesXml ++ userRulesBinary ++ userRulesGeneric ++ userRulesGhcBinary ++ RuleUtility.rules ++ RuleFunctorM.rules ++ RuleMonoid.rules ++ RulePerl5.rules 19 userRules = userRulesXml ++ userRulesBinary ++ userRulesGeneric ++ userRulesGhcBinary ++ RuleUtility.rules ++ RuleFunctorM.rules ++ RuleMonoid.rules ++ RulePerl5.rules ++ RuleJSON.rules 19 20 -
src/Pugs/CodeGen.hs
r6248 r6250 16 16 import Pugs.CodeGen.PIR (genPIR) 17 17 import Pugs.CodeGen.Perl5 (genPerl5) 18 import Pugs.CodeGen.JSON (genJSON) 18 19 import Pugs.CodeGen.Binary (genBinary) 19 20 import Pugs.Compile.Pugs (genPugs) … … 35 36 , ("Pugs", genPugs) 36 37 , ("Binary", genBinary) 38 , ("Json", genJSON) 37 39 -- , ("Xml", genXML) 38 40 ] -
src/Pugs/CodeGen/Perl5.hs
r6248 r6250 11 11 genPerl5 :: Eval Val 12 12 genPerl5 = do 13 penv <- compile () 14 return . VStr . unlines $ 15 [ "bless({" 16 , " pilMain => " ++ showPerl5 (pilMain penv) ++ "," 17 , " pilGlob => " ++ showPerl5 (pilGlob penv) 18 , "} => 'PIL::Environment')" 19 ] 13 penv <- compile () :: Eval PIL_Environment 14 return . VStr . unlines $ [showPerl5 penv] -
src/Pugs/PIL1.hs
r6248 r6250 1 1 {-# OPTIONS_GHC -fglasgow-exts -funbox-strict-fields -fallow-overlapping-instances -fno-warn-orphans -fno-warn-incomplete-patterns #-} 2 {- Generated by DrIFT (Automatic class derivations for Haskell) -} 3 {-# LINE 1 "src/Pugs/PIL1.hs-drift" #-} 2 4 3 5 module Pugs.PIL1 ( … … 13 15 import DrIFT.Perl5 14 16 import DrIFT.Binary 17 import DrIFT.JSON 15 18 16 19 -- import DrIFT.XML 17 20 -- {-! global : Haskell2Xml !-} 18 21 19 {-! global : GhcBinary, Perl5 !-}22 {-! global : GhcBinary, Perl5, JSON !-} 20 23 21 24 {-| … … 117 120 instance Perl5 Exp where 118 121 showPerl5 _ = "(undef)" 122 instance JSON Exp where 123 showJSON _ = "null" 119 124 120 125 {-* Generated by DrIFT : Look, but Don't Touch. *-} … … 132 137 showP5HashObj "PIL::Environment" 133 138 [("pilGlob", showPerl5 aa) , ("pilMain", showPerl5 ab)] 139 140 instance JSON PIL_Environment where 141 showJSON (PIL_Environment aa ab) = showJSHashObj "PIL_Environment" 142 [("pilGlob", showJSON aa) , ("pilMain", showJSON ab)] 134 143 135 144 instance Binary PIL_Stmts where … … 168 177 ("pStmts", showPerl5 ac)] 169 178 179 instance JSON PIL_Stmts where 180 showJSON (PNil) = showJSScalar "PNil" 181 showJSON (PStmts aa ab) = showJSHashObj "PStmts" 182 [("pStmt", showJSON aa) , ("pStmts", showJSON ab)] 183 showJSON (PPad aa ab ac) = showJSHashObj "PPad" 184 [("pScope", showJSON aa) , ("pSyms", showJSON ab) , 185 ("pStmts", showJSON ac)] 186 170 187 instance Binary PIL_Stmt where 171 188 put_ bh PNoop = do … … 200 217 [("pPos", showPerl5 aa) , ("pExp", showPerl5 ab) , 201 218 ("pNode", showPerl5 ac)] 219 220 instance JSON PIL_Stmt where 221 showJSON (PNoop) = showJSScalar "PNoop" 222 showJSON (PStmt aa) = showJSHashObj "PStmt" 223 [("pExpr", showJSON aa)] 224 showJSON (PPos aa ab ac) = showJSHashObj "PPos" 225 [("pPos", showJSON aa) , ("pExp", showJSON ab) , 226 ("pNode", showJSON ac)] 202 227 203 228 instance Binary PIL_Expr where … … 251 276 ("pBody", showPerl5 ac)] 252 277 278 instance JSON PIL_Expr where 279 showJSON (PRawName aa) = showJSHashObj "PRawName" 280 [("pRawName", showJSON aa)] 281 showJSON (PExp aa) = showJSHashObj "PExp" [("pLV", showJSON aa)] 282 showJSON (PLit aa) = showJSHashObj "PLit" [("pLit", showJSON aa)] 283 showJSON (PThunk aa) = showJSHashObj "PThunk" 284 [("pThunk", showJSON aa)] 285 showJSON (PCode aa ab ac) = showJSHashObj "PCode" 286 [("pType", showJSON aa) , ("pParams", showJSON ab) , 287 ("pBody", showJSON ac)] 288 253 289 instance Binary PIL_Decl where 254 290 put_ bh (PSub aa ab ac ad) = do … … 269 305 ("pSubParams", showPerl5 ac) , ("pSubBody", showPerl5 ad)] 270 306 307 instance JSON PIL_Decl where 308 showJSON (PSub aa ab ac ad) = showJSHashObj "PSub" 309 [("pSubName", showJSON aa) , ("pSubType", showJSON ab) , 310 ("pSubParams", showJSON ac) , ("pSubBody", showJSON ad)] 311 271 312 instance Binary PIL_Literal where 272 313 put_ bh (PVal aa) = do … … 278 319 instance Perl5 PIL_Literal where 279 320 showPerl5 (PVal aa) = showP5HashObj "PVal" [("pVal", showPerl5 aa)] 321 322 instance JSON PIL_Literal where 323 showJSON (PVal aa) = showJSHashObj "PVal" [("pVal", showJSON aa)] 280 324 281 325 instance Binary PIL_LValue where … … 329 373 [("pLHS", showPerl5 aa) , ("pRHS", showPerl5 ab)] 330 374 375 instance JSON PIL_LValue where 376 showJSON (PVar aa) = showJSHashObj "PVar" 377 [("pVarName", showJSON aa)] 378 showJSON (PApp aa ab ac ad) = showJSHashObj "PApp" 379 [("pCxt", showJSON aa) , ("pFun", showJSON ab) , 380 ("pInv", showJSON ac) , ("pArgs", showJSON ad)] 381 showJSON (PAssign aa ab) = showJSHashObj "PAssign" 382 [("pLHS", showJSON aa) , ("pRHS", showJSON ab)] 383 showJSON (PBind aa ab) = showJSHashObj "PBind" 384 [("pLHS", showJSON aa) , ("pRHS", showJSON ab)] 385 331 386 instance Binary TParam where 332 387 put_ bh (MkTParam aa ab) = do … … 341 396 showPerl5 (MkTParam aa ab) = showP5HashObj "MkTParam" 342 397 [("tpParam", showPerl5 aa) , ("tpDefault", showPerl5 ab)] 398 399 instance JSON TParam where 400 showJSON (MkTParam aa ab) = showJSHashObj "MkTParam" 401 [("tpParam", showJSON aa) , ("tpDefault", showJSON ab)] 343 402 344 403 instance Binary TCxt where … … 385 444 [showPerl5 aa] 386 445 446 instance JSON TCxt where 447 showJSON (TCxtVoid) = showJSScalar "TCxtVoid" 448 showJSON (TCxtLValue aa) = showJSArrayObj "TCxtLValue" 449 [showJSON aa] 450 showJSON (TCxtItem aa) = showJSArrayObj "TCxtItem" [showJSON aa] 451 showJSON (TCxtSlurpy aa) = showJSArrayObj "TCxtSlurpy" 452 [showJSON aa] 453 showJSON (TTailCall aa) = showJSArrayObj "TTailCall" [showJSON aa] 454 387 455 instance Binary TEnv where 388 456 put_ bh (MkTEnv aa ab ac ad ae) = do … … 405 473 ("tCxt", showPerl5 ac) , ("tReg", showPerl5 ad) , 406 474 ("tLabel", showPerl5 ae)] 475 476 instance JSON TEnv where 477 showJSON (MkTEnv aa ab ac ad ae) = showJSHashObj "MkTEnv" 478 [("tLexDepth", showJSON aa) , ("tTokDepth", showJSON ab) , 479 ("tCxt", showJSON ac) , ("tReg", showJSON ad) , 480 ("tLabel", showJSON ae)] 407 481 408 482 instance Binary Scope where … … 442 516 showPerl5 (STemp) = showP5Class "STemp" 443 517 showPerl5 (SGlobal) = showP5Class "SGlobal" 518 519 instance JSON Scope where 520 showJSON (SState) = showJSScalar "SState" 521 showJSON (SMy) = showJSScalar "SMy" 522 showJSON (SOur) = showJSScalar "SOur" 523 showJSON (SLet) = showJSScalar "SLet" 524 showJSON (STemp) = showJSScalar "STemp" 525 showJSON (SGlobal) = showJSScalar "SGlobal" 444 526 445 527 instance Binary SubType where … … 484 566 showPerl5 (SubPointy) = showP5Class "SubPointy" 485 567 showPerl5 (SubPrim) = showP5Class "SubPrim" 568 569 instance JSON SubType where 570 showJSON (SubMethod) = showJSScalar "SubMethod" 571 showJSON (SubCoroutine) = showJSScalar "SubCoroutine" 572 showJSON (SubMacro) = showJSScalar "SubMacro" 573 showJSON (SubRoutine) = showJSScalar "SubRoutine" 574 showJSON (SubBlock) = showJSScalar "SubBlock" 575 showJSON (SubPointy) = showJSScalar "SubPointy" 576 showJSON (SubPrim) = showJSScalar "SubPrim" 486 577 487 578 instance Binary Val where … … 546 637 showPerl5 (VType aa) = showP5ArrayObj "VType" [showPerl5 aa] 547 638 639 instance JSON Val where 640 showJSON (VUndef) = showJSScalar "VUndef" 641 showJSON (VBool aa) = showJSArrayObj "VBool" [showJSON aa] 642 showJSON (VInt aa) = showJSArrayObj "VInt" [showJSON aa] 643 showJSON (VRat aa) = showJSArrayObj "VRat" [showJSON aa] 644 showJSON (VNum aa) = showJSArrayObj "VNum" [showJSON aa] 645 showJSON (VStr aa) = showJSArrayObj "VStr" [showJSON aa] 646 showJSON (VList aa) = showJSArrayObj "VList" [showJSON aa] 647 showJSON (VType aa) = showJSArrayObj "VType" [showJSON aa] 648 548 649 instance Binary Cxt where 549 650 put_ bh CxtVoid = do … … 572 673 showPerl5 (CxtSlurpy aa) = showP5ArrayObj "CxtSlurpy" 573 674 [showPerl5 aa] 675 676 instance JSON Cxt where 677 showJSON (CxtVoid) = showJSScalar "CxtVoid" 678 showJSON (CxtItem aa) = showJSArrayObj "CxtItem" [showJSON aa] 679 showJSON (CxtSlurpy aa) = showJSArrayObj "CxtSlurpy" [showJSON aa] 574 680 575 681 instance Binary Type where … … 606 712 showPerl5 (TypeAnd aa ab) = showP5ArrayObj "TypeAnd" 607 713 [showPerl5 aa , showPerl5 ab] 714 715 instance JSON Type where 716 showJSON (MkType aa) = showJSArrayObj "MkType" [showJSON aa] 717 showJSON (TypeOr aa ab) = showJSArrayObj "TypeOr" 718 [showJSON aa , showJSON ab] 719 showJSON (TypeAnd aa ab) = showJSArrayObj "TypeAnd" 720 [showJSON aa , showJSON ab] 608 721 609 722 instance Binary Param where … … 639 752 ("paramDefault", showPerl5 ai)] 640 753 754 instance JSON Param where 755 showJSON (MkParam aa ab ac ad ae af ag ah ai) = 756 showJSHashObj "MkParam" 757 [("isInvocant", showJSON aa) , ("isOptional", showJSON ab) , 758 ("isNamed", showJSON ac) , ("isLValue", showJSON ad) , 759 ("isWritable", showJSON ae) , ("isLazy", showJSON af) , 760 ("paramName", showJSON ag) , ("paramContext", showJSON ah) , 761 ("paramDefault", showJSON ai)] 762 641 763 instance Binary Pos where 642 764 put_ bh (MkPos aa ab ac ad ae) = do … … 660 782 ("posEndColumn", showPerl5 ae)] 661 783 784 instance JSON Pos where 785 showJSON (MkPos aa ab ac ad ae) = showJSHashObj "MkPos" 786 [("posName", showJSON aa) , ("posBeginLine", showJSON ab) , 787 ("posBeginColumn", showJSON ac) , ("posEndLine", showJSON ad) , 788 ("posEndColumn", showJSON ae)] 789 662 790 -- Imported from other files :- -
src/Pugs/PIL1.hs-drift
r6248 r6250 13 13 import DrIFT.Perl5 14 14 import DrIFT.Binary 15 import DrIFT.JSON 15 16 16 17 -- import DrIFT.XML 17 18 -- {-! global : Haskell2Xml !-} 18 19 19 {-! global : GhcBinary, Perl5 !-}20 {-! global : GhcBinary, Perl5, JSON !-} 20 21 21 22 {-| … … 117 118 instance Perl5 Exp where 118 119 showPerl5 _ = "(undef)" 120 instance JSON Exp where 121 showJSON _ = "null" 119 122 120 123 =begin DRIFT
