10.33.2.1 Syntax

The syntax of CHR rules is the following:

rules ::= rule rules
rules ::= empty

rule ::= name actual_rule pragma .

name ::= atom @
name ::= empty

actual_rule ::= simplification_rule
actual_rule ::= propagation_rule
actual_rule ::= simpagation_rule

simplification_rule ::= head <=> guard body
propagation_rule ::= head ==> guard body
simpagation_rule ::= head \ head <=> guard body

head ::= constraints

constraints ::= constraint constraint_id
constraints ::= constraint constraint_id , constraints

constraint ::= compound_term

constraint_id ::= empty
constraint_id ::= # variable

guard ::= empty
guard ::= goal |

body ::= goal

pragma ::= empty
pragma ::= pragma actual_pragmas

actual_pragmas ::= actual_pragma
actual_pragmas ::= actual_pragma , actual_pragmas

actual_pragma ::= passive(variable)

Note that the guard of a rule may not contain any goal that binds a variable in the head of the rule with a non-variable or with another variable in the head of the rule. It may however bind variables that do not appear in the head of the rule, e.g. an auxiliary variable introduced in the guard.


Send feedback on this subject.