Ejemplo n.º 1
0
        public MyString()
        {
            var hex = new Choices(
                new Ranges('0', '9'),
                new Ranges('a', 'f'),
                new Ranges('A', 'F'));
            var unicodeCharacters = new Sequance(
                new Charact('\\'),
                new Charact('u'),
                new Sequance(
                    hex,
                    hex,
                    hex,
                    hex));
            var escape     = new Sequance(new Charact('\\'), new Any("rntfb/\\"));
            var quotes     = new Charact('\u0022');
            var char1      = new Ranges('\u0020', '\u0021');
            var char2      = new Ranges('\u0023', '\u005B');
            var char3      = new Ranges('\u005D', '\uFFFF');
            var validChars = new Many(
                new Choices(
                    char1,
                    char2,
                    char3,
                    unicodeCharacters,
                    escape));

            pattern = new Sequance(
                quotes,
                validChars,
                quotes);
        }
Ejemplo n.º 2
0
Archivo: Value.cs Proyecto: nidarg/JSN
        public Value()
        {
            var ws    = new Many(new Any(" \r\n\t"));
            var value = new Choices(
                new MyString(),
                new Numb(),
                new Texts("true"),
                new Texts("false"),
                new Texts("null"));
            var comma         = new Sequance(new Charact(','), ws);
            var arrayElements = new MyList(value, comma);
            var openBraket    = new Sequance(ws, new Charact('['), ws);
            var closeBraket   = new Sequance(ws, new Charact(']'), ws);
            var semicolumns   = new Sequance(ws, new Charact(':'), ws);
            var open          = new Sequance(ws, new Charact('{'), ws);
            var close         = new Sequance(ws, new Charact('}'), ws);
            var array         = new Sequance(
                openBraket,
                arrayElements,
                closeBraket);
            var objectElements = new MyList(
                new Sequance(
                    new MyString(),
                    semicolumns,
                    value),
                comma);
            var newObject = new Sequance(
                open,
                objectElements,
                close);

            value.Add(array);
            value.Add(newObject);
            pattern = new Sequance(ws, value, ws);
        }
Ejemplo n.º 3
0
        public Numb()
        {
            var allDigits      = new OneOrMore(new Ranges('0', '9'));
            var dot            = new Charact('.');
            var minus          = new Charact('-');
            var zero           = new Charact('0');
            var digits         = new OneOrMore(new Ranges('1', '9'));
            var naturalNumbers = new Choices(zero, allDigits);
            var integerNumbers = new Sequance(new Optionals(minus), naturalNumbers);
            var fractionalPart = new Sequance(
                dot,
                allDigits);
            var exponentialOption = new Any("eE");
            var optionalSign      = new Any("+-");
            var exponentialPart   = new Sequance(
                exponentialOption,
                optionalSign,
                allDigits);

            pattern = new Sequance(
                integerNumbers,
                new Optionals(fractionalPart),
                new Optionals(exponentialPart));
        }