void PJson::process_quote(In& source, State& state) { if(this->scope_type == Type::Null) { this->throw_exception(state, "Value not in a scope."); } /* skip opening quotation-mark */ source.move(1, error); auto& buffer = state.name_processed ? this->value_buffer : this->name_buffer; MemBlock block = read_unescape(source, buffer); this->process_string(block, state); }
pair<Lib::MemBlock, Value> PJson::read(In& source) { State state; while(!state.complete) { /* literals can be 'un-quoted', values in 'square-brackets' don't have a name */ if(!state.reading_value && this->scope_type != Type::Array) { source.move_until(error, '\"', ':', '{', '[', '}', ']', '/'); } else { source.move_while(error, ' ', ',', '\n', '\t', '\r'); } bool move = true; char c = *source.pointer(); switch(c) { case '\"': this->process_quote(source, state); break; case ':' : if(state.reading_value) { this->throw_exception(state, "Redundant semicolon."); } state.reading_value = true; break; case '{' : case '}' : case '[' : case ']' : this->process_bracket(c, state); break; case '/' : skip_comment(source); break; default : this->process_char(source, state, move); } if(move) { source.move(1, error); } } return { state.name, state.value }; }