Perl6-Pugs

 view release on metacpan or  search on metacpan

docs/summaries/2006/03-31.pod  view on Meta::CPAN

419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
and requested that someone write a Perl version at some point.
 
 
TSa noted that S03 explicitly disallows auto-reversed ranges and asked
why that was the case.  Larry Wall noted that to date, nobody wanted it.
 
 
Yuval Kogman brought up a Catalyst problem debugging the eventual
location of a die within a cascade of evals.  He suggested that Perl
6 should make it easier to trace an exception.  Larry Wall asked how
this could be done without impacting performance, and Yuval clarified
his request.
 
 
Gabor Szabo had a proposal for some alterations to C<chmod>.  There was
discussion on his suggestions.
 
=head2 Acknowledgments

examples/qotw/009r/words.spel  view on Meta::CPAN

3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
carton
cartoon
cartridge
cartwheel
Caruso
carve
carven
caryatid
Casanova
casbah
cascade
cascara
case
casebook
casein
casework
Casey
cash
cashew
cashier
cashmere

misc/pX/Common/xquery/grammar.dtd  view on Meta::CPAN

223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
         action -> State stack action.
-->
<!ELEMENT g:transition (g:description?, (g:tref | g:transition-default)+)>
<!ATTLIST g:transition
  if IDREFS #IMPLIED
  next-state IDREF #IMPLIED
  action CDATA #IMPLIED
>
 
<!--=================== Parser Production Specifications ===============-->
<!-- A production that defines a "cascade" of productions that define
     operator precedence.
         name -> the ID of the production.
         if -> space separated list of tokens for conditional processing.
-->
<!ELEMENT g:exprProduction (g:level+)>
<!ATTLIST g:exprProduction
  name ID #REQUIRED
  if IDREFS #IMPLIED
  node-type CDATA #IMPLIED
  condition CDATA #IMPLIED

src/Pugs/Prim.hs  view on Meta::CPAN

596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
op1 "log10" = op1Cast (VNum . logBase 10)
op1 "from"  = op1Cast (castV . matchFrom)
op1 "to"    = op1Cast (castV . matchTo)
op1 "matches" = op1Cast (VList . matchSubPos)
op1 "gather" = \v -> do
    evl <- asks envEval
    evl (Syn "gather" [Val v])
op1 "Thread::yield" = const $ do
    guardSTM . unsafeIOToSTM $ yield
    return $ VBool True
op1 "DESTROYALL" = \x -> cascadeMethod id "DESTROY" x VUndef
-- [,] is a noop -- It simply returns the input list
op1 "prefix:[,]" = return
op1 "prefix:$<<" = op1SigilHyper SScalar
op1 "prefix:@<<" = op1SigilHyper SArray
op1 "prefix:%<<" = op1SigilHyper SHash
op1 "prefix:&<<" = op1SigilHyper SCode
op1 "Code::assoc" = op1CodeAssoc
op1 "Code::name"  = op1CodeName
op1 "Code::arity" = op1CodeArity
op1 "Code::body"  = op1CodeBody

src/Pugs/Prim.hs  view on Meta::CPAN

708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
handleExitCode :: ExitCode -> Eval Val
handleExitCode exitCode = do
    glob    <- askGlobal
    errSV   <- findSymRef (cast "$!") glob
    writeRef errSV $ case exitCode of
        ExitFailure x   -> VInt $ toInteger x
        ExitSuccess     -> VUndef
    return (VBool $ exitCode == ExitSuccess)
 
cascadeMethod :: ([VStr] -> [VStr]) -> VStr -> Val -> Val -> Eval Val
cascadeMethod f meth v args = do
    typ     <- evalValType v
    pkgs    <- fmap f (pkgParents $ showType typ)
    named   <- case args of
        VUndef -> return Map.empty
        VType{}-> return Map.empty
        _      -> join $ doHash args hash_fetch
 
    -- Here syms is a list of (sym, tvar) tuples where tvar is the physical coderef
    -- The monad in the "do" below is List.
    syms <- forM pkgs $ \pkg -> do

src/Pugs/Prim.hs  view on Meta::CPAN

1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
    sz          <- fetchSize
    let len = if len' < 0 then if sz > 0 then (len' `mod` sz) else 0 else len'
    op4 "splice" x y (castV (sz - len)) (VList [])
op2 "sort" = \x y -> do
    xs <- fromVals x
    ys <- fromVals y
    op1 "sort" . VList $ xs ++ ys
op2 "IO::say" = op2Print hPutStrLn
op2 "IO::print" = op2Print hPutStr
op2 "printf" = op3 "IO::printf" (VHandle stdout)
op2 "BUILDALL" = cascadeMethod reverse "BUILD"
op2 "Pugs::Internals::install_pragma_value" = \x y -> do
    name <- fromVal x
    val  <- fromVal y
    idat <- asks envInitDat
    idatval <- liftSTM $ readTVar idat
    --trace ("installing " ++ name ++ "/" ++ (show val)) $ return ()
    let prag = initPragmas idatval
    liftSTM $ writeTVar idat idatval{initPragmas =
        MkPrag{ pragName=name, pragDat=val } : prag }
    return (VBool True)

t/operators/filetest.t  view on Meta::CPAN

79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
close $fh;
#if $*OS eq any <MSWin32 mingw msys cygwin> {
#  skip 1, "-z is not working on Win32 yet"
#}
#else {
  ok -z "empty_file",      "-z returns true for an empty file";
#}
unlink "empty_file";
 
# Stacked filetests
# L<S03/Changes to Perl 5 operators/"just cascade tests">
ok -e -d -r "t",               "stacking of filetest operators (1)";
ok -e -f -r $*PROGRAM_NAME, "stacking of filetest operators (2)";
ok not -e -f -r "doesnotexist.t", "stacking of filetest operators (3)";
# This one should return false *all the time* (-f and -d are mutually
# exclusive):
ok not -e -f -d "t",              "stacking of filetest operators (4-1)";
ok not -e -f -d "doesnotexist.t", "stacking of filetest operators (4-2)";
ok not -e -f -d "pugs",           "stacking of filetest operators (4-3)";
# L<S03/Changes to Perl 5 operators/"put the value in a variable">
my $sb = -e "t";

t/syntax/interpolation/strings.t  view on Meta::CPAN

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
is("Wont you take me to &func()", 'Wont you take me to func-y town', 'closure interpolation');
is("2 + 2 = { 2+2 }", '2 + 2 = 4', 'double quoted closure interpolation works');
is("&func() is where I live", 'func-y town is where I live', "make sure function interpolation doesn't eat all trailing whitespace");
 
# L<S02/Names and Variables /except when interpolating/>
is("&func. () is where I live", '&func. () is where I live', '"&func. ()" should not interpolate');
is("&func_w_args("foo","bar"))", '[foo][bar])', '"&func_w_args(...)" should interpolate');
# L<S02/"Literals" /"In order to interpolate the result of a method call">
is("$world.chars()", '5', 'method calls with parens should interpolate');
is("$world.chars", 'World.chars', 'method calls without parens should not interpolate');
is("$world.reverse.chars()", '5', 'cascade of argumentless methods, last ending in paren');
is("$world.substr(0,1)", 'W', 'method calls with parens and args should interpolate');
 
# Single quotes
# XXX the next tests will always succeed even if '' interpolation is buggy
is('Hello $world', 'Hello $world', 'single quoted string interpolation does not work (which is correct)');
is('2 + 2 = { 2+2 }', '2 + 2 = { 2+2 }', 'single quoted closure interpolation does not work (which is correct)');
is('$world @list[] %hash{} &func()', '$world @list[] %hash{} &func()', 'single quoted string interpolation does not work (which is correct)');
 
# Corner-cases
is("Hello $world!", "Hello World!", "! is not a part of var names");



( run in 0.532 second using v1.01-cache-2.11-cpan-e5176c747c2 )