protected override MatchContext Match(Ust ust, MatchContext context)
        {
            var unaryOperatorLiteral = ust as UnaryOperatorLiteral;

            if (unaryOperatorLiteral == null)
            {
                return(context.Fail());
            }

            return(UnaryOperator.Equals(unaryOperatorLiteral.UnaryOperator)
                ? context.AddMatch(unaryOperatorLiteral)
                : context.Fail());
        }
Beispiel #2
0
        /// <summary>
        /// Checks if this expression can generate an empty word.
        /// </summary>
        /// <returns></returns>
        public bool GeneratesEmptyWord()
        {
            //if (role.Equals(PartialExpressionRole.EmptyWord))
            //	return true;

            if (_operator.Equals(UnaryOperator.KleeneStar))
            {
                return(true);
            }

            switch (role)
            {
            case PartialExpressionRole.EmptyWord:
                return(true);

            case PartialExpressionRole.Union:
                if (parts.Any(x => x.GeneratesEmptyWord()))
                {
                    return(true);
                }
                break;

            case PartialExpressionRole.Concatenation:
                if (parts.All(x => x.GeneratesEmptyWord()))
                {
                    return(true);
                }
                break;
            }

            //if (role.Equals(PartialExpressionRole.Union)
            //	&& parts.Any(x => x.GeneratesEmptyWord()))
            //	return true;

            //if (role.Equals(PartialExpressionRole.Concatenation)
            //	&& parts.All(x => x.GeneratesEmptyWord()))
            //	return true;

            return(false);
        }