Skip to content

Commit

Permalink
VirtualUnaryTuple should reflect level N, not N+1
Browse files Browse the repository at this point in the history
  • Loading branch information
sblom committed Dec 15, 2023
1 parent ab98627 commit e6b36b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion RegExtract.Test/Usage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public void a007()

[Fact]
public void a008()
{
var plan = ExtractionPlan<List<int>>.CreatePlan(new Regex(@"(\d+ ?)+"));
var str = plan.ToString("x");
output.WriteLine(str);

var result = plan.Extract("123 456 789");
}

[Fact]
public void a009()
{
var plan = ExtractionPlan<List<(string, string)>>.CreatePlan(new Regex(@"(([a-z]+)([=-][0-9]?),?)+"));
var str = plan.ToString("x");
Expand All @@ -101,7 +111,7 @@ public void a008()
}

[Fact]
public void a009()
public void a010()
{
var plan = ExtractionPlan<List<List<List<char>>>>.CreatePlan(new Regex(@"(((\w)+ ?)+,? ?)+"));
var str = plan.ToString("x");
Expand Down
2 changes: 1 addition & 1 deletion RegExtract/ExtractionPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private ExtractionPlanNode AssignTypesToTree(RegexCaptureGroupNode tree, Type ty
{
if (tree.children.Any())
{
return new VirtualUnaryTupleNode(tree.children.Single().name, type, new[] { AssignTypesToTree(tree.children.Single(), type) }, new ExtractionPlanNode[0]);
return new VirtualUnaryTupleNode(tree.name, type, new[] { AssignTypesToTree(tree.children.Single(), type) }, new ExtractionPlanNode[0]);
}
return ExtractionPlanNode.BindLeaf(tree.name, type, groups.ToArray(), namedgroups.ToArray());
}
Expand Down

0 comments on commit e6b36b9

Please sign in to comment.