MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / read_string

Method read_string

compiler/src/modules/packages/manifest.rs:118–142  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

116 }
117
118 fn read_string(&mut self) -> Result<String, String> {
119 self.expect(b'"', "expected '\"' starting a string")?;
120 let mut out = String::new();
121 loop {
122 match self.peek() {
123 None => return Err(s!("unterminated string in packages.json")),
124 Some(b'"') => { self.pos += 1; return Ok(out); }
125 Some(b'\\') => {
126 self.pos += 1;
127 let esc = self.peek().ok_or_else(|| s!("dangling '\\' in packages.json"))?;
128 match esc {
129 b'"' => out.push('"'),
130 b'\\' => out.push('\\'),
131 b'/' => out.push('/'),
132 b'n' => out.push('\n'),
133 b't' => out.push('\t'),
134 b'r' => out.push('\r'),
135 _ => return Err(s!("unsupported escape '\\", char esc as char, "' in packages.json")),
136 }
137 self.pos += 1;
138 }
139 Some(c) => { out.push(c as char); self.pos += 1; }
140 }
141 }
142 }
143
144 fn read_imports_into(&mut self, out: &mut Vec<(String, String)>) -> Result<(), String> {
145 self.expect(b'{', "'imports' must be an object")?;

Callers 3

parse_manifestFunction · 0.45
read_imports_intoMethod · 0.45
skip_valueMethod · 0.45

Calls 3

pushMethod · 0.80
expectMethod · 0.45
peekMethod · 0.45

Tested by

no test coverage detected