Exemplo n.º 1
0
        public void AddMatch(string str, bool caseInsensitive, TokenPattern value)
        {
            DFAState state;
            char     c     = str[0];
            int      start = 0;

            if (caseInsensitive)
            {
                c = Char.ToLower(c);
            }

            if (c < 128)
            {
                state = _ascii[c];
                if (state == null)
                {
                    state = _ascii[c] = new DFAState();
                }

                start++;
            }
            else
            {
                state = _nonAscii;
            }

            for (int i = start; i < str.Length; i++)
            {
                var next = state.Tree.Find(str[i], caseInsensitive);
                if (next == null)
                {
                    next = new DFAState();
                    state.Tree.Add(str[i], caseInsensitive, next);
                }

                state = next;
            }

            state.Value = value;
        }
Exemplo n.º 2
0
        public void Add(char c, bool lowerCase, DFAState state)
        {
            if (lowerCase)
            {
                c = Char.ToLower(c);
            }

            if (_value == '\0')
            {
                this._value = c;
                this._state = state;
                this._left  = new TransitionTree();
                this._right = new TransitionTree();
            }
            else if (_value > c)
            {
                _left.Add(c, false, state);
            }
            else
            {
                _right.Add(c, false, state);
            }
        }