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