Exemplo n.º 1
0
        internal static IList <ParseNode> AncestorsAndSelf(this ParseNode node)
        {
            var result = node.Ancestors().Reverse().ToList();

            result.Add(node);

            return(result);
        }
Exemplo n.º 2
0
        internal static IEnumerable <ParseNode> AncestorsToIntersection(this ParseNode segment, ParseNode lastFoundSegment)
        {
            if (segment.Prefix != Prefixes.S)
            {
                throw new ParserException("Not a segment " + segment.Name);
            }

            var lastParents = lastFoundSegment.Ancestors();
            var parents     = segment.Ancestors().ToList();
            var intersect   = parents.Select(n => n.Name).Intersect(lastParents.Select(n => n.Name)).ToList();
            var result      = parents.TakeWhile(parent => parent.Name != intersect.First()).Reverse().ToList();

            if (!result.Any() && segment.IsTrigger)
            {
                result.Add(segment.Parent);
            }

            result.Add(segment);

            return(result);
        }
Exemplo n.º 3
0
 internal static ParseNode Root(this ParseNode parseNode)
 {
     return(parseNode.Ancestors().Last());
 }