Skip to content

Commit

Permalink
Handle infix:<< < >> syntax; implement Num*Num -> Bool operators
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan O'Rear committed Jul 13, 2010
1 parent ab166f7 commit e92f5a9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Niecza/Actions.pm
Expand Up @@ -157,14 +157,17 @@ sub circumfix { }
sub circumfix__S_Lt_Gt { my ($cl, $M) = @_;
my $sl = $M->{nibble}{_ast};

if (!$sl->isa('Op::StringLiteral') || ($sl->text =~ /\s/)) {
if (!$sl->isa('Op::StringLiteral') || ($sl->text =~ /\S\s\S/)) {
$M->sorry("Word splitting NYI");
return;
}

$M->{_ast} = $sl;
$M->{qpvalue} = '<' . $sl->text . '>';
my ($t) = $sl->text =~ /^\s*(.*?)\s*$/;

$M->{_ast} = Op::StringLiteral->new(text => $t);
$M->{qpvalue} = '<' . $t . '>';
}
sub circumfix__S_LtLt_GtGt { goto &circumfix__S_Lt_Gt }

sub infixish { my ($cl, $M) = @_;
$M->sorry("Metaoperators NYI") if $M->{infix_postfix_meta_operator}[0];
Expand Down
24 changes: 24 additions & 0 deletions setting
Expand Up @@ -236,6 +236,30 @@ sub infix:</> { Q:NIL {
=[0] @ unbox:Double =[1] @ unbox:Double / box:Num
} }

sub infix:<< < >> { Q:NIL {
=[0] @ unbox:Double =[1] @ unbox:Double < box:Bool
} }

sub infix:<< > >> { Q:NIL {
=[0] @ unbox:Double =[1] @ unbox:Double > box:Bool
} }

sub infix:<< <= >> { Q:NIL {
=[0] @ unbox:Double =[1] @ unbox:Double <= box:Bool
} }

sub infix:<< >= >> { Q:NIL {
=[0] @ unbox:Double =[1] @ unbox:Double >= box:Bool
} }

sub infix:<< == >> { Q:NIL {
=[0] @ unbox:Double =[1] @ unbox:Double == box:Bool
} }

sub infix:<< != >> { Q:NIL {
=[0] @ unbox:Double =[1] @ unbox:Double != box:Bool
} }

sub say { Q:NIL {
=[0] dup@ .method/0:Str @ unbox:String
.plaincall/1:Console.WriteLine null:Variable
Expand Down

0 comments on commit e92f5a9

Please sign in to comment.