Esempio n. 1
0
        public static void test_list()
        {
            var context = new Context("abc");
            var chara = new Character('a');
            var charb = new Character('b');
            var charc = new Character('c');
            var list = new List(new IMatch[] { chara, charb, charc });

            // (abc)
            ExecTest(context, list);
        }
Esempio n. 2
0
        public static void test_list_backward()
        {
            var context = new Context("abc");
            var chara = new Character('a', false);
            var charb = new Character('b', false);
            var charc = new Character('c', false);
            var list = new List(new IMatch[] { chara, charb, charc }, false);

            context.offset = context.Length;
            ExecTest(context, list);
        }
Esempio n. 3
0
        public static void test_possessive()
        {
            var context = new Context("aaaab");
            var chara = new Character('a');
            var charb = new Character('b');
            var alt = new CaptureGroup(new Alternate(new IMatch[] { chara, charb }), 2);
            var posa = new Possessive(alt, 2);
            var list = new List(new IMatch[] { new CaptureGroup(posa, 1), alt });

            // (((a|b){2,}+)(a|b))
            ExecTest(context, list);
        }
Esempio n. 4
0
        public static void test_backref()
        {
            var context = new Context("aaaaab");
            var chara = new Character('a');
            var lazya = new Lazy(chara, 1);
            var cap1 = new CaptureGroup(lazya, 1);
            var back1 = new Backreference(cap1);
            var list = new List(new IMatch[] { cap1, back1 });

            // ((a+?)\1)
            ExecTest(context, list);
        }
Esempio n. 5
0
        public static void test_negative_lookbehind()
        {
            var context = new Context("abaab");
            var chara = new Character('a');
            var charb = new Character('b');
            var alt = new Alternate(new IMatch[] { chara, charb });
            var lazy = new Lazy(alt, 1);

            var backa = new Character('a', false);
            var back2a = new List(new IMatch[] { backa, backa }, false);
            var assert = new Lookaround(back2a, false);
            var list = new List(new IMatch[] { lazy, assert });

            // ((?:a|b)+?(?<!aa))
            ExecTest(context, list);
        }
Esempio n. 6
0
        public static void test_atomic()
        {
            var context = new Context("aaaab");
            var chara = new Character('a');
            var charb = new Character('b');
            var greedya = new Greedy(chara, 2);
            var atomic = new Atomic(greedya);
            var alt = new Alternate(new IMatch[] { chara, charb });
            var list = new List(new IMatch[] { new CaptureGroup(atomic, 1), alt });

            // (((?>a{2,}))(?:a|b))
            ExecTest(context, list);
        }
Esempio n. 7
0
        public static void test_negative_lookahead()
        {
            var context = new Context("aaaab");
            var chara = new Character('a');
            var greedy = new Greedy(chara, 1);
            var list2a = new List(new IMatch[] { chara, chara });
            var assert = new Lookaround(new CaptureGroup(list2a, 1), false);
            var list = new List(new IMatch[] { greedy, assert });

            // (a+(?!(aa))
            ExecTest(context, list);
        }
Esempio n. 8
0
        public static void test_greedyaltcapture()
        {
            var context = new Context("aaaaa");
            var chara = new Character('a');
            var list2a = new List(new IMatch[] { chara, chara });

            var grp1 = new CaptureGroup(chara, 1);
            var grp2 = new CaptureGroup(list2a, 2);
            var alt = new Alternate(new IMatch[] { grp1, grp2 });
            var greedy = new Greedy(alt, 1, 2);

            // ((a)|(aa)){1,2}
            ExecTest(context, greedy);
        }
Esempio n. 9
0
        public static void test_lazyalternate()
        {
            var context = new Context("aaaaa");
            var chara = new Character('a');
            var list2a = new List(new IMatch[] { chara, chara });
            var alt = new Alternate(new IMatch[] { chara, list2a });
            var lazy = new Lazy(alt, 1, 2);

            // (a|aa){1,2}?
            ExecTest(context, lazy);
        }
Esempio n. 10
0
        public static void test_repeat()
        {
            var context = new Context("aaaa");
            var chara = new Character('a');
            var list2a = new List(new IMatch[] { chara, chara });
            var alt = new Alternate(new IMatch[] { chara, list2a });
            var rep = new Repeat(alt, 2);

            // (a|aa){2}
            ExecTest(context, rep);
        }
Esempio n. 11
0
        public static void test_alternatelist()
        {
            var context = new Context("aaaa");
            var chara = new Character('a');
            var list2a = new List(new IMatch[] { chara, chara });
            var list3a = new List(new IMatch[] { chara, chara, chara });
            var alt = new Alternate(new IMatch[] { chara, list2a, list3a });
            var list = new List(new IMatch[] { alt, alt });

            // (a|aa|aaa)(a|aa|aaa)
            ExecTest(context, list);
        }