Beispiel #1
0
 protected virtual void VisitChildren(PtNode node)
 {
     foreach (var child in reflect.Or(node))
     {
         Dispatch(child);
     }
 }
Beispiel #2
0
        protected override void VisitChildren(PtNode node)
        {
            var children = reflect.Or(node).ToList();

            if (children.Count == 0)
            {
                for (var i = node.Span.Start; i < node.Span.Next; ++i)
                {
                    Set.Add(i);
                }
                if (node is PtArguments ||
                    node is PtParameters ||
                    node is PtLambdaParameters ||
                    node is PtLambdaTypeParameters ||
                    node is PtFields ||
                    node is PtMethods ||
                    node is PtUnit)
                {
                }
                else
                {
                    var text = node.Span.ToString();
                    Debug.Assert(!string.IsNullOrWhiteSpace(text));
                    Debug.Assert(text != "(-)");
                    //System.Console.WriteLine($"{text}");
                }
            }

            base.VisitChildren(node);
        }
Beispiel #3
0
        private List <PropertyInfo> GetProps(PtNode node)
        {
            var type = node.GetType();

            if (!cache.TryGetValue(type, out var props))
            {
                props = GetProps(type);
                cache.Add(type, props);
            }

            return(props);
        }
Beispiel #4
0
 public IEnumerable <PtNode> Or(PtNode node)
 {
     foreach (var info in GetProps(node))
     {
         if (typeof(PtNode).IsAssignableFrom(info.PropertyType))
         {
             var child = (PtNode?)info.GetValue(node);
             if (child != null)
             {
                 yield return(child);
             }
         }
         else if (typeof(PonyTokenSpan).IsAssignableFrom(info.PropertyType))
         {
         }
         else if (typeof(bool).IsAssignableFrom(info.PropertyType))
         {
         }
         else if (info.PropertyType.IsEnum)
         {
         }
         else if (typeof(IEnumerable <PtNode>).IsAssignableFrom(info.PropertyType))
         {
             var value = (IEnumerable <PtNode>?)info.GetValue(node);
             if (value != null)
             {
                 foreach (var child in value)
                 {
                     yield return(child);
                 }
             }
         }
         else
         {
             Debug.Assert(false);
         }
     }
 }
Beispiel #5
0
 private void Dispatch(PtNode node)
 {
     DoVisit(node as dynamic);
 }
Beispiel #6
0
 private void DoVisit(PtNode node)
 {
     throw new System.NotImplementedException($"node type `{node.GetType().Name}´ not implemented");
 }
Beispiel #7
0
 public void Visit(PtNode root)
 {
     Dispatch(root);
 }
Beispiel #8
0
 private PonyTokenSpan Mark(PtNode node)
 {
     Debug.Assert(next <= limit);
     Debug.Assert(marks.Count > 0);
     return(new PonyTokenSpan(Tokens, node.Span.Start, next));
 }