public Value() { var value = new Choice( new String(), new Number(), new Text("true"), new Text("false"), new Text("null") ); var whitespaces = new Many(new Any(" \n\r\t")); var validValue = new Sequence(whitespaces, value, whitespaces); var arrayValue = new List(validValue, new Character(',')); var objectValue = new Sequence(new String(), whitespaces, new Character(':'), validValue); var array = new Sequence( whitespaces, new Character('['), whitespaces, arrayValue, whitespaces, new Character(']'), whitespaces ); value.Add(array); var objects = new Sequence( whitespaces, new Character('{'), whitespaces, new List(objectValue, new Sequence(new Character(','), whitespaces)), whitespaces, new Character('}'), whitespaces); value.Add(objects); pattern = value; }
public String() { var quotation = new Character('"'); var character = new Choice( new Range(' ', '!'), new Range('#', '.'), new Range('0', '['), new Range(']', (char)ushort.MaxValue) ); var hex = new Choice( new Range('0', '9'), new Range('a', 'f'), new Range('A', 'F') ); var escapeCharacters = new Any("\"\\/bfnrt"); var unicode = new Sequence( new Character('u'), hex, hex, hex, hex); var validEscapeCharacters = new Sequence( new Character('\\'), new Choice(escapeCharacters, unicode)); var text = new Many( new Choice( character, validEscapeCharacters)); pattern = new Sequence(quotation, text, quotation); }