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

Method class_escape

std/re/src/main/parser.rs:271–292  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

269 }
270
271 fn class_escape(&mut self) -> Result<ClassItem, ParseError> {
272 let c = self.bump().ok_or(self.err("trailing backslash"))?;
273 Ok(match c {
274 'd' => ClassItem::Digit,
275 'D' => ClassItem::NotDigit,
276 'w' => ClassItem::Word,
277 'W' => ClassItem::NotWord,
278 's' => ClassItem::Space,
279 'S' => ClassItem::NotSpace,
280 'n' => ClassItem::Ch('\n'),
281 't' => ClassItem::Ch('\t'),
282 'r' => ClassItem::Ch('\r'),
283 'f' => ClassItem::Ch('\u{0C}'),
284 'v' => ClassItem::Ch('\u{0B}'),
285 'a' => ClassItem::Ch('\u{07}'),
286 'b' => ClassItem::Ch('\u{08}'), // backspace inside a set
287 '0' => ClassItem::Ch('\0'),
288 'x' => ClassItem::Ch(self.read_hex(2)?),
289 'u' => ClassItem::Ch(self.read_hex(4)?),
290 other => ClassItem::Ch(other), // lenient, escaped literal
291 })
292 }
293
294 fn escape(&mut self) -> Result<Node, ParseError> {
295 self.bump(); // backslash

Callers 1

classMethod · 0.80

Calls 3

bumpMethod · 0.80
read_hexMethod · 0.80
errMethod · 0.45

Tested by

no test coverage detected