Changeset 8684
- Timestamp:
- 01/15/06 18:15:06 (3 years ago)
- Files:
-
- 1 added
- 7 modified
-
Pugs.cabal.in (modified) (1 diff)
-
src/DrIFT/YAML.hs (modified) (2 diffs)
-
src/Pugs/AST/Internals.hs-drift (added)
-
src/Pugs/CodeGen.hs (modified) (5 diffs)
-
src/Pugs/CodeGen/PIL2.hs (modified) (3 diffs)
-
src/Pugs/PIL1.hs-drift (modified) (3 diffs)
-
src/Pugs/PIL2.hs-drift (modified) (3 diffs)
-
util/drift.pl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Pugs.cabal.in
r8675 r8684 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.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.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.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__ -
src/DrIFT/YAML.hs
r8682 r8684 20 20 Right s -> return s 21 21 22 class (Show a) =>YAML a where22 class YAML a where 23 23 asYAML :: a -> IO YamlNode 24 asYAML _ = return $ nilNode 24 25 25 26 asYAMLseq :: YAMLClass -> [IO YAMLVal] -> IO YamlNode … … 44 45 tagHs = ("tag:hs:" ++) 45 46 46 -- XXX - overlapping instances? 47 instance YAML () where 48 asYAML _ = return $ nilNode 47 instance YAML () 49 48 50 49 instance YAML Int where -
src/Pugs/CodeGen.hs
r8681 r8684 14 14 import Pugs.Internals 15 15 import Pugs.CodeGen.PIL1 (genPIL1) 16 import Pugs.CodeGen.PIL2 (genPIL2, genPIL2Perl5, genPIL2 Binary, genPIL2JSON, genPIL2YAML)16 import Pugs.CodeGen.PIL2 (genPIL2, genPIL2Perl5, genPIL2JSON, genPIL2YAML) 17 17 import Pugs.CodeGen.PIR (genPIR, genPIR_YAML) 18 18 import Pugs.CodeGen.Perl5 (genPerl5) 19 19 import Pugs.CodeGen.YAML (genYAML) 20 20 import Pugs.CodeGen.JSON (genJSON) 21 import Pugs.CodeGen.Binary (genBinary)22 21 import Pugs.Compile.Pugs (genPugs) 23 22 import Pugs.Compile.Haskell (genGHC) … … 34 33 , ("PIL1", genPIL1) 35 34 , ("PIL1-Perl5", genPerl5) 36 , ("PIL1-Binary", genBinary)37 35 , ("PIL1-JSON", genJSON) 38 36 , ("PIL1-YAML", genYAML) … … 41 39 , ("PIL2-JSON", genPIL2JSON) 42 40 , ("PIL2-YAML", genPIL2YAML) 43 , ("PIL2-Binary", genPIL2Binary)44 41 , ("Pugs", genPugs) 42 , ("Parse-YAML", genParseYAML) 45 43 -- , ("XML", genXML) 46 44 ] … … 60 58 norm' "pil2" = "PIL2" 61 59 norm' "perl5" = "!PIL1-Perl5" 62 norm' "binary" = "!PIL1-Binary"63 60 norm' "json" = "!PIL1-JSON" 64 61 norm' "yaml" = "!PIL1-YAML" … … 66 63 norm' "pil1json" = "PIL1-JSON" 67 64 norm' "pil1yaml" = "PIL1-YAML" 68 norm' "pil1binary" = "PIL1-Binary"69 65 norm' "pil2perl5" = "PIL2-Perl5" 70 66 norm' "pil2json" = "PIL2-JSON" 71 67 norm' "pil2yaml" = "PIL2-YAML" 72 norm' "pil2binary" = "PIL2-Binary"73 68 norm' "pugs" = "Pugs" 74 69 -- norm' "xml" = "XML" -
src/Pugs/CodeGen/PIL2.hs
r8675 r8684 4 4 module Pugs.CodeGen.PIL2 ( 5 5 genPIL2, 6 genPIL2Perl5, genPIL2 Binary, genPIL2JSON, genPIL2YAML6 genPIL2Perl5, genPIL2JSON, genPIL2YAML 7 7 ) where 8 8 import Pugs.Internals … … 13 13 import System.Directory 14 14 import DrIFT.Perl5 15 import DrIFT.Binary16 15 import DrIFT.JSON 17 16 import DrIFT.YAML … … 32 31 return . VStr . unlines $ [showPerl5 penv] 33 32 34 genPIL2Binary :: Eval Val35 genPIL2Binary = do36 penv <- compile () :: Eval PIL_Environment37 liftIO $ do38 tmp <- getTemporaryDirectory39 (file, fh) <- openBinaryTempFile tmp "pugs.bin"40 bh <- openBinIO fh41 put_ bh penv42 hClose fh43 return $ VStr (unlines [file])44 45 33 genPIL2JSON :: Eval Val 46 34 genPIL2JSON = do -
src/Pugs/PIL1.hs-drift
r8682 r8684 24 24 import DrIFT.Perl5 25 25 import DrIFT.YAML 26 import DrIFT.Binary27 26 import DrIFT.JSON 28 27 … … 30 29 -- {-! global : Haskell2Xml !-} 31 30 32 {-! global : GhcBinary,Perl5, JSON, YAML !-}31 {-! global : Perl5, JSON, YAML !-} 33 32 34 33 {-| … … 128 127 129 128 ------------------------------------------------------------------------ 130 131 instance Binary Exp where132 put_ _ _ = return ()133 get _ = return Noop134 instance YAML Exp where135 asYAML _ = asYAML ()136 instance Perl5 Exp where137 showPerl5 _ = "(undef)"138 instance JSON Exp where139 showJSON _ = "null"140 141 -- Non-canonical serialization... needs work142 instance (Typeable a, YAML a) => YAML (TVar a) where143 asYAML tv = do144 v <- liftSTM (readTVar tv)145 asYAML v146 instance (Show (TVar a)) => Perl5 (TVar a) where147 showPerl5 _ = "(warn '<ref>')"148 instance (Show (TVar a)) => JSON (TVar a) where149 showJSON _ = "null"150 151 =begin DRIFT152 153 data Scope = SState -- ^ Persistent across calls154 | SMy -- ^ Lexical155 | SOur -- ^ Package156 | SLet -- ^ Hypotheticalised (reverted upon failure)157 | STemp -- ^ Temporary (reverted at scope exit)158 | SGlobal -- ^ Global159 160 data SubType = SubMethod -- ^ Method161 | SubCoroutine -- ^ Coroutine162 | SubMacro -- ^ Macro163 | SubRoutine -- ^ Regular subroutine164 | SubBlock -- ^ Bare block165 | SubPointy -- ^ Pointy sub166 | SubPrim -- ^ Built-in primitive operator (see "Pugs.Prim")167 168 169 data Val170 = VUndef -- ^ Undefined value171 | VBool !VBool -- ^ Boolean value172 | VInt !VInt -- ^ Integer value173 | VRat !VRat -- ^ Rational number value174 | VNum !VNum -- ^ Number (i.e. a double)175 | VStr !VStr -- ^ String value176 | VList !VList -- ^ List value177 | VType !VType -- ^ Type value (e.g. @Int@ or @Type@)178 179 data Cxt = CxtVoid -- ^ Context that isn't expecting any values180 | CxtItem !Type -- ^ Context expecting a value of the specified type181 | CxtSlurpy !Type -- ^ Context expecting multiple values of the182 -- specified type183 data Type184 = MkType !String -- ^ A regular type185 | TypeOr !Type !Type -- ^ The disjunction (|) of two types186 | TypeAnd !Type !Type -- ^ The conjunction (&) of two types187 188 data Param = MkParam189 { isInvocant :: !Bool -- ^ Is it in invocant slot?190 , isOptional :: !Bool -- ^ Is it optional?191 , isNamed :: !Bool -- ^ Is it named-only?192 , isLValue :: !Bool -- ^ Is it lvalue (i.e. not `is copy`)?193 , isWritable :: !Bool -- ^ Is it writable (i.e. `is rw`)?194 , isLazy :: !Bool -- ^ Is it call-by-name (short-circuit)?195 , paramName :: !String -- ^ Parameter name196 , paramContext :: !Cxt -- ^ Parameter context: slurpiness and type197 , paramDefault :: !Exp -- ^ Default expression (to evaluate to)198 }199 200 data Pos = MkPos201 { posName :: !String202 , posBeginLine :: !Int203 , posBeginColumn :: !Int204 , posEndLine :: !Int205 , posEndColumn :: !Int206 }207 208 209 =cut -
src/Pugs/PIL2.hs-drift
r8682 r8684 24 24 import DrIFT.Perl5 25 25 import DrIFT.YAML 26 import DrIFT.Binary27 26 import DrIFT.JSON 28 27 … … 30 29 -- {-! global : Haskell2Xml !-} 31 30 32 {-! global : GhcBinary,Perl5, JSON, YAML !-}31 {-! global : Perl5, JSON, YAML !-} 33 32 34 33 {-| … … 198 197 deriving (Show, Eq, Ord, Typeable) 199 198 200 ------------------------------------------------------------------------201 202 instance Binary Exp where203 put_ _ _ = return ()204 get _ = return Noop205 instance YAML Exp where206 asYAML _ = asYAML ()207 instance Perl5 Exp where208 showPerl5 _ = "(undef)"209 instance JSON Exp where210 showJSON _ = "null"211 212 -- Non-canonical serialization... needs work213 instance (Typeable a, YAML a) => YAML (TVar a) where214 asYAML tv = do215 v <- liftSTM (readTVar tv)216 asYAML v217 instance (Show (TVar a)) => Perl5 (TVar a) where218 showPerl5 _ = "(warn '<ref>')"219 instance (Show (TVar a)) => JSON (TVar a) where220 showJSON _ = "null"221 222 =begin DRIFT223 224 data Scope = SState -- ^ Persistent across calls225 | SMy -- ^ Lexical226 | SOur -- ^ Package227 | SLet -- ^ Hypotheticalised (reverted upon failure)228 | STemp -- ^ Temporary (reverted at scope exit)229 | SGlobal -- ^ Global230 231 data SubType = SubMethod -- ^ Method232 | SubCoroutine -- ^ Coroutine233 | SubMacro -- ^ Macro234 | SubRoutine -- ^ Regular subroutine235 | SubBlock -- ^ Bare block236 | SubPointy -- ^ Pointy sub237 | SubPrim -- ^ Built-in primitive operator (see "Pugs.Prim")238 239 240 data Val241 = VUndef -- ^ Undefined value242 | VBool !VBool -- ^ Boolean value243 | VInt !VInt -- ^ Integer value244 | VRat !VRat -- ^ Rational number value245 | VNum !VNum -- ^ Number (i.e. a double)246 | VStr !VStr -- ^ String value247 | VList !VList -- ^ List value248 | VType !VType -- ^ Type value (e.g. @Int@ or @Type@)249 250 data Cxt = CxtVoid -- ^ Context that isn't expecting any values251 | CxtItem !Type -- ^ Context expecting a value of the specified type252 | CxtSlurpy !Type -- ^ Context expecting multiple values of the253 -- specified type254 data Type255 = MkType !String -- ^ A regular type256 | TypeOr !Type !Type -- ^ The disjunction (|) of two types257 | TypeAnd !Type !Type -- ^ The conjunction (&) of two types258 259 data Param = MkParam260 { isInvocant :: !Bool -- ^ Is it in invocant slot?261 , isOptional :: !Bool -- ^ Is it optional?262 , isNamed :: !Bool -- ^ Is it named-only?263 , isLValue :: !Bool -- ^ Is it lvalue (i.e. not `is copy`)?264 , isWritable :: !Bool -- ^ Is it writable (i.e. `is rw`)?265 , isLazy :: !Bool -- ^ Is it call-by-name (short-circuit)?266 , paramName :: !String -- ^ Parameter name267 , paramContext :: !Cxt -- ^ Parameter context: slurpiness and type268 , paramDefault :: !Exp -- ^ Default expression (to evaluate to)269 }270 271 data Pos = MkPos272 { posName :: !String273 , posBeginLine :: !Int274 , posBeginColumn :: !Int275 , posEndLine :: !Int276 , posEndColumn :: !Int277 }278 279 280 =cut -
util/drift.pl
r7874 r8684 5 5 # XXX - This is not at all portable. 6 6 7 $ENV{DERIVEPATH} = "$Bin/../src"; 8 7 9 my ($in, $out) = @ARGV; 8 10 my ($rh, $wh); … … 10 12 $rh, $wh, 11 13 'runhugs', 14 "-h1048576", 12 15 "-P.:/usr/local/lib/hugs/libraries/:/usr/lib/hugs/libraries/:$Bin/../src/DrIFT:$Bin/../../DrIFT/src", 13 16 "$Bin/../../DrIFT/src/DrIFT.hs",
