Exemplo n.º 1
0
 private static ILexerRule CreateNotSingleQuoteLexerRule()
 {
     var start = new DfaState();
     var final = new DfaState(true);
     var terminal = new NegationTerminal(new Terminal('\''));
     var edge = new DfaEdge(terminal, final);
     start.AddEdge(edge);
     final.AddEdge(edge);
     return new DfaLexerRule(start, new TokenType("not-single-quote"));
 }
Exemplo n.º 2
0
        private static ILexerRule CreateNotDoubleQuoteLexerRule()
        {
            // ( [^"\\] | (\\ .) ) +
            var start = new DfaState();
            var escape = new DfaState();
            var final = new DfaState(true);

            var notQuoteTerminal = new NegationTerminal(
                new SetTerminal('"', '\\'));
            var escapeTerminal = new Terminal('\\');
            var anyTerminal = new AnyTerminal();

            var notQuoteEdge = new DfaEdge(notQuoteTerminal, final);
            start.AddEdge(notQuoteEdge);
            final.AddEdge(notQuoteEdge);

            var escapeEdge = new DfaEdge(escapeTerminal, escape);
            start.AddEdge(escapeEdge);
            final.AddEdge(escapeEdge);

            var anyEdge = new DfaEdge(anyTerminal, final);
            escape.AddEdge(anyEdge);

            return new DfaLexerRule(start, new TokenType("not-double-quote"));
        }