Perl6-Pugs
view release on metacpan or search on metacpan
misc/pX/audreyt/p6ast.hs view on Meta::CPAN
COMPUNIT = module Main {
sub MAIN {
say 1;
}
}
my $x ::= 1;
data Value
= VConstant Unboxed -- 1
| VObject Object -- Foo.new(...)
| VForeign Foreign -- perl5:DBI.connect()
| VCode Code -- {...}
| VType Type -- ::CGI
| VCapture Capture -- \(...)
| VSignature Signature -- :(...)
package Main;
sub f (constant $x = 1) { ... }
f(); # $x retains last value
submethod BUILD (has $x) { ... }
submethod BUILD ($.x) { ... }
$Main::x
positional named named_slurpy
method f (Moose $self where {...}: ...)
(@a [$x, $y, *@rest [*, *, *, $z]] ) := [1,2,3]
sub f (:v($verbose), :$verbose, :$v) {
say $verbose;
}
f(v=>1);
f(verbose=>1);
Any $self (\)
sub f ($x, $x, $x) { }
method f ($x, $y) {}
data Param = MkParam
{ paramVariable :: Identifier
, paramTypes :: [Type] -- Static pieces of inferencer-food
, paramConstraints :: [Code] -- Dynamic pieces of runtime-mood
, paramUnpacking :: Maybe Signature
, paramDefault :: Maybe Expression
, paramLabel :: Identifier
}
data Variable
= VarLexical
{ varName :: Identifier
, callerCount :: Int
, outerCount :: Int
}
| VarDynamic
{ varName :: Identifier
, packageName :: [Identifier]
}
| VarMagic Magic
data Expression
= ExpVariable Variable
| ExpValue Value
| ExpDeref Variable
| ExpBind Expression Expression
| ExpAssign Expression Expression
| ExpControl Control
data Control
= ContCall -- lookup a routine, call it
| ContApply -- apply a Code immediately
| ContCond -- statement_control:<if>
| ContGoto -- statement_control:<goto>
| ContWhile -- statement_control:<while>
| ContForeign -- statement_control:<mycontrol>
data Statement = MkStatment
{ label :: Identifier
, pragmas :: Map Identifier Value
, expression :: Expression
}
--if 1 { 2 } else { 3 }
&statement_control:<if>.(1,2,3)
%h<1>
&statement_control<if>.wrap(...)
&statement_control<if> <== ...
( run in 2.300 seconds using v1.01-cache-2.11-cpan-5e09290becf )