예제 #1
0
        // General convention in parsing methods: All whitespaces are consumed immediately after advancing the position.
        // Methods can assume they do not need to advance past whitespace when they are called.
        #region Parsing methods
        private RootFilter ParseRootFilter()
        {
            bool includeDependents = false;

            // Parse dependency selection. This may only be specified at the beginning of the root filter, outside any grouping
            if (MatchesNext(LegacyDependentsFlag))
            {
                includeDependents = true;
                m_position++;
            }

            SkipWhitespace();

            PipFilter filter = ParseExpression();

            if (includeDependents)
            {
                filter = new DependentsFilter(filter);
            }

            return(new RootFilter(filter, m_expression));
        }
예제 #2
0
        private PipFilter ParseFilterGroup()
        {
            string matched;

            if (TryMatch(DependentsFunction, out matched) ||
                TryMatch(DependenciesFunction, out matched) ||
                TryMatch(RequiredInputsFunction, out matched) ||
                TryMatch(CopyDependentsFunction, out matched))
            {
                AdvancePast(matched);
                SkipWhitespace();

                // Filter functions (i.e. dpt) is only allowed outside of group operators (). Check that the next character is the start
                // of a group but don't consume is since that is handled by the recursive call
                if (!MatchesNext(StartGroup))
                {
                    throw CreateException(ErrorMessages.FilterFunctionMustBeOustideOfGroupDelimiters, StartGroup, EndGroup, DependentsFunction);
                }

                PipFilter result = ParseFilterGroup();
                switch (matched)
                {
                case DependentsFunction:
                    result = new DependentsFilter(result);
                    break;

                case DependenciesFunction:
                    result = new DependenciesFilter(result);
                    break;

                case RequiredInputsFunction:
                    result = new DependenciesFilter(result, ClosureMode.DirectExcludingSelf);
                    break;

                case CopyDependentsFunction:
                default:
                    Contract.Assert(matched == CopyDependentsFunction, "Unexpected match");
                    result = new CopyDependentsFilter(result);
                    break;
                }

                return(result);
            }
            else if (MatchesNext(Negation))
            {
                ExpectAndAdvancePast(Negation);
                SkipWhitespace();

                // Negation is only allowed outside of group operators (). Check that the next character is the start
                // of a group but don't consume is since that is handled by the recursive call
                if (!MatchesNext(StartGroup))
                {
                    throw CreateException(ErrorMessages.NetagionMustBeOustideOfGroupDelimiters, StartGroup, EndGroup);
                }

                PipFilter result = ParseFilterGroup();
                result = result.Negate();
                return(result);
            }
            else if (MatchesNext(StartGroup))
            {
                ExpectAndAdvancePast(StartGroup);
                SkipWhitespace();
                PipFilter result = ParseExpression();
                ExpectAndAdvancePast(EndGroup);
                SkipWhitespace();

                return(result);
            }
            else
            {
                return(ParseFilterTuple());
            }
        }