Skip to content

Commit 60f18bc

Browse files
committed
added documentation for model methods
1 parent 0ccdbc2 commit 60f18bc

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

docs/user/JMLGrammar.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,38 @@ you should keep strict policy:
5454

5555
In the following, we go through each JML detail.
5656

57+
## Model methods
58+
59+
In JML, you can declare and define methods in JML annotation comments
60+
which can then (only) be used in specifications. They are treated
61+
specially as declarations and definitions of logical functions. This
62+
has two consequences:
63+
1. The syntax supported in model methods is restricted (since it must
64+
be translatable directly to a logical formula.
65+
2. All model methods must always terminate.
66+
67+
Termination is not optional, as non-termination compromises soundness
68+
of the approach. Unfortunately, termination proofs are not fully
69+
implemented yet.
70+
71+
Regarding the restricted syntax in model methods, their bodies can be
72+
be nested `if` statements around `return` statements. Local variable
73+
declarations (using `var`) are allowed. More concretely, the
74+
(simplified) part of the JML syntax for model method bodies is
75+
76+
```
77+
method_declaration : typespec IDENT param_list (method_body=mbody_block | ';')
78+
79+
mbody_block : '{' mbody_var* mbody_statement '}'
80+
81+
mbody_statement :
82+
'return' expression ';'
83+
| 'if' '(' expression ')' (mbody_statement | mbody_block) 'else' (mbody_statement | mbody_block)
84+
85+
mbody_var : 'var' IDENT '=' expression ';'
86+
```
87+
88+
5789
## Entity names
5890

5991
In a recent update of the JMLref, JML entities can carry a name. KeY

0 commit comments

Comments
 (0)