| | 1 | The contracts specification of CIVL-C is based on ACSL, with additional primitives and constructs for various purposes, such as function guard, function dependency, MPI function behavior, etc. |
| | 2 | |
| | 3 | == overview == |
| | 4 | The grammar for the contract specification of a function is as follows: |
| | 5 | |
| | 6 | {{{ |
| | 7 | contract: requires* terminates? decreases? simple* behavior* completeness* ; |
| | 8 | requires: 'Requires' e ';' ; |
| | 9 | ... |
| | 10 | simple: ensures | assumes | assigns | reads | guards | depends | ... ; |
| | 11 | ensures: 'Ensures' e ';' ; |
| | 12 | assumes: 'Assumes' e ';' ; |
| | 13 | assigns: 'Assigns' e (',' e)* ';' ; |
| | 14 | reads: 'Reads' e (',' e)* ';' ; |
| | 15 | depends: 'Depends' e (',' e)* ';' ; |
| | 16 | ... |
| | 17 | behavior: 'Behavior' id ':' behaviorBody ; |
| | 18 | behaviorBody: behaviorClause+; |
| | 19 | behaviorClause: assumes | requires | simple ; |
| | 20 | completeness: 'Complete' (id (',' id)*)? |
| | 21 | | 'Disjoint' (id (',' id)*)? |
| | 22 | ; |
| | 23 | }}} |
| | 24 | |
| 7 | | * `ensures e;` |
| 8 | | * `assumes e;` |
| 9 | | * `assigns e0, e1, ...;` |
| 10 | | * `allocates e0, e1, ...;` |
| 11 | | * `frees e0, e1, ...;` |
| 12 | | * `guards e;` |
| 13 | | * `reads e0, e1, ...;` |
| 14 | | * `depends e0, e1, ...;` |
| | 31 | * `Ensures e;`: postcondition, `e` has `Bool` type and should hold when the function terminates |
| | 32 | * `Assumes e;`: assumption, `e` has `Bool` type |
| | 33 | * `Assigns e0, e1, ...;`: side-effects, `e0, e1, ...` have `Mem` type |
| | 34 | * absence of `Assigns` clause does NOT mean that the function has no side-effects |
| | 35 | * `Assigns \nothing`: means that the function has no side-effects |
| | 36 | * `Allocates e0, e1, ...;`: memory units allocated by the function, `e0, e1, ...` have `Mem` type |
| | 37 | * `Frees e0, e1, ...;`: memory units deallocated by the function, `e0, e1, ...` have `Mem` type |
| | 38 | * `Guards e;`: guard of the function, where `e` has `Bool` type |
| | 39 | * `Reads e0, e1, ...;`: memory access, where `e0, e1, ...` have `Mem` type |
| | 40 | * similar to `Assigns` |
| | 41 | * absence of `Reads` clause does NOT mean that the function does NOT read anything |
| | 42 | * `Reads \nothing`: means that the function does NOT read the memory |
| | 43 | * `Depends e0, e1, ...;`: dependency relation, where `e0, e1, ...` have `Mem` type |
| | 44 | * Note: `Guards`, `Depends` and `Reads` are CIVL extension for ACSL |