Quantum computing has the potential to become a reality in the next few decades. We're thinking ahead of the curve and have developed a language that makes it easy to build quantum circuits, which consist of quantum gates and quantum registers holding qubits.
A high-level language for quantum computing that encapsulates mathematical operations and quantum computing specific components like quantum registers.
A futuristic compiler on your laptop.
Based on MicroC
All the usual tokens + specific ones for
Grammar was developed incrementally
Pacman Parsing
expr:
...
/* Query */
| expr ? expr
| expr ? [ : expr ]
| expr ? [expr : expr ]
...
/* Membership testing with keyword 'in' */
| expr in expr
...
/* literals */
| expr $ expr
| [| matrix_row_list |]
| i( expr , expr )
| <| expr , expr |>
iterator:
| ident in [range]
| datatype ident in [range]
| datatype ident in expr
Valid syntax doesn't always make sense
The importance of semantic checks in real life
Error messages
Type Mapping
Op Tag
Pythonic for-loop
Pythonic for-loop
More examples
More examples
A simple Hello World
def int main:
{
print("Hello, Ground!");
return 0;
}
It was unfortunately a very short hello for our whale friend
int i = 4;
float f = 2.0;
bool b = true;
string s = "So Long, and Thanks for All the Fish";
string[] arr = ["Ford", "Prefect", "Zaphod", "Beeblebrox"];
int[][] arr2 = [[1,2,3],[4,5,6]];
fraction f = 84$2;
complex c = i(5.0, 7.0);
float[|] = [|1.0, 2.1; 3.2, 46.1|];
qreg q = <| 42, 0 |>;
% FRACTIONS
frac foo = 2$3;
~foo; % 3$2
int i = 5;
i > foo; % true
% COMPLEX NUMBERS
complex cnum = i(3.0, 1);
real(cnum); % 3.0
imag(cnum); % 1
complex cnum2 = i(9) % this gives us i(9, 0)
% MATRICES
float[|] mat = [| 1.2, 3.4; 5.6, 7.8 |];
mat[2, 1];
mat'; % transpose matrix
% QUANTUM REGISTERS
qreg q = <|10, 3|>;
hadamard(q);
q ? [2:10]; % measures qubit 2 to 10
if x > 0:
print("positive");
elif x < 0:
print("negative");
else:
print("zero");
while x > 42: {
print(x);
x = x - 1;
}
int[] arr = [1,2,3];
for int i in arr:
print i;
int i;
for i in [1:10]
for int i in [1:10:2]
import ../lib/mylib1;
import ../lib/herlib2;
import imported_file;
def int main:
{
return imported_file.function(5);
}
So Fancy!
def int gcd: int x, int y
{
while y != 0:
{
int r = x mod y;
x = y;
y = r;
}
return x;
}
def int main:
{
% prints the greatest common divisor of 10 and 20
print(gcd(10, 20));
return 0;
}
Hang on to your Towel!
Let's see Shor's algorithm and Grover's Search in action! Real quantum computing programs running on a not-so-real quantum computer (our simulator)
[oh-kam-uh l] Mostly harmless