Exemple #1
0
        private void OnAdd(string item)
        {
            char key = Utils.Cast(item[0]);


            CharGroup group = mGroup[key];

            if (group == null)
            {
                group = new CharGroup(key, MaxBlank);
                //group = new CharGroup(key);
                mGroup[key] = group;
            }
            group.Add(item);
        }
Exemple #2
0
        private IList <MatchItem> OnMatchs(char[] data, int length, bool matchFirst = false)
        {
            IList <MatchItem> result = new List <MatchItem>();
            Rule rule  = Rule1;
            int  index = 0;

            while (index < length)
            {
                CharGroup group = mGroup[Utils.Cast(data[index])];
                if (group != null)
                {
                    MatchItem item = group.Match(data, index);
                    if (item.IsMatch)
                    {
                        result.Add((MatchItem)item.Clone());
                        index           = item.EndIndex() + 1;
                        rule.mLastIndex = -10;
                        if (matchFirst)
                        {
                            return(result);
                        }
                    }
                    else
                    {
                        rule.Add(data, index);
                        index++;
                    }
                }
                else
                {
                    rule.Add(data, index);
                    index++;
                }
            }
            if (rule.Count > 2)
            {
                OnRule(data, rule, result);
            }
            return(result);
        }