예제 #1
0
파일: Extensions.cs 프로젝트: girish66/REM
        public static string GetCompositeElement(this TypedSegment typedSegment, params string[] components)
        {
            string result = string.Empty;

            if (components != null && components.Length > 0)
            {
                result = components.Aggregate((i, j) => i + typedSegment.Delimiters.SubElementSeparator + j);
            }

            return(result);
        }
예제 #2
0
        public override TypedShakeCondition <string> AsTypedShakeCondition()
        {
            Regex currentRegex = new Regex(TargetWord);

            return(LexicalExtensions.GenerateTypedRegexCond <string>(
                       (x, y, z) =>
            {
                Match m = currentRegex.Match(x, y, z - y);
                TypedSegment output = m.Success ? new TypedSegment(m.Length, WordType, m.Index + y) : null;
                return new Tuple <bool, TypedSegment>(m.Success, output);
            }));
        }
예제 #3
0
파일: Keyword.cs 프로젝트: DrItanium/Cortex
        public override TypedShakeCondition <string> AsTypedShakeCondition()
        {
            TypedShakeCondition <string> fn = null;

            if (RequiresEqualityCheck)
            {
                fn = LexicalExtensions.GenerateTypedCond <string>(
                    (val, ind, len) =>
                {
                    bool condition   = val.Equals(TargetWord);
                    TypedSegment seg = new TypedSegment(TargetWord.Length, WordType, ind);
                    return(new Tuple <bool, TypedSegment>(condition, seg));
                });
            }
            else
            {
                fn = LexicalExtensions.GenerateMultiCharacterTypedCond(TargetWord, TargetWord);
            }
            return((x) =>
            {
                bool result = x.Value.Contains(TargetWord);
                return result ? fn(x) : null;
            });
        }
예제 #4
0
        public Tuple <bool, TypedSegment> GenerateSingularTypedDualMatch(string x, int start, int length)
        {
            TypedSegment result = (TypedSegment)GenerateSingularDualMatch0(x, start, length, true);

            return(new Tuple <bool, TypedSegment>(result != null, result));
        }