-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSyntax.v
59 lines (39 loc) · 1.23 KB
/
Syntax.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Require Import Vars.
Require Import PhaserMap.
(** * Programs *)
(** Declares the language of a program. *)
Inductive prog :=
| pcons : inst -> prog -> prog
| pnil : prog
with inst :=
| new_tid : tid -> inst
| fork : tid -> prog -> inst
| pm_op: PhaserMap.op -> inst
| await: phid -> nat -> inst
| c_op: cflow -> inst
with cflow :=
| skip : cflow
| loop : prog -> cflow.
Fixpoint concat (p:prog) (q:prog) :=
match p with
| pcons i p' => pcons i (concat p' q)
| pnil => q
end.
(** Declares a concrete syntax to simplify writing programs. *)
Module CST.
Notation "'END'" := (pnil).
Infix ";;" := pcons (at level 62, right associativity).
Notation "'DEREG' ( ph )" :=
(pm_op (PhaserMap.APP ph Phaser.DEREG)) (at level 65).
Notation "'REG' ( ph , t )" :=
(pm_op (PhaserMap.APP ph (Phaser.REG t))) (at level 65).
Notation "'ADV' ( ph ) " :=
(pm_op (PhaserMap.APP ph Phaser.ADV)) (at level 65).
Notation "p '<-' 'NEW_PHASER'" :=
(pm_op (PhaserMap.NEW p)) (at level 65).
Notation "t '<-' 'NEW_TID'" := (new_tid t) (at level 65).
Notation "'FORK' ( t , b ) " := (fork t b) (at level 65).
Notation "'CFLOW'" := c_op.
Notation "'LOOP' ( b )" := (c_op (loop b)).
Notation "'SKIP'" := (CFLOW skip).
End CST.