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