Ejemplo n.º 1
0
        public Value()
        {
            var str                = new String();
            var number             = new Number();
            var isTrue             = new Text("true");
            var isFalse            = new Text("false");
            var isNull             = new Text("null");
            var ws                 = new Many(new Any(" \n\r\t"));
            var opendBracket       = new Character('[');
            var closedBracket      = new Character(']');
            var opendCurlyBracket  = new Character('{');
            var closedCurlyBracket = new Character('}');
            var comma              = new Character(',');
            var colon              = new Character(':');
            var value              = new Choice(str, number, isTrue, isFalse, isNull);
            var element            = new Sequance(ws, value, ws);
            var elements           = new List(element, comma);
            var member             = new Sequance(ws, str, ws, colon, element);
            var members            = new List(member, comma);
            var obj                = new Sequance(ws, opendCurlyBracket, ws, members, ws, closedCurlyBracket, ws);
            var array              = new Sequance(ws, opendBracket, ws, elements, ws, closedBracket, ws);

            value.Add(array);
            value.Add(obj);
            this.patern = value;
        }
Ejemplo n.º 2
0
        public Number()
        {
            var minus    = new Optional(new Character('-'));
            var dot      = new Character('.');
            var zeroChar = new Character('0');
            var digit    = new Range('0', '9');
            var digits   = new Many(digit);
            var sign     = new Any("+-");
            var e        = new Any("Ee");
            var natural  = new Choice(zeroChar, new Sequance(new Range('1', '9'), digits));
            var integer  = new Sequance(minus, natural);

            this.pattern = new Sequance(integer, new Optional(new Sequance(dot, digits, new Optional(new Sequance(e, new Optional(sign), digits)))));
        }
Ejemplo n.º 3
0
        public String()
        {
            var hex = new Choice(
                new Range('0', '9'),
                new Range('a', 'f'),
                new Range('A', 'F'));
            var escaped = new Sequance(
                new Character('\\'),
                new Choice(
                    new Any("\"/bfnrt"),
                    new Sequance(
                        new Character('u'), hex, hex, hex, hex)));
            var character = new Choice(
                new Range('\u0020', '\uffff', "\"\\"),
                escaped);
            var characters    = new Many(character);
            var quotationmark = new Character('"');

            this.pattern = new Sequance(
                quotationmark,
                characters,
                quotationmark);
        }