fix: support comma-separated behavioral properties without repeating 'is'
Allows `is pure, commutative` syntax in addition to `is pure is commutative`. After the initial `is`, comma-separated properties no longer require repeating the `is` keyword (though it's still accepted for compatibility). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -879,7 +879,8 @@ impl Parser {
|
||||
Ok(effects)
|
||||
}
|
||||
|
||||
/// Parse behavioral properties: is pure, is total, is idempotent, etc.
|
||||
/// Parse behavioral properties: is pure, total, idempotent, etc.
|
||||
/// Supports: `is pure`, `is pure is total`, `is pure, total`, `is pure, is total`
|
||||
fn parse_behavioral_properties(&mut self) -> Result<Vec<BehavioralProperty>, ParseError> {
|
||||
let mut properties = Vec::new();
|
||||
|
||||
@@ -901,9 +902,15 @@ impl Parser {
|
||||
let property = self.parse_single_property()?;
|
||||
properties.push(property);
|
||||
|
||||
// Optional comma for multiple properties: is pure, is total
|
||||
if self.check(TokenKind::Comma) {
|
||||
self.advance();
|
||||
// After first property, allow comma-separated list without repeating 'is'
|
||||
while self.check(TokenKind::Comma) {
|
||||
self.advance(); // consume comma
|
||||
// Allow optional 'is' after comma: `is pure, is total` or `is pure, total`
|
||||
if self.check(TokenKind::Is) {
|
||||
self.advance();
|
||||
}
|
||||
let property = self.parse_single_property()?;
|
||||
properties.push(property);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user