示例#1
0
        private GlobNode Parse(GlobParserContext context)
        {
            context.Accept();

            // Parse the root.
            var items = new List <GlobNode> {
                ParseRoot(context)
            };

            if (items.Count == 1 && items[0] is RelativeRoot)
            {
                items.Add(ParseSegment(context));
            }

            // Parse all path segments.
            while (context.CurrentToken.Kind == GlobTokenKind.PathSeparator)
            {
                context.Accept();
                items.Add(ParseSegment(context));
            }

            // Not an end of text token?
            if (context.CurrentToken.Kind != GlobTokenKind.EndOfText)
            {
                throw new InvalidOperationException("Expected EOT");
            }

            // Rewrite the items into a linked list.
            var result = GlobNodeRewriter.Rewrite(items);

            GlobNodeValidator.Validate(result);
            return(result);
        }
示例#2
0
文件: GlobParser.cs 项目: vbjay/cake
        private GlobNode Parse(GlobParserContext context)
        {
            context.Accept();

            // Parse the root.
            var items = new List <GlobNode> {
                ParseRoot(context)
            };

            if (items.Count == 1 && items[0] is RelativeRootNode)
            {
                items.Add(ParseNode(context));
            }

            // Parse all path segments.
            while (context.CurrentToken?.Kind == GlobTokenKind.PathSeparator)
            {
                context.Accept();
                items.Add(ParseNode(context));
            }

            // Rewrite the items into a linked list.
            var result = GlobNodeRewriter.Rewrite(items);

            GlobNodeValidator.Validate(result);
            return(result);
        }