Changeset 342
- Timestamp:
- 02/28/05 20:25:26 (4 years ago)
- svk:copy_cache_prev:
- 1619
- Files:
-
- 1 removed
- 119 modified
-
AUTHORS (modified) (1 prop)
-
ChangeLog (modified) (1 prop)
-
LICENSE/Artistic-2 (modified) (1 prop)
-
LICENSE/GPL-2 (modified) (1 prop)
-
MANIFEST (modified) (1 prop)
-
MANIFEST.SKIP (modified) (1 prop)
-
META.yml (modified) (1 prop)
-
Makefile.PL (modified) (1 diff, 2 props)
-
README (modified) (1 prop)
-
SIGNATURE (modified) (1 prop)
-
docs/01Overview.html (modified) (1 prop)
-
examples/fp.p6 (modified) (1 prop)
-
examples/life.p6 (modified) (1 prop)
-
examples/mandel.p6 (modified) (1 prop)
-
examples/quicksort.p6 (modified) (1 prop)
-
examples/sendmoremoney.p6 (modified) (1 prop)
-
examples/shuffle.p6 (modified) (1 prop)
-
inc/Module/Install.pm (modified) (1 prop)
-
inc/Module/Install/Base.pm (modified) (1 prop)
-
inc/Module/Install/Can.pm (modified) (1 prop)
-
inc/Module/Install/Fetch.pm (modified) (1 prop)
-
inc/Module/Install/Makefile.pm (modified) (1 prop)
-
inc/Module/Install/Metadata.pm (modified) (1 prop)
-
inc/Module/Install/Scripts.pm (modified) (1 prop)
-
inc/Module/Install/Win32.pm (modified) (1 prop)
-
inc/Module/Install/WriteAll.pm (modified) (1 prop)
-
inc/Test/Harness.pm (modified) (1 prop)
-
inc/Test/Harness/Assert.pm (modified) (1 prop)
-
inc/Test/Harness/Iterator.pm (modified) (1 prop)
-
inc/Test/Harness/Straps.pm (modified) (1 prop)
-
inc/Test/Harness/TAP.pod (modified) (1 prop)
-
lib/Perl6/Pugs.pm (modified) (1 prop)
-
lib/Perl6/lib/Kwid.pm (modified) (1 prop)
-
lib/Perl6/lib/Test.pm (modified) (1 prop)
-
lib/Perl6/lib/perlkwid.kwid (modified) (1 prop)
-
src/AST.hs (modified) (15 diffs, 2 props)
-
src/Bind.hs (modified) (3 diffs, 2 props)
-
src/Cont.hs (modified) (1 diff, 2 props)
-
src/Context.hs (modified) (4 diffs, 2 props)
-
src/Eval.hs (modified) (17 diffs, 2 props)
-
src/Help.hs (modified) (1 diff, 2 props)
-
src/Internals.hs (modified) (4 diffs, 2 props)
-
src/Junc.hs (modified) (2 diffs, 2 props)
-
src/Lexer.hs (modified) (4 diffs, 2 props)
-
src/Main.hs (modified) (3 diffs, 2 props)
-
src/Monads.hs (modified) (3 diffs, 2 props)
-
src/Parser.hs (modified) (6 diffs, 2 props)
-
src/Posix.hs (modified) (1 diff, 2 props)
-
src/Pretty.hs (modified) (2 diffs, 2 props)
-
src/Prim.hs (modified) (3 diffs, 2 props)
-
src/Rule.hs (modified) (2 props)
-
src/Rule/Char.hs (modified) (1 diff, 2 props)
-
src/Rule/Combinator.hs (modified) (1 diff, 2 props)
-
src/Rule/Error.hs (modified) (3 diffs, 2 props)
-
src/Rule/Expr.hs (modified) (2 props)
-
src/Rule/LICENSE (modified) (1 prop)
-
src/Rule/Language.hs (modified) (2 props)
-
src/Rule/Perm.hs (modified) (2 props)
-
src/Rule/Pos.hs (modified) (4 diffs, 2 props)
-
src/Rule/Prim.hs (modified) (8 diffs, 2 props)
-
src/Rule/Token.hs (modified) (2 props)
-
src/Shell.hs (modified) (1 diff, 2 props)
-
src/builtins.pod (modified) (1 prop)
-
t/01basic.t (modified) (2 props)
-
t/02atoms.t (modified) (2 props)
-
t/03operator.t (modified) (2 diffs, 2 props)
-
t/06sub.t (modified) (2 props)
-
t/Dialects/perlego/isrw.t (modified) (2 props)
-
t/Dialects/perlego/sigilless.t (modified) (2 props)
-
t/S03.t (deleted)
-
t/Synopsis/S01.pod (modified) (1 prop)
-
t/Synopsis/S02.pod (modified) (1 prop)
-
t/Synopsis/S03.pod (modified) (1 prop)
-
t/Synopsis/S04.pod (modified) (1 prop)
-
t/Synopsis/S05.pod (modified) (1 prop)
-
t/Synopsis/S06.pod (modified) (1 prop)
-
t/Synopsis/S09.pod (modified) (1 prop)
-
t/Synopsis/S10.pod (modified) (1 prop)
-
t/Synopsis/S11.pod (modified) (1 prop)
-
t/Synopsis/S12.pod (modified) (1 prop)
-
t/Synopsis/S13.pod (modified) (1 prop)
-
t/base/anon_block.t (modified) (2 props)
-
t/base/cond.t (modified) (2 props)
-
t/base/for.t (modified) (2 props)
-
t/base/if.t (modified) (2 props)
-
t/base/num.t (modified) (2 props)
-
t/base/unless.t (modified) (2 props)
-
t/base/until.t (modified) (2 props)
-
t/base/while.t (modified) (2 props)
-
t/op/append.t (modified) (2 props)
-
t/op/arith.t (modified) (2 props)
-
t/op/array.t (modified) (2 props)
-
t/op/array_ref.t (modified) (2 props)
-
t/op/auto.t (modified) (2 props)
-
t/op/binding.t (modified) (2 props)
-
t/op/bit.t (modified) (2 props)
-
t/op/defined.t (modified) (2 props)
-
t/op/die.t (modified) (2 props)
-
t/op/eq.t (modified) (2 props)
-
t/op/eval.t (modified) (2 props)
-
t/op/grep.t (modified) (2 props)
-
t/op/hash.t (modified) (2 props)
-
t/op/inc.t (modified) (2 props)
-
t/op/int.t (modified) (2 props)
-
t/op/join.t (modified) (2 props)
-
t/op/magic.t (modified) (2 props)
-
t/op/map.t (modified) (2 props)
-
t/op/multi_dimensional_array.t (modified) (2 props)
-
t/op/not.t (modified) (2 props)
-
t/op/pair.t (modified) (2 props)
-
t/op/pop.t (modified) (2 props)
-
t/op/push.t (modified) (2 props)
-
t/op/recurse.t (modified) (2 props)
-
t/op/relational.t (modified) (2 props)
-
t/op/repeat.t (modified) (2 props)
-
t/op/shift.t (modified) (2 props)
-
t/op/split.t (modified) (2 props)
-
t/op/string_interpolation.t (modified) (2 props)
-
t/op/unshift.t (modified) (2 props)
-
t/unspecced/cont.t (modified) (2 props)
Legend:
- Unmodified
- Added
- Removed
-
AUTHORS
- Property svn:eol-style set to native
-
ChangeLog
- Property svn:eol-style set to native
-
LICENSE/Artistic-2
- Property svn:eol-style set to native
-
LICENSE/GPL-2
- Property svn:eol-style set to native
-
MANIFEST
- Property svn:eol-style set to native
-
MANIFEST.SKIP
- Property svn:eol-style set to native
-
META.yml
- Property svn:eol-style set to native
-
Makefile.PL
- Property svn:mime-type set to text/plain; charset=UTF-8
- Property svn:eol-style set to native
r321 r342 115 115 postamble(<< "."); 116 116 $pugs: @{[glob("src/*.hs"), glob("src/Rule/*.hs")]} $version_h 117 ghc --make - o pugs src/Main.hs -isrc117 ghc --make -Wall -fno-warn-missing-signatures -fno-warn-name-shadowing -o pugs src/Main.hs -isrc 118 118 119 119 tags :: -
README
- Property svn:eol-style set to native
-
SIGNATURE
- Property svn:eol-style set to native
-
docs/01Overview.html
- Property svn:eol-style set to native
-
examples/fp.p6
- Property svn:eol-style set to native
-
examples/life.p6
- Property svn:eol-style set to native
-
examples/mandel.p6
- Property svn:eol-style set to native
-
examples/quicksort.p6
- Property svn:eol-style set to native
-
examples/sendmoremoney.p6
- Property svn:eol-style set to native
-
examples/shuffle.p6
- Property svn:eol-style set to native
-
inc/Module/Install.pm
- Property svn:eol-style set to native
-
inc/Module/Install/Base.pm
- Property svn:eol-style set to native
-
inc/Module/Install/Can.pm
- Property svn:eol-style set to native
-
inc/Module/Install/Fetch.pm
- Property svn:eol-style set to native
-
inc/Module/Install/Makefile.pm
- Property svn:eol-style set to native
-
inc/Module/Install/Metadata.pm
- Property svn:eol-style set to native
-
inc/Module/Install/Scripts.pm
- Property svn:eol-style set to native
-
inc/Module/Install/Win32.pm
- Property svn:eol-style set to native
-
inc/Module/Install/WriteAll.pm
- Property svn:eol-style set to native
-
inc/Test/Harness.pm
- Property svn:eol-style set to native
-
inc/Test/Harness/Assert.pm
- Property svn:eol-style set to native
-
inc/Test/Harness/Iterator.pm
- Property svn:eol-style set to native
-
inc/Test/Harness/Straps.pm
- Property svn:eol-style set to native
-
inc/Test/Harness/TAP.pod
- Property svn:eol-style set to native
-
lib/Perl6/Pugs.pm
- Property svn:eol-style set to native
-
lib/Perl6/lib/Kwid.pm
- Property svn:eol-style set to native
-
lib/Perl6/lib/Test.pm
- Property svn:eol-style set to native
-
lib/Perl6/lib/perlkwid.kwid
- Property svn:eol-style set to native
-
src/AST.hs
- Property svn:mime-type set to text/plain; charset=UTF-8
- Property svn:eol-style set to native
r222 r342 27 27 vCast v = doCast v 28 28 castV :: n -> Val 29 castV v= error $ "cannot cast into Val"29 castV _ = error $ "cannot cast into Val" 30 30 doCast :: Val -> n 31 31 doCast v = error $ "cannot cast from Val: " ++ (show v) … … 40 40 vCast v = case vCast v of 41 41 [x, y] -> (x, y) 42 other-> error $ "cannot cast into VPair: " ++ (show v)42 _ -> error $ "cannot cast into VPair: " ++ (show v) 43 43 44 44 instance Value VHash where … … 95 95 = (1 ==) . length . filter vCast $ setToList vs 96 96 97 readMVal :: MonadIO m => Val -> m Val 97 98 readMVal (MVal mv) = readMVal =<< liftIO (readIORef mv) 98 99 readMVal v = return v … … 129 130 doCast (VArray (MkArray a)) = genericLength a 130 131 doCast (VHash (MkHash h)) = fromIntegral $ sizeFM h 131 doCast x= 0/0 -- error $ "cannot cast as Num: " ++ (show x)132 doCast _ = 0/0 -- error $ "cannot cast as Num: " ++ (show x) 132 133 133 134 instance Value VComplex where … … 141 142 vCast (VBool b) = if b then "1" else "" 142 143 vCast (VInt i) = show i 143 vCast (VRat r) = showNum $ realToFrac r144 vCast (VRat r) = showNum $ (realToFrac r :: Double) 144 145 vCast (VNum n) = showNum n 145 146 vCast (VList l) = unwords $ map vCast l … … 151 152 vCast x = error $ "cannot cast as Str: " ++ (show x) 152 153 154 showNum :: Show a => a -> String 153 155 showNum x 154 156 | (i, ".0") <- break (== '.') str … … 163 165 164 166 instance Value MVal where 165 castV ref = error "bye~" --unsafePerformIO $ readIORef ref167 castV _ = error "Cannot cast MVal into Value!" 166 168 vCast (MVal x) = x 167 169 vCast (VRef v) = vCast v … … 209 211 castV = id -- XXX not really correct; need to referencify things 210 212 213 strRangeInf :: String -> [String] 211 214 strRangeInf s = (s:strRangeInf (strInc s)) 212 215 216 strRange :: String -> String -> [String] 213 217 strRange s1 s2 214 218 | s1 == s2 = [s2] … … 216 220 | otherwise = (s1:strRange (strInc s1) s2) 217 221 222 strInc :: String -> String 218 223 strInc [] = "1" 219 224 strInc "z" = "aa" … … 229 234 xs = init str 230 235 236 charInc :: Char -> Char 231 237 charInc x = chr $ 1 + ord x 232 238 239 intCast :: Num b => Val -> b 233 240 intCast x = fromIntegral (vCast x :: VInt) 234 241 … … 272 279 deriving (Show, Eq, Ord) 273 280 281 valType :: Val -> String 274 282 valType VUndef = "Any" 275 283 valType (VRef v) = valType v … … 342 350 instance (Ord a, Ord b) => Ord (FiniteMap a b) 343 351 instance Ord MVal where 344 compare x y = LT-- compare (castV x) (castV y)352 compare _ _ = EQ -- compare (castV x) (castV y) 345 353 instance Show MVal where 346 354 show _ = "<mval>" … … 369 377 instance Eq (CharParser Env Exp) 370 378 instance Ord (CharParser Env Exp) where 371 compare _ _ = LT379 compare _ _ = EQ 372 380 373 381 extractExp :: Exp -> ([Exp], [String]) -> ([Exp], [String]) 374 extractExp ex p (exps, vs) = (exp':exps, vs')375 where 376 (ex p', vs') = extract (exp, vs)382 extractExp ex (exps, vs) = (ex':exps, vs') 383 where 384 (ex', vs') = extract (ex, vs) 377 385 378 386 extract :: (Exp, [String]) -> (Exp, [String]) … … 398 406 | otherwise 399 407 = (Var name, vs) 400 extract ((Parens ex p), vs) = ((Parens exp'), vs')401 where 402 (ex p', vs') = extract (exp, vs)408 extract ((Parens ex), vs) = ((Parens ex'), vs') 409 where 410 (ex', vs') = extract (ex, vs) 403 411 extract other = other 404 412 413 cxtOfSigil :: Char -> String 405 414 cxtOfSigil '$' = "Scalar" 406 415 cxtOfSigil '@' = "Array" 407 416 cxtOfSigil '%' = "Hash" 408 417 cxtOfSigil '&' = "Code" 418 cxtOfSigil x = internalError $ "cxtOfSigil: unexpected character: " ++ (show x) 409 419 410 420 --- cxtOf '*' '$' = "List" 421 cxtOf :: Char -> Char -> String 411 422 cxtOf '*' '@' = "List" 412 423 cxtOf _ _ = "Scalar" 413 424 414 buildParam cxt sigil name exp = Param 425 buildParam :: String -> String -> String -> Exp -> Param 426 buildParam cxt sigil name e = Param 415 427 { isInvocant = False 416 428 , isSlurpy = (sigil == "*") … … 420 432 , paramName = name 421 433 , paramContext = if null cxt then defaultCxt else cxt 422 , paramDefault = e xp434 , paramDefault = e 423 435 } 424 436 where 425 437 sig = if null sigil then ' ' else head sigil 426 438 defaultCxt = cxtOf sig (head name) 439 440 defaultArrayParam :: Param 441 defaultHashParam :: Param 442 defaultScalarParam :: Param 427 443 428 444 defaultArrayParam = buildParam "" "*" "@_" (Val VUndef) -
src/Bind.hs
- Property svn:mime-type set to text/plain; charset=UTF-8
- Property svn:eol-style set to native
r334 r342 35 35 36 36 bindHash :: [Exp] -> [Param] -> MaybeError [(Param, Exp)] 37 bindHash vs[] = return []37 bindHash _ [] = return [] 38 38 bindHash [] [p] = return [ (p, emptyHashExp) ] 39 39 bindHash vs (p:ps@(_:_))= do … … 59 59 doBindArray :: Exp -> ([(Param, Exp)], VInt) -> (Param, Char) -> MaybeError ([(Param, Exp)], VInt) 60 60 doBindArray _ (xs, -1) (p, '@') = return (((p, emptyArrayExp):xs), -1) 61 doBindArray _ ( xs, -1) (p, '$') = fail $ "Slurpy array followed by slurpy scalar: " ++ show p61 doBindArray _ (_, -1) (p, '$') = fail $ "Slurpy array followed by slurpy scalar: " ++ show p 62 62 doBindArray v (xs, n) (p, '@') = return (((p, doSlice v [n..]):xs), -1) 63 63 doBindArray v (xs, n) (p, '$') = case v of 64 64 (Syn "," []) -> fail $ "Insufficient arguments for slurpy scalar" 65 65 _ -> return (((p, doIndex v n):xs), n+1) 66 doBindArray _ (_, _) (_, x) = internalError $ "doBindArray: unexpected char: " ++ (show x) 66 67 67 68 bindEmpty :: Param -> MaybeError (Param, Exp) … … 69 70 ('@':_) -> return (p, emptyArrayExp) 70 71 ('$':_) -> fail $ "Unbound slurpy scalar: " ++ show p 71 other -> error $ "Impossible - unknown slurpy sigil in param: " ++ other 72 (x:_) -> internalError $ "bindEmpty: unexpected char: " ++ (show x) 73 [] -> internalError $ "bindEmpty: empty string encountered" 72 74 73 75 isPair :: Exp -> Bool 74 isPair (Syn "=>" [(Val v), _]) = True75 isPair (Val (VPair (_, _))) = True76 isPair _ = False76 isPair (Syn "=>" [(Val _), _]) = True 77 isPair (Val (VPair (_, _))) = True 78 isPair _ = False 77 79 78 80 unPair :: Exp -> (String, Exp) -
src/Cont.hs
- Property svn:mime-type set to text/plain; charset=UTF-8
- Property svn:eol-style set to native
r23 r342 1 {-# OPTIONS -fglasgow-exts #-}1 {-# OPTIONS -fglasgow-exts -fno-warn-unused-binds #-} 2 2 3 3 {- -
src/Context.hs
- Property svn:mime-type set to text/plain; charset=UTF-8
- Property svn:eol-style set to native
r190 r342 15 15 type Cxt = String 16 16 17 countTree :: Tree Type -> Int 17 18 countTree (Node _ []) = 0 18 19 countTree (Node _ cs) = 1 + sum (map countTree cs) … … 39 40 l2 = findList target tree 40 41 42 castOk :: a -> b -> Bool 41 43 castOk _ _ = True 42 44 45 compareList :: (Eq a) => [a] -> [a] -> Int 43 46 compareList [] _ = 0 44 47 compareList _ [] = 0 … … 48 51 | otherwise = compareList l1 (init l2) 49 52 53 findList :: Eq [a] => [a] -> Tree [a] -> [[a]] 50 54 findList [] _ = [] 51 55 findList base (Node l cs) … … 56 60 found = map (findList base) cs 57 61 62 prettyTypes :: String 58 63 prettyTypes = drawTree initTree 59 64 -
src/Eval.hs
- Property svn:mime-type set to text/plain; charset=UTF-8
- Property svn:eol-style set to native
r332 r342 70 70 evaluate (Val v@(MVal mv)) = do 71 71 lvalue <- asks envLValue 72 cxt<- asks envContext72 _ <- asks envContext 73 73 if lvalue 74 74 then return v … … 122 122 shiftT $ \_ -> return $ VError str exp 123 123 124 newMVal val@(MVal r) = newMVal =<< liftIO (readIORef r)124 newMVal (MVal r) = newMVal =<< liftIO (readIORef r) 125 125 newMVal val = do 126 126 mval <- liftIO $ newIORef val 127 127 return $ MVal mval 128 128 129 writeMVal l (MVal r) = writeMVal l =<< liftIO (readIORef r)130 writeMVal (MVal l) r = liftIO $ writeIORef l r131 writeMVal l@(VError s e) _ = retError s e132 writeMVal _ l@(VError s e) = retError s e133 writeMVal x y= retError "Can't write a constant item" (Val x)129 writeMVal l (MVal r) = writeMVal l =<< liftIO (readIORef r) 130 writeMVal (MVal l) r = liftIO $ writeIORef l r 131 writeMVal (VError s e) _ = retError s e 132 writeMVal _ (VError s e) = retError s e 133 writeMVal x _ = retError "Can't write a constant item" (Val x) 134 134 135 135 -- readMVal (MVal mv) = liftIO $ readIORef mv … … 144 144 reduceStatements ([], exp) = reduceExp exp 145 145 reduceStatements (((exp, pos):rest), lastVal) 146 | Syn "sym" (Sym sym@(Symbol _ _ vexp@(Syn "sub" [ sub])):other) <- exp = do146 | Syn "sym" (Sym sym@(Symbol _ _ vexp@(Syn "sub" [_])):other) <- exp = do 147 147 (VSub sub) <- enterEvalContext "Code" vexp 148 148 lex <- asks envLexical … … 178 178 reduceStatements ((app, pos):rest, lastVal) 179 179 | null rest = do 180 cxt<- asks envContext180 _ <- asks envContext 181 181 val <- enterLex (posSyms pos) $ reduceExp exp 182 182 retVal val … … 204 204 205 205 evalVar name = do 206 env<- ask206 _ <- ask 207 207 val <- local (\e -> e{ envLValue = True }) $ do 208 208 rv <- findVar name … … 246 246 247 247 -- Reduction for mutables 248 reduce env exp@(Val val@(MVal mv)) = do248 reduce _ (Val val@(MVal _)) = do 249 249 lvalue <- asks envLValue 250 250 if lvalue … … 255 255 256 256 -- Reduction for constants 257 reduce env exp@(Val v) = do257 reduce _ (Val v) = do 258 258 return v 259 259 260 260 -- Reduction for variables 261 reduce envexp@(Var name) = do261 reduce _ exp@(Var name) = do 262 262 rv <- findVar name 263 263 case rv of … … 266 266 _ -> retError ("Undefined variable " ++ name) exp 267 267 268 reduce env(Statements stmts) = do268 reduce _ (Statements stmts) = do 269 269 let (global, local) = partition isGlobalExp stmts 270 270 reduceStatements (global ++ local, Val VUndef) … … 348 348 retVal val 349 349 "::=" -> do -- XXX wrong 350 let [Var name, exp] = exps351 val <-evalExp exp350 let [Var _, exp] = exps 351 evalExp exp 352 352 retVal VUndef -- XXX wrong 353 353 "=>" -> do … … 420 420 retVal val 421 421 422 reduce env@Env{ envClasses = cls, envContext = cxt, envLexical = lex, envGlobal = glob } exp@(App name invs args) = do422 reduce Env{ envClasses = cls, envContext = cxt, envLexical = lex, envGlobal = glob } exp@(App name invs args) = do 423 423 syms <- liftIO $ readIORef glob 424 424 subSyms <- mapM evalSym … … 428 428 ] 429 429 lens <- mapM argSlurpLen (invs ++ args) 430 case findSub (sum lens) subSyms nameof430 case findSub (sum lens) subSyms of 431 431 Just sub -> applySub subSyms sub invs args 432 otherwise-> retError ("No compatible subroutine found: " ++ name) exp432 Nothing -> retError ("No compatible subroutine found: " ++ name) exp 433 433 where
