lib/activefacts/cql/CQLParser.treetop in activefacts-0.8.5 vs lib/activefacts/cql/CQLParser.treetop in activefacts-0.8.6
- old
+ new
@@ -73,48 +73,57 @@
set_constraint /
presence_constraint
# REVISIT: / value_constraint
end
+ rule enforcement
+ s '(' s otherwise s action s agent? s ')' s
+ { def value; [action.text_value, agent.empty? ? nil : agent.text_value]; end }
+ /
+ ''
+ { def value; []; end }
+ end
+
# presence constraint:
rule presence_constraint
- s 'each' s ('combination' S)? role_list s 'occurs' s quantifier s 'time' s 'in' s
+ s 'each' s ('combination' S)? role_list s 'occurs' s quantifier s 'time' s enforcement 'in' s
readings_list s
c:context? ';' s
- { def value; [ nil, [ :constraint, :presence, role_list.roles, quantifier.value, readings_list.value, c.empty? ? nil : c.value ] ]; end }
+ { def value; [ nil, [ :constraint, :presence, role_list.roles, quantifier.value, readings_list.value, c.empty? ? nil : c.value, enforcement.value ] ]; end }
end
# set (exclusion, mandatory exclusion, complex equality) constraint
rule set_constraint
- s 'for' s 'each' s role_list s quantifier s 'of' s 'these' s 'holds' s ':' s
+ s 'for' s 'each' s role_list s quantifier s 'of' s 'these' s 'holds' s enforcement ':' s
readings_list s
c:context? ';' s
- { def value; [ nil, [ :constraint, :set, role_list.roles, quantifier.value, readings_list.value, c.empty? ? nil : c.value ] ]; end }
+ { def value; [ nil, [ :constraint, :set, role_list.roles, quantifier.value, readings_list.value, c.empty? ? nil : c.value, enforcement.value ] ]; end }
/
- s either? s r1:readings s or s r2:readings exclusion:(but s not s both s)? c:context? ';' s
+ s either? s r1:readings s or s r2:readings exclusion:(but s not s both s)? c:context? enforcement ';' s
{ def value;
[ nil, [ :constraint, :set,
nil, # No roles names, rely on the join
exclusion.text_value.empty? ?
- [1, nil] : # At least one (meaning 1 or 2/more)
+ [1, nil] : # At least one (meaning 1 or 2/more)
[1,1], # Exactly one (1 and only 1)
[r1.value, r2.value],
- c.empty? ? nil : c.value
+ c.empty? ? nil : c.value,
+ enforcement.value
] ];
end
}
end
rule subset_constraint
s readings s only s if s r2:readings s
- c:context? ';' s
- { def value; [ nil, [ :constraint, :subset, [readings.value, r2.value], c.empty? ? nil : c.value ] ]; end }
+ c:context? enforcement ';' s
+ { def value; [ nil, [ :constraint, :subset, [readings.value, r2.value], c.empty? ? nil : c.value, enforcement.value ] ]; end }
end
rule equality_constraint
s readings s tail:( if s and s only s if s readings s)+
- c:context? ';' s
- { def value; [ nil, [ :constraint, :equality, [readings.value] + tail.elements.map{|e| e.readings.value }, c.empty? ? nil : c.value ]]; end }
+ c:context? enforcement ';' s
+ { def value; [ nil, [ :constraint, :equality, [readings.value] + tail.elements.map{|e| e.readings.value }, c.empty? ? nil : c.value, enforcement.value ]]; end }
end
rule readings_list
readings tail:( ',' s readings )*
{ def value; [readings.value]+tail.elements.map{|e| e.readings.value }; end }