Browse Source

Writing out BNF

Adam Kelly 5 years ago
parent
commit
dcbff73d1a
1 changed files with 19 additions and 0 deletions
  1. 19 0
      qasm/parser.c

+ 19 - 0
qasm/parser.c

@@ -0,0 +1,19 @@
+// The following is an implementation of OpenQASM
+// using a recursive descent style parser.
+
+// MainProgram := "OPENQASM" Real ";" Program
+// Program ::= Statement | Program Statement
+// Statement ::= Decl 
+//             | GateDecl GeoList "}" 
+//             | GateDecl "}"
+//             | "opaque" Id Idlist ";"
+//             | "opaque" Id "()" IdList ";"
+//             | "opaque" Id "(" IdList ")" IdList ";"
+//             | Qop
+//             | "if" "(" Id "==" Integer ")" Qop
+//             | "barrier" AnyList ";"
+// Decl ::= "qreg" Id "[" Integer "]" ";" | "creg" Id "[" Integer "]" ";"
+// GateDecl ::= "gate" Id IdList "{" | "gate" Id "()" IdList "{" | "gate" Id "(" IdList ")" Idlist "{"
+// GopList ::= Uop | "barrier" IdList ";" | GopList Uop | GopList "barrier" IdList ";"
+// Qop ::= Uop | "measure" Argument "->" Argument ";" | "reset" Argument ";"
+// Uop ::= "U" "(" ExpList ")" Argument ";" | "CX" Argument "," Argument ";" | Id AnyList ";" | Id "()" AnyList ";" | Id ""