-
Notifications
You must be signed in to change notification settings - Fork 1
Syntax and informal semantic
Pendulum's keywords are based on Esterel's keywords
sname := <ocaml-expr-ident>
label := <ocaml-expr-ident>
sstatement :=
| nothing
| pause
| emit <sname> <ocaml-expr>
| present <presence_test_expr> <statement> <statement>
| loop <statement>
| <statement> || <statement>
| <statement> ; <statement>
| signal <sname> <ocaml-expr> <statement>
| trap <label> <statement>
| exit <label>
| suspend <presence_test_expr> <statement>
| (atom | !) <ocaml-expr>
| present <presence_test_expr> <statement> (* not kernel *)
inout_decls :=
| input sname `;`
| input sname `;` inout_decls
presence_test_expr :=
| <sname> [& <ocaml-expr>]
| <sname>##<sname> [& <ocaml-expr>]
program := inout_decls statement
nothing
Does nothing.
pause
Stops and wait for the next instant.
emit <sname> <ocaml-expr>
Sets the signal <sname>
present for this instant in the environnement and
assigns it the given OCaml value
present <presence_test_expr> <statement> <statement>
Runs the first <statement>
if the signal <sname>
otherwise.
loop <statement>
Re-runs <statement>
when it stops for ever.
<statement> || <statement>
Runs the two statements in parallele. Ends when the both end.
<statement> ; <statement>
Runs the first <statement>
and then the second at the same instant the first ends.
signal <sname> <ocaml-expr> <statement>
Defines sname
as a local signal with the given initial value in the <statement>
trap <label> <statement>
Jump at the end if <statement>
runs exit <label>
exit <label>
See previous entry.
suspend <presence_test_expr> <statement>
Pauses <statement>
each instants <sname>
is present.
atom <ocaml-expr> or !<ocaml-expr>
Runs the given instantaneous OCaml expression (seen as a side effet).
present <presence_test_expr> <statement>
Same as present <sname> <statement> nothing
presence_test_expr :=
| <sname> [& <ocaml-expr>]
| <sname>##<sname> [& <ocaml-expr>]
You can add a guard to a presence test with the operator &
The syntax's precedence rules follow those of OCaml corresponding expressions :
- keywords have the function call precedence. example :
loop
atom
print_string "hello";
pause
is incorrect. The statement inside loop
must be parenthezised with begin...end
or (...)
and
so does the atom
loop begin
atom (print_string "hello");
pause
end
-
||
and;
has the same precedence than in OCaml, particularly : - Both are weaker than function calls so
loop pause || loop pause
andloop pause ; loop pause
are syntactically corrects and do what you expect -
;
is weaker than||
so :
loop
pause
||
atom (print_string "hello");
pause
is equivalent to
(
(loop pause)
||
(atom (print_string "hello"))
)
;
(
pause
)