diff --git a/lib/Cursor.cs b/lib/Cursor.cs index 87f50748..5e095c28 100644 --- a/lib/Cursor.cs +++ b/lib/Cursor.cs @@ -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); diff --git a/src/Niecza/Actions.pm b/src/Niecza/Actions.pm index a47a84e4..bd15b0e9 100644 --- a/src/Niecza/Actions.pm +++ b/src/Niecza/Actions.pm @@ -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) = @_; diff --git a/src/RxOp.pm b/src/RxOp.pm index e34ceb2c..893bea4e 100644 --- a/src/RxOp.pm +++ b/src/RxOp.pm @@ -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 } @@ -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;