protected virtual void VisitChildren(PtNode node) { foreach (var child in reflect.Or(node)) { Dispatch(child); } }
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); }
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); }
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); } } }
private void Dispatch(PtNode node) { DoVisit(node as dynamic); }
private void DoVisit(PtNode node) { throw new System.NotImplementedException($"node type `{node.GetType().Name}´ not implemented"); }
public void Visit(PtNode root) { Dispatch(root); }
private PonyTokenSpan Mark(PtNode node) { Debug.Assert(next <= limit); Debug.Assert(marks.Count > 0); return(new PonyTokenSpan(Tokens, node.Span.Start, next)); }