in crates/concrete-syntax/src/models/concrete_syntax/parser.rs [176:205]
fn parse_in_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 in_constraint")?;
let capture_name = Self::extract_capture_name(capture_pair)?;
// Check for optional "not" keyword
let mut negated = false;
let mut items = Vec::new();
for next_pair in inner {
match next_pair.as_rule() {
Rule::not_keyword => negated = true,
Rule::list_items => items = Self::parse_list_items(next_pair)?,
_ => continue, // Skip other tokens like "in"
}
}
let base_constraint = CsConstraint::In {
capture: capture_name,
items,
};
if negated {
Ok(CsConstraint::Not(Box::new(base_constraint)))
} else {
Ok(base_constraint)
}
}