コード例 #1
0
        public override NFATransition Copy(NFAState state)
        {
            var copy = new NFACharRangeTransition(Inverse, IgnoreCase, state)
            {
                _contents = _contents
            };

            return(copy);
        }
コード例 #2
0
        private NFAState ParseCharSet(NFAState start)
        {
            NFAState end = new NFAState();
            NFACharRangeTransition range;

            if (PeekChar(0) == '^')
            {
                ReadChar('^');
                range = new NFACharRangeTransition(true, _ignoreCase, end);
            }
            else
            {
                range = new NFACharRangeTransition(false, _ignoreCase, end);
            }
            start.AddOut(range);
            while (PeekChar(0) > 0)
            {
                var min = (char)PeekChar(0);
                switch (min)
                {
                case ']':
                    return(end);

                case '\\':
                    range.AddCharacter(ReadEscapeChar());
                    break;

                default:
                    ReadChar(min);
                    if (PeekChar(0) == '-' &&
                        PeekChar(1) > 0 &&
                        PeekChar(1) != ']')
                    {
                        ReadChar('-');
                        var max = ReadChar();
                        range.AddRange(min, max);
                    }
                    else
                    {
                        range.AddCharacter(min);
                    }
                    break;
                }
            }
            return(end);
        }