Exemple #1
0
        /// <summary>
        /// Try match entire
        /// </summary>
        public bool TryMatchEntire(string source,
                                   int checkAt,
                                   IReadOnlyList <Token> context,
                                   out TokenDescriptionMatch match)
        {
            match = TokenDescriptionMatch.EmptyMatch;

            if (string.IsNullOrEmpty(source))
            {
                return(false);
            }
            else if (checkAt < 0 || checkAt >= source.Length)
            {
                return(false);
            }

            Tuple <int, int> location = CoreMatchEntire(source, checkAt, context);

            if (location.Item1 == checkAt && location.Item2 > 0)
            {
                match = new TokenDescriptionMatch(this, location.Item1, location.Item2, TokenMatchKind.Entire);

                return(true);
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Try match stop
        /// </summary>
        public bool TryMatchStop(string source,
                                 int startAt,
                                 IReadOnlyList <Token> context,
                                 out TokenDescriptionMatch match,
                                 string prefix)
        {
            match = TokenDescriptionMatch.EmptyMatch;

            if (string.IsNullOrEmpty(source))
            {
                return(false);
            }
            else if (startAt < 0 || startAt >= source.Length)
            {
                return(false);
            }

            Tuple <int, int> location = CoreMatchStop(source, startAt, prefix, context);

            if (location.Item1 >= startAt && location.Item2 > 0)
            {
                match = new TokenDescriptionMatch(this, location.Item1, location.Item2, TokenMatchKind.Stop);

                return(true);
            }

            return(false);
        }