public override RegexSpec Simplify(LexerSpec lexerSpec)
        {
            // a&b&c -> !(!a|!b|!c)
            var expanded = new ComplementSpec(new AlternationSpec(Expressions.Select(exp => new ComplementSpec(exp))));

            return(expanded.Simplify(lexerSpec));
        }
Beispiel #2
0
        protected override RegexSpec Simplify(LexerSpec lexerSpec, RegexSpec exp, bool changed)
        {
            // ~a -> !([^]* a [^]*)
            var anyChar       = new CharClassSpec(InversionListCodePointSet.All);
            var repetition    = new RepetitionSpec(anyChar, 0, null);
            var concatenation = new ConcatenationSpec(new[] { repetition, exp, repetition });
            var expanded      = new ComplementSpec(concatenation);

            return(expanded.Simplify(lexerSpec));
        }