MCPcopy Create free account
hub / github.com/davidblewett/rure-python / add_capture_name

Method add_capture_name

regex/regex-syntax/src/ast/parse.rs:438–454  ·  view source on GitHub ↗

Adds the given capture name to this parser. If this capture name has already been used, then an error is returned.

(&self, cap: &ast::CaptureName)

Source from the content-addressed store, hash-verified

436 /// Adds the given capture name to this parser. If this capture name has
437 /// already been used, then an error is returned.
438 fn add_capture_name(&self, cap: &ast::CaptureName) -> Result<()> {
439 let mut names = self.parser().capture_names.borrow_mut();
440 match names.binary_search_by_key(
441 &cap.name.as_str(),
442 |c| c.name.as_str(),
443 ) {
444 Err(i) => {
445 names.insert(i, cap.clone());
446 Ok(())
447 }
448 Ok(i) => {
449 Err(self.error(cap.span, ast::ErrorKind::GroupNameDuplicate {
450 original: names[i].span,
451 }))
452 }
453 }
454 }
455
456 /// Return whether the parser should ignore whitespace or not.
457 fn ignore_whitespace(&self) -> bool {

Callers 1

parse_capture_nameMethod · 0.80

Calls 5

parserMethod · 0.80
cloneMethod · 0.80
as_strMethod · 0.45
insertMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected