-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsyntax.txt
54 lines (43 loc) · 1.42 KB
/
syntax.txt
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
Syntax rules for QPL given in EBNF
main:= statement_list
statement := ifthen
| measure
| while_loop
| proc_decl
| proc_call
| allocation
| skip
| gate_application
| block
proc_call := "call" name "(" var_list ")"
proc_decl := "proc" name ":" context "->" context block "in" statement
ifthen := "if" boolean_expr "then" statement "else" statement
measure := "measure" var "then" statement "else" statement
while_loop := "while" boolean_expr "do" statement
skip := "skip"
block := "{" stmt_list "}"
context := var ":" type { "," var ":" type }
arith_expr := number
| var
| arith_expr * arith_expr
| arith_expr + arith_expr
| arith_expr - arith_expr
| arith_expr / arith_expr
| (arith_expr)
boolean_expr := arith_expr { cmp_op arith_expr }
| !boolean_expr
| boolean_expr boolean_op boolean_expr
| "true"
| "false"
cmp_op := "<" | ">" | "<=" | ">=" | "!="
boolean_op := "&" | "|"
proc_call := "call" name "(" var_list ")"
gate_application := var_list "*=" var
var_list := var { "," var }
stmt_list := statement
| statement ";" stmt_list
allocation := "new bit" var ":=" inital_value
| "new qbit" var ":=" inital_value
inital_value := "0" | "1"
type := "bit" | "qbit"
var := 'Alphanumerical name'