The following syntax is used for the text input of the Guarded Commands Code, starting with a command C.
C ::=
x := a
| A[a] := a
| read x
| read A[a]
| write a
| skip
| C; C
| if GC fi
| do GC od
| continue
| break
| try C catch HC yrt
| throw e
GC ::=
b -> C
| GC [] GC
HC ::=
e: C
| HC [] HC
a ::=
n
| x
| A[a]
| a + a
| a - a
| a * a
| a / a
| a % a
| -a
| (a)
b ::=
true
| false
| b & b
| b | b
| b && b
| b || b
| !b
| a = a
| a != a
| a > a
| a >= a
| a < a
| a <= a
| (b)
Additional notes:
&& and || do short-circut evaluation (i.e. a minimal number of operands are evaluated left to right), the rest of the operators do eager evaluation (i.e. all operands are evaluted).
Precedence and associativity rules:
Precedence is highest for - (unary minus), then *, % and /, and lowest for + and -.
Precedence is highest for !, then & and &&, and lowest for | and ||.
*, %, /, +, -, &, |, &&, and || associate left to right.
!, - (unary minus), [], and ; associate right to left.
Variables x, arrays A and exceptions e match the regular expression [a-zA-Z][a-zA-Z\d_]* and can not be any of the keywords. Furthermore the three sets should be pair-wise disjoint, e.g. a variable identifier can not be used both as a variable and an array (and an exception) in the same program.
Numbers n match the regular expression \d+ and are bound by 253-1 (JavaScript Number.MAX_SAFE_INTEGER). Negative numbers are passed as unary minus -n.
A whitespace matches the regular expression [ \u00A0\f\n\r\t\v], with a mandatory whitespace after read␣, write␣, if␣, do␣, try␣, throw␣, before ␣fi, ␣od, ␣yrt, and around ␣catch␣. Whitespaces are ignored anywhere else.
pa4fun is a tool supporting the language and concepts from the notes Program Analysis – An Appetizer.
Browser Compatibility
The tool uses a responsive design and can be used on any device with a modern browser. The tool have been deveopled and tested in
Google Chrome v60,
Firefox v49,
Opera v46,
Safari v10, and
Internet Explorer v11.
About
The core functionality is written in F# and then converted to JavaScript using Fable.
License
Developed by Kasper Laursen, Hanne Riis Nielson, Panagiotis Vasilikos and Mike Castro Lundin, based on the specification developed by Hanne Riis Nielson and Flemming Nielson.
Explore how the memory changes, upon execution of the actions. Recall that if more guards are satisfied then it is non-deterministic which action to take.
If there is a non-deterministic choice it will be shown in the first column as , and if clicked the trace will be "reset" from that configuration.
For the output, all non-terminated and non-stuck configurations can be extended with 1-1000 transitions.