fn parse_regex_constraint()

in crates/concrete-syntax/src/models/concrete_syntax/parser.rs [207:236]


  fn parse_regex_constraint(pair: Pair<Rule>) -> Result<CsConstraint, String> {
    let mut inner = pair.into_inner();

    // First should be the capture
    let capture_pair = inner.next().ok_or("Expected capture in regex_constraint")?;
    let capture_name = Self::extract_capture_name(capture_pair)?;

    // Check for optional "not" keyword
    let mut negated = false;
    let mut pattern = String::new();

    for next_pair in inner {
      match next_pair.as_rule() {
        Rule::not_keyword => negated = true,
        Rule::regex_pattern => pattern = Self::parse_regex_pattern(next_pair)?,
        _ => continue, // Skip other tokens like "matches"
      }
    }

    let base_constraint = CsConstraint::Regex {
      capture: capture_name,
      pattern,
    };

    if negated {
      Ok(CsConstraint::Not(Box::new(base_constraint)))
    } else {
      Ok(base_constraint)
    }
  }