RunOnChildren() public method

public RunOnChildren ( ParseTree>.Func fn ) : void
fn ParseTree>.Func
return void
Esempio n. 1
0
 private ParseTree RunWeaveMacro(ParseTree source)
 {
     if (IsWeave(source))
     {
         var leftSide = source.Children.ElementAt(1);
         var rightSide = source.Children.ElementAt(2);
         var count = new Utils.Wrapper<Int32>(0);
         ReplacePlaceholder(rightSide, leftSide, count);
         if (count.Item == 0)
         {
             RaiseErrorAt(
                 "No replacement in postfix call (->, $).",
                 source.StartPos, source.EndPos);
         }
         return RunWeaveMacro(rightSide);
     }
     else
     {
         source.RunOnChildren(RunWeaveMacro);
         return source;
     }
 }
Esempio n. 2
0
 private ParseTree ReplacePlaceholder(ParseTree source, ParseTree replacement, Utils.Wrapper<Int32> count)
 {
     if (source.Content == "$" && source.Label == ParseTree.Labels.Placeholder)
     {
         if (count.Item > 0)
         {
             RaiseErrorAt(
                 "More than one replacement in postfix call (->, $).",
                 source.StartPos, source.EndPos);
         }
         count.Item ++;
         return replacement;
     }
     else if (IsWeave(source))
     {
         return source;
     }
     else
     {
         source.RunOnChildren(pt => ReplacePlaceholder(pt, replacement, count));
         return source;
     }
 }