| 1 |
---- MODULE PlusCalExample ---- |
| 2 |
(* TLA+/PlusCal example program. *) |
| 3 |
(* Multi-line |
| 4 |
(* nested *) |
| 5 |
comment *) |
| 6 |
\* Single-line comment |
| 7 |
|
| 8 |
\* The code below appears to be a TLA+ comment but is PlusCal code which should |
| 9 |
\* always be line-counted. |
| 10 |
\* Grammar rules for PlusCal are specified in appendices A and C of A PlusCal |
| 11 |
\* User's Manual: https://lamport.azurewebsites.net/tla/c-manual.pdf |
| 12 |
(* |
| 13 |
PlusCal options (-sf) |
| 14 |
--algorithm Example { |
| 15 |
process (A = 0) { |
| 16 |
Start: skip; |
| 17 |
} |
| 18 |
} |
| 19 |
This is a comment line. |
| 20 |
*) |
| 21 |
|
| 22 |
\* The code between BEGIN( )TRANSLATION and END( )TRANSLATION should be |
| 23 |
\* line-counted as generated code. |
| 24 |
\* BEGIN TRANSLATION (chksum(pcal) = "7bf2389f" /\ chksum(tla) = "dd78b4d4") |
| 25 |
VARIABLE pc |
| 26 |
|
| 27 |
vars == << pc >> |
| 28 |
|
| 29 |
ProcSet == {0} |
| 30 |
|
| 31 |
Init == /\ pc = [self \in ProcSet |-> "Start"] |
| 32 |
|
| 33 |
Start == /\ pc[0] = "Start" |
| 34 |
/\ TRUE |
| 35 |
/\ pc' = [pc EXCEPT ![0] = "Done"] |
| 36 |
|
| 37 |
A == Start |
| 38 |
|
| 39 |
(* Allow infinite stuttering to prevent deadlock on termination. *) |
| 40 |
Terminating == /\ \A self \in ProcSet: pc[self] = "Done" |
| 41 |
/\ UNCHANGED vars |
| 42 |
|
| 43 |
Next == A |
| 44 |
\/ Terminating |
| 45 |
|
| 46 |
Spec == /\ Init /\ [][Next]_vars |
| 47 |
/\ SF_vars(A) |
| 48 |
|
| 49 |
Termination == <>(\A self \in ProcSet: pc[self] = "Done") |
| 50 |
|
| 51 |
\* END TRANSLATION |
| 52 |
|
| 53 |
==== |