@@ -708,20 +708,25 @@ F+F+F+F +JJJJ+ F+F+F+F ++ JJJJ' },
708
708
709
709
#>
710
710
param(
711
+ # The axiom, or starting string.
711
712
[Alias('Start', 'StartString', 'Initiator')]
712
713
[string]
713
714
$Axiom,
714
715
716
+ # The rules for expanding each iteration of the axiom.
715
717
[Alias('Rules', 'ProductionRules')]
716
718
[Collections.IDictionary]
717
719
$Rule = [Ordered]@{},
718
720
721
+ # The order of magnitude (or number of iterations)
719
722
[Alias('Iterations', 'IterationCount', 'N', 'Steps', 'N','StepCount')]
720
723
[int]
721
724
$Order = 2,
722
725
726
+ # The ways each variable will be expanded.
723
727
[Collections.IDictionary]
724
728
$Variable = @{}
729
+
725
730
)
726
731
727
732
# First, let us expand our axiom
@@ -776,20 +781,26 @@ $allMatches = @([Regex]::Matches($finalState, $MatchesAny, 'IgnoreCase,IgnorePat
776
781
$matchCache = @{}
777
782
:nextMatch foreach ($match in $allMatches) {
778
783
$m = "$match"
784
+ # If we have not mapped the match to a script,
779
785
if (-not $matchCache[$m]) {
786
+ # find the matching replacement.
780
787
foreach ($key in $Variable.Keys) {
781
788
if (-not ($match -match $key)) { continue }
782
789
$matchCache[$m] = $localReplacement[$key]
783
790
break
784
791
}
785
792
}
786
793
794
+ # If we have a script to run
787
795
if ($matchCache[$m] -is [ScriptBlock]) {
796
+ # run it
788
797
$null = . $matchCache[$m] $match
798
+ # and continue to the next match.
789
799
continue nextMatch
790
800
}
791
801
}
792
802
803
+ # return this so we can pipe and chain this method.
793
804
return $this
794
805
795
806
</Script >
0 commit comments