Changeset 3372
- Timestamp:
- 05/18/05 02:43:25 (3 years ago)
- svk:copy_cache_prev:
- 4945
- Location:
- src
- Files:
-
- 17 modified
-
Pugs/AST/Internals.hs (modified) (2 diffs)
-
Pugs/Compile/Haskell.hs (modified) (2 diffs)
-
Pugs/Compile/Parrot.hs (modified) (7 diffs)
-
Pugs/Embed.hs (modified) (1 diff)
-
Pugs/Eval.hs (modified) (4 diffs)
-
Pugs/External.hs (modified) (1 diff)
-
Pugs/Lexer.hs (modified) (1 diff)
-
Pugs/Parser.hs (modified) (6 diffs)
-
Pugs/Prim.hs (modified) (2 diffs)
-
Pugs/Prim/FileTest.hs (modified) (1 diff)
-
Pugs/Prim/List.hs (modified) (1 diff)
-
Pugs/Prim/Match.hs (modified) (1 diff)
-
Pugs/Run.hs (modified) (1 diff)
-
Pugs/Run/Args.hs (modified) (2 diffs)
-
Pugs/Shell.hs (modified) (2 diffs)
-
RRegex/PCRE.hs (modified) (1 diff)
-
Unicode.hs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/AST/Internals.hs
r3328 r3372 1291 1291 deriving (Show, Eq, Ord, Typeable) 1292 1292 1293 -- | A $/ object, the return of a rx match operation. 1293 1294 data VMatch = MkMatch 1294 1295 { matchOk :: !VBool -- success? … … 1301 1302 deriving (Show, Eq, Ord, Typeable) 1302 1303 1304 -- | An empty failed match 1305 mkMatchFail :: VMatch 1303 1306 mkMatchFail = MkMatch False 0 0 "" [] Map.empty 1307 1308 -- | Makes a successful match 1309 mkMatchOk :: Int -> Int -> VStr -> VList -> VHash -> VMatch 1304 1310 mkMatchOk = MkMatch True 1305 1311 -
src/Pugs/Compile/Haskell.hs
r3105 r3372 9 9 #else 10 10 11 import qualified Language.Haskell.TH as TH 12 import qualified Language.Haskell.TH.Lib 11 13 import Pugs.Internals 12 import qualified Language.Haskell.TH as TH13 14 import Pugs.AST 14 15 import Pugs.Run … … 37 38 38 39 -- Haddock doesn't like Template Haskell. 40 compile :: Exp -> Language.Haskell.TH.Lib.ExpQ 39 41 #ifndef HADDOCK 40 42 compile (Stmts stmt rest) = [| do -
src/Pugs/Compile/Parrot.hs
r3352 r3372 45 45 compile = return 46 46 47 padSort :: (Var, [(TVar Bool, TVar VRef)]) -> (String, [(a, b)]) -> Ordering 47 48 padSort ((a::[Char]), [(_, _)]) ((b::[Char]), [(_, _)]) 48 49 | (head a == ':' && head b == '&') = LT … … 97 98 compile prm = return $ text ".param pmc" <+> varText (paramName prm) 98 99 100 varText :: String -> Doc 99 101 varText ('$':name) = text $ "s__" ++ name 100 102 varText ('@':name) = text $ "a__" ++ name … … 102 104 varText x = error $ "invalid name: " ++ x 103 105 106 varInit :: String -> Doc 104 107 varInit ('$':_) = text $ "PerlUndef" 105 108 varInit ('@':_) = text $ "PerlArray" … … 122 125 return $ map ((tmp <> text "_" <>) . text) strs 123 126 127 incCounter :: String -> (String -> String) -> Eval Doc 124 128 incCounter key f = do 125 129 Just ioRef <- asks envDebug … … 139 143 140 144 145 label :: Doc -> Doc 141 146 label doc = doc <> text ":" 142 147 148 compileCond :: Compile a => String -> [a] -> Eval Doc 143 149 compileCond neg [cond, bodyIf, bodyElse] = do 144 150 [alt, end] <- tempLabels ["else", "endif"] … … 324 330 return $ vcat [ argC, f tmp ] 325 331 332 currentStash :: Eval Doc 326 333 currentStash = fmap text $ asks envStash 334 335 constPMC :: Doc -> Eval Doc 327 336 constPMC doc = do 328 337 tmp <- currentStash … … 332 341 ] 333 342 343 compileArg :: Compile a => a -> Eval (Doc, Doc) 334 344 compileArg exp = do 335 345 tmp <- tempPMC -
src/Pugs/Embed.hs
r2750 r3372 22 22 -- import Pugs.Embed.Ponie 23 23 24 evalEmbedded :: String -> String -> IO () 24 25 evalEmbedded "Parrot" code = do 25 26 evalParrot code -
src/Pugs/Eval.hs
r3340 r3372 87 87 -- Evaluation --------------------------------------------------------------- 88 88 89 -- debug :: (Pretty a) => String-> String -> a -> Eval ()89 debug :: Pretty a => String -> (String -> String) -> String -> a -> Eval () 90 90 debug key fun str a = do 91 91 rv <- asks envDebug … … 152 152 (retVal $ val) 153 153 154 addGlobalSym :: (Pad -> Pad) -> Eval () 154 155 addGlobalSym newSym = do 155 156 glob <- asks envGlobal … … 997 998 | otherwise = False 998 999 1000 toGlobal :: String -> String 999 1001 toGlobal name 1000 1002 | (sigil, identifier) <- break (\x -> isAlpha x || x == '_') name … … 1004 1006 1005 1007 1008 arityMatch :: VCode -> Int -> Int -> Maybe VCode 1006 1009 arityMatch sub@MkCode{ subAssoc = assoc, subParams = prms } argLen argSlurpLen 1007 1010 | assoc == "list" || assoc == "chain" -
src/Pugs/External.hs
r2725 r3372 29 29 30 30 31 externExternalize :: String -> String -> String -> IO String 31 32 externExternalize "Haskell" = externalizeHaskell 32 33 externExternalize backend = error $ "Unrecognized inline backend: " ++ backend 33 34 35 externLoad :: String -> FilePath -> IO [(String, [Val] -> Eval Val)] 34 36 externLoad "Haskell" = loadHaskell 35 37 externLoad backend = error $ "Unrecognized inline backend: " ++ backend 36 38 39 externRequire :: String -> FilePath -> Eval () 37 40 externRequire lang name = do 38 41 glob <- asks envGlobal -
src/Pugs/Lexer.hs
r3297 r3372 283 283 tryChoice = choice . map try 284 284 285 verbatimParens :: GenParser Char st a -> GenParser Char st a 285 286 verbatimParens = between (lexeme $ char '(') (char ')') 286 287 -
src/Pugs/Parser.hs
r3362 r3372 236 236 return (isMulti, isMethod, name) 237 237 238 maybeColon :: RuleParser ([Char] -> [Char]) 238 239 maybeColon = option id $ do 239 240 char ':' … … 354 355 return $ Pad scope lexDiff exp 355 356 357 -- | A Param representing the default (unnamed) invocant of a method on the given type. 358 selfParam :: String -> Param 356 359 selfParam typ = MkParam 357 360 { isInvocant = True … … 536 539 return $ Syn "module" [Val . VStr $ name ++ v ++ a] -- XXX 537 540 541 -- | The version part of a full class specification. 542 ruleVersionPart :: RuleParser String 538 543 ruleVersionPart = do -- version - XXX 539 544 char '-' … … 541 546 return ('-':str) 542 547 548 -- | The author part of a full class specification. 549 ruleAuthorPart :: RuleParser String 543 550 ruleAuthorPart = do -- author - XXX 544 551 char '-' … … 1456 1463 ] 1457 1464 1465 -- | splits the string into expressions on whitespace. 1466 -- Implements the <> operator at parse-time. 1467 doSplitStr :: String -> Exp 1458 1468 doSplitStr str = case perl6Words str of 1459 1469 [] -> Syn "," [] … … 1604 1614 1605 1615 -- Regexps 1616 1617 -- | A parser returning a regex, given a hashref of adverbs and a closing delimiter. 1618 rxLiteralAny :: Exp -> Char -> RuleParser Exp 1606 1619 rxLiteralAny adverbs 1607 1620 | Syn "\\{}" [Syn "," pairs] <- adverbs -
src/Pugs/Prim.hs
r3330 r3372 455 455 op1 other = \_ -> fail ("Unimplemented unaryOp: " ++ other) 456 456 457 op1Exit :: Val -> Eval a 457 458 op1Exit v = do 458 459 rv <- fromVal v … … 834 835 op2DefinedOr = undefined 835 836 837 op2Identity :: Val -> Val -> Eval Val 836 838 op2Identity (VObject x) (VObject y) = return $ VBool (objId x == objId y) 837 839 op2Identity (VRef ref) y = do -
src/Pugs/Prim/FileTest.hs
r2961 r3372 18 18 -- Known Bugs: multiple stat()s are done, and filename isnt a boolean. 19 19 20 isReadable = fileTestIO fileTestIsReadable 21 isWritable = fileTestIO fileTestIsWritable 20 isReadable :: Val -> Eval Val 21 isReadable = fileTestIO fileTestIsReadable 22 isWritable :: Val -> Eval Val 23 isWritable = fileTestIO fileTestIsWritable 24 isExecutable :: Val -> Eval Val 22 25 isExecutable = fileTestIO fileTestIsExecutable 23 exists = fileTestIO fileTestExists 24 isFile = fileTestIO fileTestIsFile 25 isDirectory = fileTestIO fileTestIsDirectory 26 fileSize = fileTestIO fileTestFileSize 27 sizeIsZero = fileTestIO fileTestSizeIsZero 26 exists :: Val -> Eval Val 27 exists = fileTestIO fileTestExists 28 isFile :: Val -> Eval Val 29 isFile = fileTestIO fileTestIsFile 30 isDirectory :: Val -> Eval Val 31 isDirectory = fileTestIO fileTestIsDirectory 32 fileSize :: Val -> Eval Val 33 fileSize = fileTestIO fileTestFileSize 34 sizeIsZero :: Val -> Eval Val 35 sizeIsZero = fileTestIO fileTestSizeIsZero 28 36 29 37 fileTestIO :: (Value n) => (n -> IO Val) -> Val -> Eval Val -
src/Pugs/Prim/List.hs
r3067 r3372 11 11 import Pugs.Prim.Numeric 12 12 13 op0Zip :: [Val] -> Eval Val 13 14 op0Zip = fmap (VList . concat . op0Zip') . mapM fromVal 14 15 -
src/Pugs/Prim/Match.hs
r3210 r3372 66 66 csBytes = encodeUTF8 csChars 67 67 68 matchFromMR :: MatchResult Char -> Val 68 69 matchFromMR mr = VMatch $ mkMatchOk 0 0 (decodeUTF8 all) subsMatch Map.empty 69 70 where -
src/Pugs/Run.hs
r3239 r3372 23 23 -- |Run 'Main.run' with command line args. 24 24 -- See 'Main.main' and 'Pugs.Run.Args.canonicalArgs' 25 runWithArgs :: ([String] -> IO t) -> IO t 25 26 runWithArgs f = do 26 27 args <- getArgs -
src/Pugs/Run/Args.hs
r3207 r3372 67 67 | otherwise = ['-':opt] 68 68 69 -- | List of options with long and sort variants, as tupples of long, short (with the dashes). 70 longOptions :: [(String, String)] 69 71 longOptions = [("--help", "-h"), ("--version", "-v")] 72 73 -- | List of options that can have their argument just after, with no space. 74 composable :: [Char] 70 75 composable = "cdlnpw" 76 77 -- | List of options that can take arguments 78 withParam :: [String] 71 79 withParam = words "e C B I M V:" 80 81 prefixOpt :: [Char] -> Maybe (String, String) 72 82 prefixOpt opt = msum $ map (findArg opt) withParam 83 84 findArg :: Eq a => [a] -> [a] -> Maybe ([a], [a]) 73 85 findArg arg prefix = do 74 86 param <- afterPrefix prefix arg … … 90 102 -} 91 103 104 compareArgs :: Arg -> Arg -> Ordering 92 105 compareArgs a b = compare (argRank a) (argRank b) 93 106 -
src/Pugs/Shell.hs
r2725 r3372 30 30 , runOptShowPretty :: Bool} 31 31 32 -- read some input from the user32 -- | read some input from the user 33 33 -- parse the input and return the corresponding command 34 34 getCommand :: IO Command … … 37 37 doCommand input 38 38 39 doCommand :: Maybe String -> IO Command 39 40 doCommand Nothing = return CmdQuit 40 41 doCommand (Just line) -
src/RRegex/PCRE.hs
r2845 r3372 43 43 deriving (Show, Eq, Ord) 44 44 45 fi :: (Num b, Integral a) => a -> b 45 46 fi x = fromIntegral x 46 47 -
src/Unicode.hs
r2725 r3372 222 222 toLower :: Char -> Char 223 223 224 -- | Convert a letter to the cooresponding title-case letter, leaving any 225 -- other character unchanged. Any Unicode letter which has a title-case 226 -- equivalent is transformed. 227 toTitle :: Char -> Char 228 224 229 -- ----------------------------------------------------------------------------- 225 230 -- Implementation with the supplied auto-generated Unicode character properties
