Dallycot
view release on metacpan or search on metacpan
lib/Dallycot/Parser.pm view on Meta::CPAN
}
elsif ( ref $right_value eq $class ) {
unshift @$right_value, $left_value;
return $right_value;
}
else {
return bless [ $left_value, $right_value ] => $class;
}
}
sub zip {
my ( undef, $left_value, $right_value ) = @_;
return _flatten_binary( undef, 'Dallycot::AST::Zip', $left_value, $right_value );
}
sub set_union {
my ( undef, $left_value, $right_value ) = @_;
return _flatten_binary( undef, 'Dallycot::AST::Union', $left_value, $right_value );
}
sub set_intersection {
my ( undef, $left_value, $right_value ) = @_;
return _flatten_binary( undef, 'Dallycot::AST::Intersection', $left_value, $right_value );
}
sub vector_index {
my ( undef, $vector, $index ) = @_;
if ( ref $vector eq 'Dallycot::AST::Index' ) {
push @{$vector}, $index;
return $vector;
}
else {
return bless [ $vector, $index ] => 'Dallycot::AST::Index';
}
}
sub vector_push {
my ( undef, $vector, $scalar ) = @_;
if ( $vector->[0] eq 'Push' ) {
push @{$vector}, $scalar;
return $vector;
}
else {
return [ Push => ( $vector, $scalar ) ];
}
}
sub defined_q {
my ( undef, $expression ) = @_;
return bless [$expression] => 'Dallycot::AST::Defined';
}
##
# Eventually, Range will be a type representing all values between
# two endpoints.
#
# Q: how to indicate open/closed endpoints
#
# ( e1 .. e2 )
# [ e1 .. e2 )
# ( e1 .. e2 ]
# [ e1 .. e2 ]
#
sub semi_range {
my ( undef, $expression ) = @_;
return bless [ $expression, undef ] => 'Dallycot::AST::BuildRange';
}
sub closed_range {
my ( undef, $left_value, $right_value ) = @_;
return bless [ $left_value, $right_value ] => 'Dallycot::AST::BuildRange';
}
sub stream_reduction {
my ( undef, $start, $function, $stream ) = @_;
return Dallycot::AST::Apply->new(
Dallycot::Value::URI->new('http://www.dallycot.net/ns/core/1.0#last'),
[ Dallycot::AST::Apply->new(
Dallycot::Value::URI->new('http://www.dallycot.net/ns/core/1.0#foldl'),
[ $start, $function, $stream ], {}
)
],
{}
);
}
sub stream_reduction1 {
my ( undef, $function, $stream ) = @_;
return Dallycot::AST::Apply->new(
Dallycot::Value::URI->new('http://www.dallycot.net/ns/core/1.0#last'),
[ Dallycot::AST::Apply->new(
Dallycot::Value::URI->new('http://www.dallycot.net/ns/core/1.0#foldl1'), [ $function, $stream ],
{}
)
],
{}
);
}
sub promote_value {
my ( undef, $expression, $type ) = @_;
if ( ref $expression eq 'Dallycot::AST::TypePromotion' ) {
push @{$expression}, $type;
return $expression;
}
else {
return bless [ $expression, $type ] => 'Dallycot::AST::TypePromotion';
}
}
sub resolve_uri {
my ( undef, $expression ) = @_;
( run in 0.528 second using v1.01-cache-2.11-cpan-140bd7fdf52 )