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