Example #1
0
            // match longest, e.g. up to just before a failure
            protected internal override bool Match(String input, Pick.Position p)
            {
                // int bestMatch = p.index;
                int count = 0;

                for (int i = 0; i < weightedIndex.weights.Length; ++i)
                {
                    if (p.IsFailure(this, i))
                    {
                        break;
                    }
                    if (!item.Match(input, p))
                    {
                        p.SetFailure(this, i);
                        break;
                    }
                    // bestMatch = p.index;
                    count++;
                }
                if (count >= minCount)
                {
                    return(true);
                }
                // TODO fix failure
                return(false);
            }
Example #2
0
        /*
         * public static testManual() { Pick p = Pick.maybe(75,Pick.unquoted("a"));
         * testOr(p, 1); p = Pick.or(new String[]{"", "a", "bb", "ccc"}); testOr(p,
         * 3); p = Pick.repeat(3, 5, new int[]{20, 30, 20}, "a"); testOr(p, 5); p =
         * Pick.codePoint("[a-ce]"); testCodePoints(p); p =
         * Pick.codePoint("[a-ce]"); testCodePoints(p); p = Pick.string(2, 8, p);
         * testOr(p,10);
         *
         * p = Pick.or(new String[]{"", "a", "bb", "ccc"}); p =
         * Pick.and(p).and2(p).and2("&"); testMatch(p, "abb&"); testMatch(p, "bba");
         *
         * // testEnglish(); }
         */

        static internal void TestMatch(Pick p, String source)
        {
            Pick.Position pp        = new Pick.Position();
            bool          value_ren = p.Match(source, pp);

            System.Console.Out.WriteLine("Match: " + value_ren + ", " + pp);
        }
Example #3
0
            protected internal override bool Match(String input, Pick.Position p)
            {
                int len = name.Length;

                if (ILOG.J2CsMapping.Util.StringUtil.RegionMatches(input, p.index, name, 0, len))
                {
                    p.index += len;
                    return(true);
                }
                p.SetMax("literal");
                return(false);
            }
Example #4
0
            protected internal override bool Match(String s, Pick.Position p)
            {
                int cp = IBM.ICU.Text.UTF16.CharAt(s, p.index);

                if (source.Contains(cp))
                {
                    p.index += IBM.ICU.Text.UTF16.GetCharCount(cp);
                    return(true);
                }
                p.SetMax("codePoint");
                return(false);
            }
Example #5
0
            protected internal override bool Match(String input, Pick.Position p)
            {
                int originalIndex = p.index;

                for (int i = 0; i < items.Length; ++i)
                {
                    if (!items[i].Match(input, p))
                    {
                        p.index = originalIndex;
                        return(false);
                    }
                }
                return(true);
            }
Example #6
0
 // take first matching option
 protected internal override bool Match(String input, Pick.Position p)
 {
     for (int i = 0; i < weightedIndex.weights.Length; ++i)
     {
         if (p.IsFailure(this, i))
         {
             continue;
         }
         if (items[i].Match(input, p))
         {
             return(true);
         }
         p.SetFailure(this, i);
     }
     return(false);
 }
Example #7
0
 protected internal override bool Match(String s, Pick.Position p)
 {
     return(false);
 }
Example #8
0
 /*
  * (non-Javadoc)
  *
  * @see Pick#match(java.lang.String, Pick.Position)
  */
 protected internal override bool Match(String input, Pick.Position p)
 {
     // TODO Auto-generated method stub
     return(false);
 }
Example #9
0
 protected abstract internal bool Match(String input, Pick.Position p);