Changeset 6240

Show
Ignore:
Timestamp:
08/14/05 14:23:31 (3 years ago)
Author:
autrijus
svk:copy_cache_prev:
8452
Message:

* Disabled -CXML (not really used; requires HaXml?)
* Added my drift.pl runner to util/drift that produces

src/Pugs/PIL1.hs from src/Pugs/PIL1.hs-drift.

* Factored out common Perl5/XML instances to src/DrIFT.

Files:
2 added
5 modified

Legend:

Unmodified
Added
Removed
  • Makefile.PL

    r6138 r6240  
    334334        $hsc2hs $hsc2hs_flags \$< 
    335335 
     336.SUFFIXES: .hs-drift .hs 
     337 
     338.hs-drift.hs : 
     339        \$(PERL) util/drift.pl \$< > \$@ 
     340 
    336341haddock : $version_h $config_h @hppfiles docs/haddock 
    337342        haddock -t Pugs-$version -h -o docs/haddock/ @hppfiles 
  • src/DrIFT/Perl5.hs

    r6237 r6240  
    22 
    33module DrIFT.Perl5 where 
     4import Data.Ratio 
    45import Data.List (intersperse) 
    56 
     
    4445    showPerl5 False = "0" 
    4546 
     47instance Perl5 Integer where  
     48    showPerl5 = show 
     49instance Perl5 Rational where  
     50    showPerl5 r = "(" ++ show x ++ "/" ++ show y ++ ")" 
     51        where 
     52        x = numerator r 
     53        y = denominator r 
     54instance Perl5 Double where  
     55    showPerl5 = show 
     56 
    4657instance (Perl5 a) => Perl5 (Maybe a) where 
    4758    showPerl5 (Just x) = showPerl5 x 
  • src/Pugs/CodeGen.hs

    r6238 r6240  
    1414import Pugs.Internals 
    1515import Pugs.CodeGen.PIL (genPIL) 
    16 -- import Pugs.CodeGen.PIL2 (genPIL2) 
    1716import Pugs.CodeGen.PIR (genPIR) 
    1817import Pugs.CodeGen.Perl5 (genPerl5) 
    19 import Pugs.CodeGen.XML (genXML) 
    2018import Pugs.Compile.Pugs (genPugs) 
    2119import Pugs.Compile.Haskell (genGHC) 
     20-- import Pugs.CodeGen.PIL2 (genPIL2) 
     21-- import Pugs.CodeGen.XML (genXML) 
    2222import qualified Data.Map as Map 
    2323 
     
    3333    , ("Perl5",       genPerl5) 
    3434    , ("Pugs",        genPugs) 
    35     , ("Xml",         genXML) 
     35--  , ("Xml",         genXML) 
    3636    ] 
    3737 
  • src/Pugs/PIL1.hs

    r6238 r6240  
    11{-# OPTIONS_GHC -fglasgow-exts -funbox-strict-fields -fallow-overlapping-instances -fno-warn-orphans #-} 
    22 
    3 module Pugs.PIL1 where 
     3module Pugs.PIL1 ( 
     4    PIL_Environment(..), 
     5    PIL_Stmts(..), PIL_Stmt(..), PIL_Decl(..), 
     6    PIL_Expr(..), PIL_Literal(..), PIL_LValue(..), 
     7    TParam(..), TCxt(..), TEnv(..), 
     8) where 
    49import Pugs.AST hiding (Prim) 
    510import Pugs.Internals 
     
    712import Emit.PIR 
    813import DrIFT.Perl5 
    9 import Text.XML.HaXml.Haskell2Xml 
    10  
    11 {-! global : Perl5, Haskell2Xml !-} 
    12  
    13 instance Perl5 VInt where  
    14     showPerl5 = show 
    15 instance Perl5 VRat where  
    16     showPerl5 r = "(" ++ show x ++ "/" ++ show y ++ ")" 
    17         where 
    18         x = numerator r 
    19         y = denominator r 
    20 instance Perl5 VNum where  
    21     showPerl5 = show 
     14 
     15-- import DrIFT.XML 
     16-- {-! global : Haskell2Xml !-} 
     17 
     18{-! global : Perl5 !-} 
     19 
    2220instance (Typeable a) => Perl5 (TVar a) where 
    2321    showPerl5 _ = "(warn '<ref>')" 
    2422instance Perl5 Exp where 
    2523    showPerl5 _ = "(undef)" 
    26  
    27 instance (Typeable a) => Haskell2Xml (TVar a) where 
    28     toHType   _    = Prim "TVar" "tvar" 
    29     toContents _   = [CElem (Elem "tvar" [] [])] 
    30  
    31 instance Haskell2Xml Exp where 
    32     toHType   _    = Prim "Exp" "exp" 
    33     toContents _   = [CElem (Elem "exp" [] [])] 
    34     fromContents _ = (Noop, []) 
    35  
    36 instance Haskell2Xml VRat where 
    37     toHType   _    = Prim "Rational" "rational" 
    38     toContents i   = [CElem (Elem "rational" [mkAttr "value" (show i)] [])] 
    39         where 
    40         mkAttr :: String -> String -> Attribute 
    41         mkAttr n v = (n, AttValue [Left v]) 
    42     fromContents (CElem (Elem "rational" [("value",(AttValue [Left s]))] []):cs) 
    43                    = (read s, cs) 
    44     fromContents (_:cs) = fromContents cs 
    4524 
    4625{-| 
     
    136115 
    137116------------------------------------------------------------------------ 
    138 {- 
    139  
    140 data Scope = SState  -- ^ Persistent across calls 
    141            | SMy     -- ^ Lexical 
    142            | SOur    -- ^ Package 
    143            | SLet    -- ^ Hypotheticalised (reverted upon failure) 
    144            | STemp   -- ^ Temporary (reverted at scope exit) 
    145            | SGlobal -- ^ Global 
    146  
    147 data SubType = SubMethod    -- ^ Method 
    148              | SubCoroutine -- ^ Coroutine 
    149              | SubMacro     -- ^ Macro 
    150              | SubRoutine   -- ^ Regular subroutine 
    151              | SubBlock     -- ^ Bare block 
    152              | SubPointy    -- ^ Pointy sub 
    153              | SubPrim      -- ^ Built-in primitive operator (see "Pugs.Prim") 
    154  
    155  
    156 data Val 
    157     = VUndef                 -- ^ Undefined value 
    158     | VBool     !VBool       -- ^ Boolean value 
    159     | VInt      !VInt        -- ^ Integer value 
    160     | VRat      !VRat        -- ^ Rational number value 
    161     | VNum      !VNum        -- ^ Number (i.e. a double) 
    162     | VStr      !VStr        -- ^ String value 
    163     | VList     !VList       -- ^ List value 
    164     | VType     !VType       -- ^ Type value (e.g. @Int@ or @Type@) 
    165  
    166 data Cxt = CxtVoid         -- ^ Context that isn't expecting any values 
    167          | CxtItem !Type   -- ^ Context expecting a value of the specified type 
    168          | CxtSlurpy !Type -- ^ Context expecting multiple values of the 
    169                            --     specified type 
    170 data Type 
    171     = MkType !String      -- ^ A regular type 
    172     | TypeOr  !Type !Type -- ^ The disjunction (|) of two types 
    173     | TypeAnd !Type !Type -- ^ The conjunction (&) of two types 
    174  
    175 data Param = MkParam 
    176     { isInvocant    :: !Bool        -- ^ Is it in invocant slot? 
    177     , isOptional    :: !Bool        -- ^ Is it optional? 
    178     , isNamed       :: !Bool        -- ^ Is it named-only? 
    179     , isLValue      :: !Bool        -- ^ Is it lvalue (i.e. not `is copy`)? 
    180     , isWritable    :: !Bool        -- ^ Is it writable (i.e. `is rw`)? 
    181     , isLazy        :: !Bool        -- ^ Is it call-by-name (short-circuit)? 
    182     , paramName     :: !String      -- ^ Parameter name 
    183     , paramContext  :: !Cxt         -- ^ Parameter context: slurpiness and type 
    184     , paramDefault  :: !Exp         -- ^ Default expression (to evaluate to) 
    185     } 
    186  
    187 data Pos = MkPos 
    188     { posName           :: !String 
    189     , posBeginLine      :: !Int 
    190     , posBeginColumn    :: !Int 
    191     , posEndLine        :: !Int 
    192     , posEndColumn      :: !Int 
    193     } 
    194  
    195 -} 
    196117 
    197118{-* Generated by DrIFT : Look, but Don't Touch. *-} 
     
    200121              showP5HashObj "PIL::Environment" 
    201122              [("pilMain", showPerl5 aa) , ("pilGlob", showPerl5 ab)] 
    202  
    203 instance Haskell2Xml PIL_Environment where 
    204     toHType v = 
    205         Defined "PIL_Environment" [] 
    206                 [Constr "PIL_Environment" [] [toHType aa,toHType ab]] 
    207       where 
    208         (PIL_Environment aa ab) = v 
    209     fromContents (CElem (Elem constr [] cs):etc) 
    210         | "PIL_Environment" `isPrefixOf` constr = 
    211             (\(aa,cs00)-> (\(ab,_)-> (PIL_Environment aa ab, etc)) 
    212                           (fromContents cs00)) 
    213             (fromContents cs) 
    214     toContents v@(PIL_Environment aa ab) = 
    215         [mkElemC (showConstr 0 (toHType v)) (concat [toContents aa, 
    216                                                      toContents ab])] 
    217123 
    218124instance Perl5 PIL_Stmts where 
     
    224130               ("pStmts", showPerl5 ac)] 
    225131 
    226 instance Haskell2Xml PIL_Stmts where 
    227     toHType v = 
    228         Defined "PIL_Stmts" [] 
    229                 [Constr "PNil" [] [],Constr "PStmts" [] [toHType aa,toHType ab], 
    230                  Constr "PPad" [] [toHType ac,toHType ad,toHType ae]] 
    231       where 
    232         (PStmts aa ab) = v 
    233         (PPad ac ad ae) = v 
    234     fromContents (CElem (Elem constr [] cs):etc) 
    235         | "PStmts" `isPrefixOf` constr = 
    236             (\(aa,cs00)-> (\(ab,_)-> (PStmts aa ab, etc)) (fromContents cs00)) 
    237             (fromContents cs) 
    238         | "PPad" `isPrefixOf` constr = 
    239             (\(ac,cs00)-> (\(ad,cs01)-> (\(ae,_)-> (PPad ac ad ae, etc)) 
    240                                         (fromContents cs01)) 
    241                           (fromContents cs00)) 
    242             (fromContents cs) 
    243         | "PNil" `isPrefixOf` constr = 
    244             (PNil,etc) 
    245     toContents v@PNil = 
    246         [mkElemC (showConstr 0 (toHType v)) []] 
    247     toContents v@(PStmts aa ab) = 
    248         [mkElemC (showConstr 1 (toHType v)) (concat [toContents aa, 
    249                                                      toContents ab])] 
    250     toContents v@(PPad ac ad ae) = 
    251         [mkElemC (showConstr 2 (toHType v)) (concat [toContents ac, 
    252                                                      toContents ad,toContents ae])] 
    253  
    254132instance Perl5 PIL_Stmt where 
    255133    showPerl5 (PNoop) = showP5Class "PNoop" 
     
    259137              [("pPos", showPerl5 aa) , ("pExp", showPerl5 ab) , 
    260138               ("pNode", showPerl5 ac)] 
    261  
    262 instance Haskell2Xml PIL_Stmt where 
    263     toHType v = 
    264         Defined "PIL_Stmt" [] 
    265                 [Constr "PNoop" [] [],Constr "PStmt" [] [toHType aa], 
    266                  Constr "PPos" [] [toHType ab,toHType ac,toHType ad]] 
    267       where 
    268         (PStmt aa) = v 
    269         (PPos ab ac ad) = v 
    270     fromContents (CElem (Elem constr [] cs):etc) 
    271         | "PStmt" `isPrefixOf` constr = 
    272             (\(aa,_)-> (PStmt aa, etc)) (fromContents cs) 
    273         | "PPos" `isPrefixOf` constr = 
    274             (\(ab,cs00)-> (\(ac,cs01)-> (\(ad,_)-> (PPos ab ac ad, etc)) 
    275                                         (fromContents cs01)) 
    276                           (fromContents cs00)) 
    277             (fromContents cs) 
    278         | "PNoop" `isPrefixOf` constr = 
    279             (PNoop,etc) 
    280     toContents v@PNoop = 
    281         [mkElemC (showConstr 0 (toHType v)) []] 
    282     toContents v@(PStmt aa) = 
    283         [mkElemC (showConstr 1 (toHType v)) (toContents aa)] 
    284     toContents v@(PPos ab ac ad) = 
    285         [mkElemC (showConstr 2 (toHType v)) (concat [toContents ab, 
    286                                                      toContents ac,toContents ad])] 
    287139 
    288140instance Perl5 PIL_Expr where 
     
    297149               ("pBody", showPerl5 ac)] 
    298150 
    299 instance Haskell2Xml PIL_Expr where 
    300     toHType v = 
    301         Defined "PIL_Expr" [] 
    302                 [Constr "PRawName" [] [toHType aa],Constr "PExp" [] [toHType ab], 
    303                  Constr "PLit" [] [toHType ac],Constr "PThunk" [] [toHType ad], 
    304                  Constr "PCode" [] [toHType ae,toHType af,toHType ag]] 
    305       where 
    306         (PRawName aa) = v 
    307         (PExp ab) = v 
    308         (PLit ac) = v 
    309         (PThunk ad) = v 
    310         (PCode ae af ag) = v 
    311     fromContents (CElem (Elem constr [] cs):etc) 
    312         | "PThunk" `isPrefixOf` constr = 
    313             (\(ad,_)-> (PThunk ad, etc)) (fromContents cs) 
    314         | "PRawName" `isPrefixOf` constr = 
    315             (\(aa,_)-> (PRawName aa, etc)) (fromContents cs) 
    316         | "PLit" `isPrefixOf` constr = 
    317             (\(ac,_)-> (PLit ac, etc)) (fromContents cs) 
    318         | "PExp" `isPrefixOf` constr = 
    319             (\(ab,_)-> (PExp ab, etc)) (fromContents cs) 
    320         | "PCode" `isPrefixOf` constr = 
    321             (\(ae,cs00)-> (\(af,cs01)-> (\(ag,_)-> (PCode ae af ag, etc)) 
    322                                         (fromContents cs01)) 
    323                           (fromContents cs00)) 
    324             (fromContents cs) 
    325     toContents v@(PRawName aa) = 
    326         [mkElemC (showConstr 0 (toHType v)) (toContents aa)] 
    327     toContents v@(PExp ab) = 
    328         [mkElemC (showConstr 1 (toHType v)) (toContents ab)] 
    329     toContents v@(PLit ac) = 
    330         [mkElemC (showConstr 2 (toHType v)) (toContents ac)] 
    331     toContents v@(PThunk ad) = 
    332         [mkElemC (showConstr 3 (toHType v)) (toContents ad)] 
    333     toContents v@(PCode ae af ag) = 
    334         [mkElemC (showConstr 4 (toHType v)) (concat [toContents ae, 
    335                                                      toContents af,toContents ag])] 
    336  
    337151instance Perl5 PIL_Decl where 
    338152    showPerl5 (PSub aa ab ac ad) = showP5HashObj "PSub" 
     
    340154               ("pSubParams", showPerl5 ac) , ("pSubBody", showPerl5 ad)] 
    341155 
    342 instance Haskell2Xml PIL_Decl where 
    343     toHType v = 
    344         Defined "PIL_Decl" [] 
    345                 [Constr "PSub" [] [toHType aa,toHType ab,toHType ac,toHType ad]] 
    346       where 
    347         (PSub aa ab ac ad) = v 
    348     fromContents (CElem (Elem constr [] cs):etc) 
    349         | "PSub" `isPrefixOf` constr = 
    350             (\(aa,cs00)-> (\(ab,cs01)-> (\(ac,cs02)-> (\(ad, 
    351                                                          _)-> (PSub aa ab ac ad, etc)) 
    352                                                       (fromContents cs02)) 
    353                                         (fromContents cs01)) 
    354                           (fromContents cs00)) 
    355             (fromContents cs) 
    356     toContents v@(PSub aa ab ac ad) = 
    357         [mkElemC (showConstr 0 (toHType v)) (concat [toContents aa, 
    358                                                      toContents ab,toContents ac,toContents ad])] 
    359  
    360156instance Perl5 PIL_Literal where 
    361157    showPerl5 (PVal aa) = showP5HashObj "PVal" [("pVal", showPerl5 aa)] 
    362  
    363 instance Haskell2Xml PIL_Literal where 
    364     toHType v = 
    365         Defined "PIL_Literal" [] [Constr "PVal" [] [toHType aa]] 
    366       where 
    367         (PVal aa) = v 
    368     fromContents (CElem (Elem constr [] cs):etc) 
    369         | "PVal" `isPrefixOf` constr = 
    370             (\(aa,_)-> (PVal aa, etc)) (fromContents cs) 
    371     toContents v@(PVal aa) = 
    372         [mkElemC (showConstr 0 (toHType v)) (toContents aa)] 
    373158 
    374159instance Perl5 PIL_LValue where 
     
    383168              [("pLHS", showPerl5 aa) , ("pRHS", showPerl5 ab)] 
    384169 
    385 instance Haskell2Xml PIL_LValue where 
    386     toHType v = 
    387         Defined "PIL_LValue" [] 
    388                 [Constr "PVar" [] [toHType aa], 
    389                  Constr "PApp" [] [toHType ab,toHType ac,toHType ad,toHType ae], 
    390                  Constr "PAssign" [] [toHType af,toHType ag], 
    391                  Constr "PBind" [] [toHType ah,toHType ai]] 
    392       where 
    393         (PVar aa) = v 
    394         (PApp ab ac ad ae) = v 
    395         (PAssign af ag) = v 
    396         (PBind ah ai) = v 
    397     fromContents (CElem (Elem constr [] cs):etc) 
    398         | "PVar" `isPrefixOf` constr = 
    399             (\(aa,_)-> (PVar aa, etc)) (fromContents cs) 
    400         | "PBind" `isPrefixOf` constr = 
    401             (\(ah,cs00)-> (\(ai,_)-> (PBind ah ai, etc)) (fromContents cs00)) 
    402             (fromContents cs) 
    403         | "PAssign" `isPrefixOf` constr = 
    404             (\(af,cs00)-> (\(ag,_)-> (PAssign af ag, etc)) (fromContents cs00)) 
    405             (fromContents cs) 
    406         | "PApp" `isPrefixOf` constr = 
    407             (\(ab,cs00)-> (\(ac,cs01)-> (\(ad,cs02)-> (\(ae, 
    408                                                          _)-> (PApp ab ac ad ae, etc)) 
    409                                                       (fromContents cs02)) 
    410                                         (fromContents cs01)) 
    411                           (fromContents cs00)) 
    412             (fromContents cs) 
    413     toContents v@(PVar aa) = 
    414         [mkElemC (showConstr 0 (toHType v)) (toContents aa)] 
    415     toContents v@(PApp ab ac ad ae) = 
    416         [mkElemC (showConstr 1 (toHType v)) (concat [toContents ab, 
    417                                                      toContents ac,toContents ad,toContents ae])] 
    418     toContents v@(PAssign af ag) = 
    419         [mkElemC (showConstr 2 (toHType v)) (concat [toContents af, 
    420                                                      toContents ag])] 
    421     toContents v@(PBind ah ai) = 
    422         [mkElemC (showConstr 3 (toHType v)) (concat [toContents ah, 
    423                                                      toContents ai])] 
    424  
    425170instance Perl5 TParam where 
    426171    showPerl5 (MkTParam aa ab) = showP5HashObj "MkTParam" 
    427172              [("tpParam", showPerl5 aa) , ("tpDefault", showPerl5 ab)] 
    428173 
    429 instance Haskell2Xml TParam where 
    430     toHType v = 
    431         Defined "TParam" [] [Constr "MkTParam" [] [toHType aa,toHType ab]] 
    432       where 
    433         (MkTParam aa ab) = v 
    434     fromContents (CElem (Elem constr [] cs):etc) 
    435         | "MkTParam" `isPrefixOf` constr = 
    436             (\(aa,cs00)-> (\(ab,_)-> (MkTParam aa ab, etc)) 
    437                           (fromContents cs00)) 
    438             (fromContents cs) 
    439     toContents v@(MkTParam aa ab) = 
    440         [mkElemC (showConstr 0 (toHType v)) (concat [toContents aa, 
    441                                                      toContents ab])] 
    442  
    443174instance Perl5 TCxt where 
    444175    showPerl5 (TCxtVoid) = showP5Class "TCxtVoid" 
     
    450181    showPerl5 (TTailCall aa) = showP5ArrayObj "TTailCall" 
    451182              [showPerl5 aa] 
    452  
    453 instance Haskell2Xml TCxt where 
    454     toHType v = 
    455         Defined "TCxt" [] 
    456                 [Constr "TCxtVoid" [] [],Constr "TCxtLValue" [] [toHType aa], 
    457                  Constr "TCxtItem" [] [toHType ab], 
    458                  Constr "TCxtSlurpy" [] [toHType ac], 
    459                  Constr "TTailCall" [] [toHType ad]] 
    460       where 
    461         (TCxtLValue aa) = v 
    462         (TCxtItem ab) = v 
    463         (TCxtSlurpy ac) = v 
    464         (TTailCall ad) = v 
    465     fromContents (CElem (Elem constr [] cs):etc) 
    466         | "TTailCall" `isPrefixOf` constr = 
    467             (\(ad,_)-> (TTailCall ad, etc)) (fromContents cs) 
    468         | "TCxtVoid" `isPrefixOf` constr = 
    469             (TCxtVoid,etc) 
    470         | "TCxtSlurpy" `isPrefixOf` constr = 
    471             (\(ac,_)-> (TCxtSlurpy ac, etc)) (fromContents cs) 
    472         | "TCxtLValue" `isPrefixOf` constr = 
    473             (\(aa,_)-> (TCxtLValue aa, etc)) (fromContents cs) 
    474         | "TCxtItem" `isPrefixOf` constr = 
    475             (\(ab,_)-> (TCxtItem ab, etc)) (fromContents cs) 
    476     toContents v@TCxtVoid = 
    477         [mkElemC (showConstr 0 (toHType v)) []] 
    478     toContents v@(TCxtLValue aa) = 
    479         [mkElemC (showConstr 1 (toHType v)) (toContents aa)] 
    480     toContents v@(TCxtItem ab) = 
    481         [mkElemC (showConstr 2 (toHType v)) (toContents ab)] 
    482     toContents v@(TCxtSlurpy ac) = 
    483         [mkElemC (showConstr 3 (toHType v)) (toContents ac)] 
    484     toContents v@(TTailCall ad) = 
    485         [mkElemC (showConstr 4 (toHType v)) (toContents ad)] 
    486183 
    487184instance Perl5 TEnv where 
     
    490187               ("tCxt", showPerl5 ac) , ("tReg", showPerl5 ad) , 
    491188               ("tLabel", showPerl5 ae)] 
    492  
    493 instance Haskell2Xml TEnv where 
    494     toHType v = 
    495         Defined "TEnv" [] 
    496                 [Constr "MkTEnv" [] 
    497                         [toHType aa,toHType ab,toHType ac,toHType ad,toHType ae]] 
    498       where 
    499         (MkTEnv aa ab ac ad ae) = v 
    500     fromContents (CElem (Elem constr [] cs):etc) 
    501         | "MkTEnv" `isPrefixOf` constr = 
    502             (\(aa,cs00)-> (\(ab,cs01)-> (\(ac,cs02)-> (\(ad,cs03)-> (\(ae, 
    503                                                                        _)-> (MkTEnv aa ab ac ad ae, etc)) 
    504                                                                     (fromContents cs03)) 
    505                                                       (fromContents cs02)) 
    506                                         (fromContents cs01)) 
    507                           (fromContents cs00)) 
    508             (fromContents cs) 
    509     toContents v@(MkTEnv aa ab ac ad ae) = 
    510         [mkElemC (showConstr 0 (toHType v)) (concat [toContents aa, 
    511                                                      toContents ab,toContents ac,toContents ad, 
    512                                                      toContents ae])] 
    513189 
    514190instance Perl5 Scope where 
     
    519195    showPerl5 (STemp) = showP5Class "STemp" 
    520196    showPerl5 (SGlobal) = showP5Class "SGlobal" 
    521  
    522 instance Haskell2Xml Scope where 
    523     toHType v = 
    524         Defined "Scope" [] 
    525                 [Constr "SState" [] [],Constr "SMy" [] [],Constr "SOur" [] [], 
    526                  Constr "SLet" [] [],Constr "STemp" [] [],Constr "SGlobal" [] []] 
    527     fromContents (CElem (Elem constr [] cs):etc) 
    528         | "STemp" `isPrefixOf` constr = 
    529             (STemp,etc) 
    530         | "SState" `isPrefixOf` constr = 
    531             (SState,etc) 
    532         | "SOur" `isPrefixOf` constr = 
    533             (SOur,etc) 
    534         | "SMy" `isPrefixOf` constr = 
    535             (SMy,etc) 
    536         | "SLet" `isPrefixOf` constr = 
    537             (SLet,etc) 
    538         | "SGlobal" `isPrefixOf` constr = 
    539             (SGlobal,etc) 
    540     toContents v@SState = 
    541         [mkElemC (showConstr 0 (toHType v)) []] 
    542     toContents v@SMy = 
    543         [mkElemC (showConstr 1 (toHType v)) []] 
    544     toContents v@SOur = 
    545         [mkElemC (showConstr 2 (toHType v)) []] 
    546     toContents v@SLet = 
    547         [mkElemC (showConstr 3 (toHType v)) []] 
    548     toContents v@STemp = 
    549         [mkElemC (showConstr 4 (toHType v)) []] 
    550     toContents v@SGlobal = 
    551         [mkElemC (showConstr 5 (toHType v)) []] 
    552197 
    553198instance Perl5 SubType where 
     
    559204    showPerl5 (SubPointy) = showP5Class "SubPointy" 
    560205    showPerl5 (SubPrim) = showP5Class "SubPrim" 
    561  
    562 instance Haskell2Xml SubType where 
    563     toHType v = 
    564         Defined "SubType" [] 
    565                 [Constr "SubMethod" [] [],Constr "SubCoroutine" [] [], 
    566                  Constr "SubMacro" [] [],Constr "SubRoutine" [] [], 
    567                  Constr "SubBlock" [] [],Constr "SubPointy" [] [], 
    568                  Constr "SubPrim" [] []] 
    569     fromContents (CElem (Elem constr [] cs):etc) 
    570         | "SubRoutine" `isPrefixOf` constr = 
    571             (SubRoutine,etc) 
    572         | "SubPrim" `isPrefixOf` constr = 
    573             (SubPrim,etc) 
    574         | "SubPointy" `isPrefixOf` constr = 
    575             (SubPointy,etc) 
    576         | "SubMethod" `isPrefixOf` constr = 
    577             (SubMethod,etc) 
    578         | "SubMacro" `isPrefixOf` constr = 
    579             (SubMacro,etc) 
    580         | "SubCoroutine" `isPrefixOf` constr = 
    581             (SubCoroutine,etc) 
    582         | "SubBlock" `isPrefixOf` constr = 
    583             (SubBlock,etc) 
    584     toContents v@SubMethod = 
    585         [mkElemC (showConstr 0 (toHType v)) []] 
    586     toContents v@SubCoroutine = 
    587         [mkElemC (showConstr 1 (toHType v)) []] 
    588     toContents v@SubMacro = 
    589         [mkElemC (showConstr 2 (toHType v)) []] 
    590     toContents v@SubRoutine = 
    591         [mkElemC (showConstr 3 (toHType v)) []] 
    592     toContents v@SubBlock = 
    593         [mkElemC (showConstr 4 (toHType v)) []] 
    594     toContents v@SubPointy = 
    595         [mkElemC (showConstr 5 (toHType v)) []] 
    596     toContents v@SubPrim = 
    597         [mkElemC (showConstr 6 (toHType v)) []] 
    598206 
    599207instance Perl5 Val where 
     
    607215    showPerl5 (VType aa) = showP5ArrayObj "VType" [showPerl5 aa] 
    608216 
    609 instance Haskell2Xml Val where 
    610     toHType v = 
    611         Defined "Val" [] 
    612                 [Constr "VUndef" [] [],Constr "VBool" [] [toHType aa], 
    613                  Constr "VInt" [] [toHType ab],Constr "VRat" [] [toHType ac], 
    614                  Constr "VNum" [] [toHType ad],Constr "VStr" [] [toHType ae], 
    615                  Constr "VList" [] [toHType af],Constr "VType" [] [toHType ag]] 
    616       where 
    617         (VBool aa) = v 
    618         (VInt ab) = v 
    619         (VRat ac) = v 
    620         (VNum ad) = v 
    621         (VStr ae) = v 
    622         (VList af) = v 
    623         (VType ag) = v 
    624     fromContents (CElem (Elem constr [] cs):etc) 
    625         | "VUndef" `isPrefixOf` constr = 
    626             (VUndef,etc) 
    627         | "VType" `isPrefixOf` constr = 
    628             (\(ag,_)-> (VType ag, etc)) (fromContents cs) 
    629         | "VStr" `isPrefixOf` constr = 
    630             (\(ae,_)-> (VStr ae, etc)) (fromContents cs) 
    631         | "VRat" `isPrefixOf` constr = 
    632             (\(ac,_)-> (VRat ac, etc)) (fromContents cs) 
    633         | "VNum" `isPrefixOf` constr = 
    634             (\(ad,_)-> (VNum ad, etc)) (fromContents cs) 
    635         | "VList" `isPrefixOf` constr = 
    636             (\(af,_)-> (VList af, etc)) (fromContents cs) 
    637         | "VInt" `isPrefixOf` constr = 
    638             (\(ab,_)-> (VInt ab, etc)) (fromContents cs) 
    639         | "VBool" `isPrefixOf` constr = 
    640             (\(aa,_)-> (VBool aa, etc)) (fromContents cs) 
    641     toContents v@VUndef = 
    642         [mkElemC (showConstr 0 (toHType v)) []] 
    643     toContents v@(VBool aa) = 
    644         [mkElemC (showConstr 1 (toHType v)) (toContents aa)] 
    645     toContents v@(VInt ab) = 
    646         [mkElemC (showConstr 2 (toHType v)) (toContents ab)] 
    647     toContents v@(VRat ac) = 
    648         [mkElemC (showConstr 3 (toHType v)) (toContents ac)] 
    649     toContents v@(VNum ad) = 
    650         [mkElemC (showConstr 4 (toHType v)) (toContents ad)] 
    651     toContents v@(VStr ae) = 
    652         [mkElemC (showConstr 5 (toHType v)) (toContents ae)] 
    653     toContents v@(VList af) = 
    654         [mkElemC (showConstr 6 (toHType v)) (toContents af)] 
    655     toContents v@(VType ag) = 
    656         [mkElemC (showConstr 7 (toHType v)) (toContents ag)] 
    657  
    658217instance Perl5 Cxt where 
    659218    showPerl5 (CxtVoid) = showP5Class "CxtVoid" 
     
    661220    showPerl5 (CxtSlurpy aa) = showP5ArrayObj "CxtSlurpy" 
    662221              [showPerl5 aa] 
    663  
    664 instance Haskell2Xml Cxt where 
    665     toHType v = 
    666         Defined "Cxt" [] 
    667                 [Constr "CxtVoid" [] [],Constr "CxtItem" [] [toHType aa], 
    668                  Constr "CxtSlurpy" [] [toHType ab]] 
    669       where 
    670         (CxtItem aa) = v 
    671         (CxtSlurpy ab) = v 
    672     fromContents (CElem (Elem constr [] cs):etc) 
    673         | "CxtVoid" `isPrefixOf` constr = 
    674             (CxtVoid,etc) 
    675         | "CxtSlurpy" `isPrefixOf` constr = 
    676             (\(ab,_)-> (CxtSlurpy ab, etc)) (fromContents cs) 
    677         | "CxtItem" `isPrefixOf` constr = 
    678             (\(aa,_)-> (CxtItem aa, etc)) (fromContents cs) 
    679     toContents v@CxtVoid = 
    680         [mkElemC (showConstr 0 (toHType v)) []] 
    681     toContents v@(CxtItem aa) = 
    682         [mkElemC (showConstr 1 (toHType v)) (toContents aa)] 
    683     toContents v@(CxtSlurpy ab) = 
    684         [mkElemC (showConstr 2 (toHType v)) (toContents ab)] 
    685222 
    686223instance Perl5 Type where 
     
    690227    showPerl5 (TypeAnd aa ab) = showP5ArrayObj "TypeAnd" 
    691228              [showPerl5 aa , showPerl5 ab] 
    692  
    693 instance Haskell2Xml Type where 
    694     toHType v = 
    695         Defined "Type" [] 
    696                 [Constr "MkType" [] [toHType aa], 
    697                  Constr "TypeOr" [] [toHType ab,toHType ac], 
    698                  Constr "TypeAnd" [] [toHType ad,toHType ae]] 
    699       where 
    700         (MkType aa) = v 
    701         (TypeOr ab ac) = v 
    702         (TypeAnd ad ae) = v 
    703     fromContents (CElem (Elem constr [] cs):etc) 
    704         | "TypeOr" `isPrefixOf` constr = 
    705             (\(ab,cs00)-> (\(ac,_)-> (TypeOr ab ac, etc)) (fromContents cs00)) 
    706             (fromContents cs) 
    707         | "TypeAnd" `isPrefixOf` constr = 
    708             (\(ad,cs00)-> (\(ae,_)-> (TypeAnd ad ae, etc)) (fromContents cs00)) 
    709             (fromContents cs) 
    710         | "MkType" `isPrefixOf` constr = 
    711             (\(aa,_)-> (MkType aa, etc)) (fromContents cs) 
    712     toContents v@(MkType aa) = 
    713         [mkElemC (showConstr 0 (toHType v)) (toContents aa)] 
    714     toContents v@(TypeOr ab ac) = 
    715         [mkElemC (showConstr 1 (toHType v)) (concat [toContents ab,