Ejemplo n.º 1
0
        private static Nfa UnitRange(RegexCharacters unitRange, bool negate)
        {
            switch (unitRange)
            {
            case RegexCharactersUnit unit:
                return(Character(unit.Character, negate));

            case RegexCharactersRange range:
                return(Range(range, negate));
            }

            throw new InvalidOperationException("Unreachable code detected.");
        }
Ejemplo n.º 2
0
        private RegexCharacterClass VisitCharacterClassNode(IInternalTreeNode node)
        {
            RegexCharacters     characterRange = null;
            RegexCharacterClass characterClass = null;

            foreach (var internalNode in node.Children.OfType <IInternalTreeNode>())
            {
                if (internalNode.Is(RegexGrammar.CharacterRange))
                {
                    characterRange = VisitCharacterRangeNode(internalNode);
                }
                else if (internalNode.Is(RegexGrammar.CharacterClass))
                {
                    characterClass = VisitCharacterClassNode(internalNode);
                }
            }

            if (characterClass == null)
            {
                return(new RegexCharacterClass(characterRange));
            }

            return(new RegexCharacterClassAlteration(characterRange, characterClass));
        }
Ejemplo n.º 3
0
 public RegexCharacterClass(RegexCharacters characterRange)
 {
     CharacterRange = characterRange;
 }
Ejemplo n.º 4
0
 public RegexCharacterClassAlteration(RegexCharacters characterRange, RegexCharacterClass characterClass)
     : base(characterRange)
 {
     CharacterClass = characterClass;
 }