83: def parse
84: reset
85: obj = nil
86: until eos?
87: case
88: when scan(OBJECT_OPEN)
89: obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
90: @current_nesting = 1
91: obj = parse_object
92: when scan(ARRAY_OPEN)
93: obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
94: @current_nesting = 1
95: obj = parse_array
96: when skip(IGNORE)
97: ;
98: else
99: raise ParserError, "source '#{peek(20)}' not in JSON!"
100: end
101: end
102: obj or raise ParserError, "source did not contain any JSON!"
103: obj
104: end