Changeset 3372

Show
Ignore:
Timestamp:
05/18/05 02:43:25 (3 years ago)
Author:
theorbtwo
svk:copy_cache_prev:
4945
Message:

More signatures, a few more haddocks.

Location:
src
Files:
17 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/AST/Internals.hs

    r3328 r3372  
    12911291    deriving (Show, Eq, Ord, Typeable) 
    12921292 
     1293-- | A $/ object, the return of a rx match operation. 
    12931294data VMatch = MkMatch 
    12941295    { matchOk           :: !VBool   -- success? 
     
    13011302    deriving (Show, Eq, Ord, Typeable) 
    13021303 
     1304-- | An empty failed match 
     1305mkMatchFail :: VMatch 
    13031306mkMatchFail = MkMatch False 0 0 "" [] Map.empty 
     1307 
     1308-- | Makes a successful match 
     1309mkMatchOk :: Int -> Int -> VStr -> VList -> VHash -> VMatch 
    13041310mkMatchOk   = MkMatch True 
    13051311 
  • src/Pugs/Compile/Haskell.hs

    r3105 r3372  
    99#else 
    1010 
     11import qualified Language.Haskell.TH as TH 
     12import qualified Language.Haskell.TH.Lib 
    1113import Pugs.Internals 
    12 import qualified Language.Haskell.TH as TH 
    1314import Pugs.AST 
    1415import Pugs.Run 
     
    3738 
    3839-- Haddock doesn't like Template Haskell. 
     40compile :: Exp -> Language.Haskell.TH.Lib.ExpQ 
    3941#ifndef HADDOCK 
    4042compile (Stmts stmt rest) = [| do 
  • src/Pugs/Compile/Parrot.hs

    r3352 r3372  
    4545    compile = return 
    4646 
     47padSort :: (Var, [(TVar Bool, TVar VRef)]) -> (String, [(a, b)]) -> Ordering 
    4748padSort ((a::[Char]), [(_, _)]) ((b::[Char]), [(_, _)]) 
    4849    | (head a == ':' && head b == '&') = LT 
     
    9798    compile prm = return $ text ".param pmc" <+> varText (paramName prm) 
    9899 
     100varText :: String -> Doc 
    99101varText ('$':name)  = text $ "s__" ++ name 
    100102varText ('@':name)  = text $ "a__" ++ name 
     
    102104varText x           = error $ "invalid name: " ++ x 
    103105 
     106varInit :: String -> Doc 
    104107varInit ('$':_) = text $ "PerlUndef" 
    105108varInit ('@':_) = text $ "PerlArray" 
     
    122125    return $ map ((tmp <> text "_" <>) . text) strs 
    123126 
     127incCounter :: String -> (String -> String) -> Eval Doc 
    124128incCounter key f = do 
    125129    Just ioRef <- asks envDebug 
     
    139143 
    140144 
     145label :: Doc -> Doc 
    141146label doc = doc <> text ":" 
    142147 
     148compileCond :: Compile a => String -> [a] -> Eval Doc 
    143149compileCond neg [cond, bodyIf, bodyElse] = do 
    144150    [alt, end]  <- tempLabels ["else", "endif"] 
     
    324330    return $ vcat [ argC, f tmp ] 
    325331 
     332currentStash :: Eval Doc 
    326333currentStash = fmap text $ asks envStash 
     334 
     335constPMC :: Doc -> Eval Doc 
    327336constPMC doc = do 
    328337    tmp  <- currentStash 
     
    332341        ] 
    333342 
     343compileArg :: Compile a => a -> Eval (Doc, Doc) 
    334344compileArg exp = do 
    335345    tmp  <- tempPMC 
  • src/Pugs/Embed.hs

    r2750 r3372  
    2222-- import Pugs.Embed.Ponie 
    2323 
     24evalEmbedded :: String -> String -> IO () 
    2425evalEmbedded "Parrot"  code = do 
    2526    evalParrot code 
  • src/Pugs/Eval.hs

    r3340 r3372  
    8787-- Evaluation --------------------------------------------------------------- 
    8888 
    89 -- debug :: (Pretty a) => String -> String -> a -> Eval () 
     89debug :: Pretty a => String -> (String -> String) -> String -> a -> Eval () 
    9090debug key fun str a = do 
    9191    rv <- asks envDebug 
     
    152152        (retVal $ val) 
    153153 
     154addGlobalSym :: (Pad -> Pad) -> Eval () 
    154155addGlobalSym newSym = do 
    155156    glob <- asks envGlobal 
     
    997998        | otherwise                     = False 
    998999 
     1000toGlobal :: String -> String 
    9991001toGlobal name 
    10001002    | (sigil, identifier) <- break (\x -> isAlpha x || x == '_') name 
     
    10041006 
    10051007 
     1008arityMatch :: VCode -> Int -> Int -> Maybe VCode 
    10061009arityMatch sub@MkCode{ subAssoc = assoc, subParams = prms } argLen argSlurpLen 
    10071010    | assoc == "list" || assoc == "chain" 
  • src/Pugs/External.hs

    r2725 r3372  
    2929 
    3030 
     31externExternalize :: String -> String -> String -> IO String 
    3132externExternalize "Haskell" = externalizeHaskell 
    3233externExternalize backend   = error $ "Unrecognized inline backend: " ++ backend 
    3334 
     35externLoad :: String -> FilePath -> IO [(String, [Val] -> Eval Val)] 
    3436externLoad "Haskell" = loadHaskell 
    3537externLoad backend   = error $ "Unrecognized inline backend: " ++ backend 
    3638 
     39externRequire :: String -> FilePath -> Eval () 
    3740externRequire lang name = do 
    3841    glob        <- asks envGlobal 
  • src/Pugs/Lexer.hs

    r3297 r3372  
    283283tryChoice = choice . map try 
    284284 
     285verbatimParens :: GenParser Char st a -> GenParser Char st a 
    285286verbatimParens = between (lexeme $ char '(') (char ')') 
    286287 
  • src/Pugs/Parser.hs

    r3362 r3372  
    236236    return (isMulti, isMethod, name) 
    237237 
     238maybeColon :: RuleParser ([Char] -> [Char]) 
    238239maybeColon = option id $ do 
    239240    char ':' 
     
    354355            return $ Pad scope lexDiff exp 
    355356 
     357-- | A Param representing the default (unnamed) invocant of a method on the given type. 
     358selfParam :: String -> Param 
    356359selfParam typ = MkParam 
    357360    { isInvocant    = True 
     
    536539    return $ Syn "module" [Val . VStr $ name ++ v ++ a] -- XXX 
    537540 
     541-- | The version part of a full class specification. 
     542ruleVersionPart :: RuleParser String 
    538543ruleVersionPart = do -- version - XXX 
    539544    char '-' 
     
    541546    return ('-':str) 
    542547 
     548-- | The author part of a full class specification. 
     549ruleAuthorPart :: RuleParser String 
    543550ruleAuthorPart = do -- author - XXX 
    544551    char '-' 
     
    14561463        ] 
    14571464 
     1465-- | splits the string into expressions on whitespace. 
     1466-- Implements the <> operator at parse-time. 
     1467doSplitStr :: String -> Exp 
    14581468doSplitStr str = case perl6Words str of 
    14591469    []  -> Syn "," [] 
     
    16041614 
    16051615-- Regexps 
     1616 
     1617-- | A parser returning a regex, given a hashref of adverbs and a closing delimiter. 
     1618rxLiteralAny :: Exp -> Char -> RuleParser Exp 
    16061619rxLiteralAny adverbs 
    16071620    | Syn "\\{}" [Syn "," pairs] <- adverbs 
  • src/Pugs/Prim.hs

    r3330 r3372  
    455455op1 other   = \_ -> fail ("Unimplemented unaryOp: " ++ other) 
    456456 
     457op1Exit :: Val -> Eval a 
    457458op1Exit v = do 
    458459    rv <- fromVal v 
     
    834835op2DefinedOr = undefined 
    835836 
     837op2Identity :: Val -> Val -> Eval Val 
    836838op2Identity (VObject x) (VObject y) = return $ VBool (objId x == objId y) 
    837839op2Identity (VRef ref) y = do 
  • src/Pugs/Prim/FileTest.hs

    r2961 r3372  
    1818-- Known Bugs: multiple stat()s are done, and filename isnt a boolean. 
    1919 
    20 isReadable = fileTestIO fileTestIsReadable 
    21 isWritable = fileTestIO fileTestIsWritable 
     20isReadable   :: Val -> Eval Val 
     21isReadable   = fileTestIO fileTestIsReadable 
     22isWritable   :: Val -> Eval Val 
     23isWritable   = fileTestIO fileTestIsWritable 
     24isExecutable :: Val -> Eval Val 
    2225isExecutable = fileTestIO fileTestIsExecutable 
    23 exists = fileTestIO fileTestExists 
    24 isFile = fileTestIO fileTestIsFile 
    25 isDirectory = fileTestIO fileTestIsDirectory 
    26 fileSize = fileTestIO fileTestFileSize 
    27 sizeIsZero = fileTestIO fileTestSizeIsZero 
     26exists       :: Val -> Eval Val 
     27exists       = fileTestIO fileTestExists 
     28isFile       :: Val -> Eval Val 
     29isFile       = fileTestIO fileTestIsFile 
     30isDirectory  :: Val -> Eval Val 
     31isDirectory  = fileTestIO fileTestIsDirectory 
     32fileSize     :: Val -> Eval Val 
     33fileSize     = fileTestIO fileTestFileSize 
     34sizeIsZero   :: Val -> Eval Val 
     35sizeIsZero   = fileTestIO fileTestSizeIsZero 
    2836 
    2937fileTestIO :: (Value n) => (n -> IO Val) -> Val -> Eval Val 
  • src/Pugs/Prim/List.hs

    r3067 r3372  
    1111import Pugs.Prim.Numeric 
    1212 
     13op0Zip :: [Val] -> Eval Val 
    1314op0Zip = fmap (VList . concat . op0Zip') . mapM fromVal 
    1415 
  • src/Pugs/Prim/Match.hs

    r3210 r3372  
    6666    csBytes = encodeUTF8 csChars 
    6767 
     68matchFromMR :: MatchResult Char -> Val 
    6869matchFromMR mr = VMatch $ mkMatchOk 0 0 (decodeUTF8 all) subsMatch Map.empty 
    6970    where 
  • src/Pugs/Run.hs

    r3239 r3372  
    2323-- |Run 'Main.run' with command line args.  
    2424-- See 'Main.main' and 'Pugs.Run.Args.canonicalArgs' 
     25runWithArgs :: ([String] -> IO t) -> IO t 
    2526runWithArgs f = do 
    2627    args <- getArgs 
  • src/Pugs/Run/Args.hs

    r3207 r3372  
    6767    | otherwise = ['-':opt] 
    6868 
     69-- | List of options with long and sort variants, as tupples of long, short (with the dashes). 
     70longOptions :: [(String, String)] 
    6971longOptions = [("--help", "-h"), ("--version", "-v")] 
     72 
     73-- | List of options that can have their argument just after, with no space. 
     74composable :: [Char] 
    7075composable = "cdlnpw" 
     76 
     77-- | List of options that can take arguments 
     78withParam :: [String] 
    7179withParam = words "e C B I M V:" 
     80 
     81prefixOpt :: [Char] -> Maybe (String, String) 
    7282prefixOpt opt = msum $ map (findArg opt) withParam 
     83 
     84findArg :: Eq a => [a] -> [a] -> Maybe ([a], [a]) 
    7385findArg arg prefix = do 
    7486    param <- afterPrefix prefix arg 
     
    90102-} 
    91103 
     104compareArgs :: Arg -> Arg -> Ordering 
    92105compareArgs a b = compare (argRank a) (argRank b) 
    93106 
  • src/Pugs/Shell.hs

    r2725 r3372  
    3030                          , runOptShowPretty :: Bool} 
    3131 
    32 -- read some input from the user 
     32-- | read some input from the user 
    3333-- parse the input and return the corresponding command 
    3434getCommand :: IO Command 
     
    3737    doCommand input 
    3838 
     39doCommand :: Maybe String -> IO Command 
    3940doCommand Nothing = return CmdQuit 
    4041doCommand (Just line) 
  • src/RRegex/PCRE.hs

    r2845 r3372  
    4343    deriving (Show, Eq, Ord) 
    4444 
     45fi :: (Num b, Integral a) => a -> b 
    4546fi x = fromIntegral x 
    4647 
  • src/Unicode.hs

    r2725 r3372  
    222222toLower                 :: Char -> Char 
    223223 
     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. 
     227toTitle                 :: Char -> Char 
     228 
    224229-- ----------------------------------------------------------------------------- 
    225230-- Implementation with the supplied auto-generated Unicode character properties