Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Encode variable name information in LAD trees
  • Loading branch information
sorear committed Nov 9, 2010
1 parent ac003e7 commit 131fa77
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
15 changes: 15 additions & 0 deletions lib/Cursor.cs
Expand Up @@ -866,6 +866,21 @@ public class LADImp : LAD {
}
}

public class LADParam : LAD {
public readonly string name;
public LADParam(string name) { this.name = name; }

public override void ToNFA(NFA pad, int from, int to) {
int knot = pad.AddNode();
pad.nodes_l[knot].final = true;
pad.AddEdge(from, knot, null);
}

public override void Dump(int indent) {
Console.WriteLine(new string(' ', indent) + "param: " + name);
}
}

public class LADNull : LAD {
public override void ToNFA(NFA pad, int from, int to) {
pad.AddEdge(from, to, null);
Expand Down
4 changes: 2 additions & 2 deletions src/Niecza/Actions.pm
Expand Up @@ -716,8 +716,8 @@ sub metachar__S_var { my ($cl, $M) = @_;
$M->{_ast} = $cl->rxcapturize($M, $cid, $a);
return;
}
$M->{_ast} = RxOp::VarString->new(ops => $cl->rxembed($M,
$cl->do_variable_reference($M, $M->{variable}{_ast}, 1)));
$M->{_ast} = RxOp::VarString->new(param => $M->{variable}->Str,
ops => $cl->rxembed($M, $cl->do_variable_reference($M, $M->{variable}{_ast}, 1)));
}

sub rxcapturize { my ($cl, $M, $name, $rxop) = @_;
Expand Down
3 changes: 2 additions & 1 deletion src/RxOp.pm
Expand Up @@ -133,6 +133,7 @@ use CgOp;
use Moose;
extends 'RxOp';

has param => (isa => 'Maybe[Str]', is => 'ro');
has ops => (isa => 'Op', is => 'ro', required => 1);
sub opzyg { $_[0]->ops }

Expand All @@ -141,7 +142,7 @@ use CgOp;
CgOp::rxbprim('Exact', CgOp::unbox('str', CgOp::fetch(CgOp::methodcall($self->ops->cgop($body), "Str"))));
}

sub lad { ['Imp'] }
sub lad { $_[0]->param ? ['Param', $_[0]->param] : ['Imp'] }

__PACKAGE__->meta->make_immutable;
no Moose;
Expand Down

0 comments on commit 131fa77

Please sign in to comment.