示例#1
0
        public String()
        {
            var hex = new Choice(
                new Range('0', '9'),
                new Range('a', 'f'),
                new Range('A', 'F'));

            var quote = new Character('"');

            var escape = new Choice(
                new Any("\\\"/bfnrt"),
                new Sequence(new Character('u'), hex, hex, hex, hex));

            var character = new Choice(
                new Range(' ', '\u0021'),
                new Range('\u0023', '\u005B'),
                new Range('\u005D', '\uFFFF'),
                new Sequence(
                    new Character('\\'),
                    escape));

            ;
            var characters = new Many(character);

            this.pattern = new Sequence(quote, characters, quote);
        }
示例#2
0
        public Value()
        {
            var ws = new Many(
                new Any(" \n\r\t"));

            var value = new Choice(
                new Number(),
                new String(),
                new Text("true"),
                new Text("false"),
                new Text("null"));


            var element = new Sequence(
                ws,
                value,
                ws);

            var array = new Sequence(
                new Character('['),
                ws,
                new List(element, new Sequence(new Character(','))),
                ws,
                new Character(']'));



            var member = new Sequence(
                ws,
                new String(),
                ws,
                new Character(':'),
                element);

            var Object = new Sequence(
                new Character('{'),
                ws,
                new List(member,
                         new Character(',')),
                ws,
                new Character('}'));


            value.Add(array);
            value.Add(Object);
            pattern = element;
        }
示例#3
0
        public Value()
        {
            var value = new Choice(
                new JsonString(),
                new Number(),
                new Text("true"),
                new Text("false"),
                new Text("null"));
            var ws            = new Many(new Any(" \n\t\r"));
            var listForObject = new List(
                new Sequence(
                    new JsonString(),
                    new Character(':'),
                    ws,
                    value,
                    ws),
                new Sequence(
                    new Character(','),
                    ws));
            var obj = new Sequence(
                new Character('{'),
                ws,
                listForObject,
                new Character('}'));
            var array = new Sequence(
                new Character('['),
                new List(
                    new Sequence(
                        ws,
                        value,
                        ws),
                    new Character(',')),
                ws,
                new Character(']'));

            value.Add(obj);
            value.Add(array);
            this.pattern = value;
        }
示例#4
0
        public void CheckIfManyReturnsTrueMatch()
        {
            Many many = new Many(new Character('a'));

            Assert.True(many.Match("bcde").Success());
        }
示例#5
0
        public void CheckIfManyConsumesSeveralLetters()
        {
            Many many = new Many(new Character('a'));

            Assert.Equal("bc", many.Match("aaaaaaabc").RemainingText());
        }