Skip to content

Commit

Permalink
Implement here documents
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Aug 4, 2010
1 parent 3a5bf4e commit 868644c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Niecza/Actions.pm
Expand Up @@ -178,7 +178,7 @@ sub quote__S_q { my ($cl, $M) = @_;
}

sub quote__S_Q { my ($cl, $M) = @_;
$M->{_ast} = $M->{quibble}{nibble}{_ast};
$M->{_ast} = $M->{quibble}{_ast};
}

sub quote__S_Slash_Slash { my ($cl, $M) = @_;
Expand Down Expand Up @@ -981,7 +981,13 @@ sub cgexp__S_op { my ($cl, $M) = @_;
}

sub apostrophe {}
sub quibble {}
sub quibble { my ($cl, $M) = @_;
if ($M->{babble}{B}[0]{_herelang}) { #XXX
$M->{_ast} = Op::HereStub->new(node => $M);
} else {
$M->{_ast} = $M->{nibble}{_ast};
}
}
sub tribble {}
sub babble {}
sub quotepair {}
Expand Down
24 changes: 23 additions & 1 deletion Op.pm
Expand Up @@ -228,6 +228,28 @@ use CgOp;
no Moose;
}

{
package Op::HereStub;
use Moose;
extends 'Op';

has node => (is => 'ro', required => 1);

sub zyg {
my ($self) = @_;
return ($self->node // {})->{doc}{_ast} //
die("Here document used before body defined");
}

sub code {
my ($self, $body) = @_;
$self->zyg->cgop($body);
}

__PACKAGE__->meta->make_immutable;
no Moose;
}

{
package Op::Yada;
use Moose;
Expand All @@ -236,7 +258,7 @@ use CgOp;
has kind => (isa => 'Str', is => 'ro', required => 1);

sub code {
my ($self, $cg, $body) = @_;
my ($self, $body) = @_;

CgOp::prog(
CgOp::subcall(
Expand Down

0 comments on commit 868644c

Please sign in to comment.