Commit 38477114 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

Updating pyxacc compiler to work with options maps, removed xacc() in favor of...


Updating pyxacc compiler to work with options maps, removed xacc() in favor of irgen_name(), add nRequiredBits() to Instruction

Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent e877d9ed
Pipeline #27238 passed with stages
in 10 minutes and 58 seconds
image: docker:stable
stages:
- build
- push
- downstream
- wheel
docker build:
......@@ -22,17 +19,10 @@ docker push:
- docker system prune
- docker rmi -f xacc/base-plugin-ci
docker downstream:
stage: downstream
only:
- master
script:
- curl -X POST -F token=$QCOR_TRIGGER_TOKEN -F ref=master https://code.ornl.gov/api/v4/projects/4076/trigger/pipeline
docker wheel:
stage: wheel
only:
- master
script:
- git diff --name-only HEAD~1 HEAD | grep VERSION && echo "Version Incremented" || echo "Version not incremented" && exit 1
- git diff --name-only HEAD~1 HEAD | grep VERSION && echo "Version Incremented" || echo "Version not incremented" && exit 0
- echo "Wheel building coming soon."
\ No newline at end of file
......@@ -64,33 +64,18 @@ param
/* A unitary operation */
uop
: gatename=gate '(' ( explist ) ')'
: gatename=gate '(' ( explist ) ')'
| allbitsOp
;
allbitsOp
: gatename=gate '(' '...' ')'
| gatename=gate '(' INT '...' INT ')'
| gatename=gate '(' INT ',...,' INT ')'
;
gate
: 'X'
| 'Rx'
| 'Rz'
| 'Ry'
| 'Y'
| 'Z'
| 'CNOT'
| 'CZ'
| 'CX'
| 'H'
| 'Swap'
| 'Identity'
| 'CPhase'
| 'Measure'
| 'MEASURE'
| 'xacc'
| 'qmi'
: id
;
/* A list of expressions */
......@@ -112,10 +97,14 @@ exp
| exp '^' exp
| '(' exp ')'
| unaryop '(' exp ')'
| id '=' exp
| key '=' exp
| '\'[' ( ','? coupler )* ']\''
;
key
: id
;
coupler
: '[' INT ',' INT ']'
;
......@@ -154,6 +143,8 @@ COMMENT
/* id, ego, and super-ego */
ID
: [a-z][A-Za-z0-9_]*
| [A-Z][A-Za-z0-9_]*
| [A-Z][A-Za-z]*
;
/* Keep it real...numbers */
......
......@@ -64,10 +64,8 @@ void PyXACCListener::enterXacckernel(PyXACCIRParser::XacckernelContext *ctx) {
std::vector<InstructionParameter> params;
for (int i = 1; i < ctx->param().size(); i++) {
if (!boost::contains(ctx->param(i)->getText(), "*")) {
params.push_back(
InstructionParameter(ctx->param(i)->getText()));
functionVariableNames.push_back(
ctx->param(i)->getText());
params.push_back(InstructionParameter(ctx->param(i)->getText()));
functionVariableNames.push_back(ctx->param(i)->getText());
}
}
f = provider->createFunction(ctx->kernelname->getText(), {}, params);
......@@ -77,7 +75,7 @@ void PyXACCListener::enterUop(PyXACCIRParser::UopContext *ctx) {
// Note, if the user has specified something like
// H(...) or H(0...2), then we have a different handle
if (ctx->allbitsOp() != nullptr)
return;
return;
auto is_double = [](const std::string &s) -> bool {
try {
......@@ -105,12 +103,85 @@ void PyXACCListener::enterUop(PyXACCIRParser::UopContext *ctx) {
gateName = "Measure";
}
if (gateName == "xacc") {
if (xacc::hasService<GateInstruction>(gateName)) {
auto generatorName = ctx->explist()->exp(0)->getText();
// We have to accept GATE(params..., qbits..., opt=val,...)
auto tmpInst = provider->createInstruction(gateName, std::vector<int>{});
auto nBits = tmpInst->nRequiredBits();
auto nArgs = ctx->explist()->exp().size();
int nOptions = 0;
// how many options are there?
for (int i = 0; i < nArgs; i++) {
if (ctx->explist()->exp(i)->key() != nullptr) {
nOptions++;
}
}
// Parameters may be optional sometimes
auto nParams = nArgs - nOptions - nBits;
// get all InstructionParameters first
std::vector<InstructionParameter> params;
for (int i = 0; i < nParams; i++) {
auto tmp = ctx->explist()->exp(i);
if (gateName == "Measure") {
InstructionParameter param(std::stoi(tmp->getText()));
params.push_back(param);
} else {
if (tmp->real() != nullptr || tmp->id() != nullptr) {
auto str = tmp->getText();
auto param = is_double(str) ? InstructionParameter(std::stod(str))
: InstructionParameter(str);
params.push_back(param);
} else if (tmp->exp().size() == 1 && tmp->exp(0)->real() != nullptr) {
// this is a neg double
params.push_back(InstructionParameter(std::stod(tmp->getText())));
} else {
params.push_back(InstructionParameter(tmp->getText()));
}
}
}
// Get qubit indices
std::vector<int> qubits;
for (int i = nParams; i < nBits + nParams; i++) {
qubits.push_back(std::stoi(ctx->explist()->exp(i)->INT()->getText()));
}
auto inst = provider->createInstruction(gateName, qubits);
int counter = 0;
for (auto &p : params) {
inst->setParameter(counter, p);
counter++;
}
// See if we have any options
for (int i = nBits + nParams; i < nArgs; i++) {
auto key = ctx->explist()->exp(i)->key()->getText();
auto valStr = ctx->explist()->exp(i)->exp(0)->getText();
if (is_int(valStr)) {
InstructionParameter p(std::stoi(valStr));
inst->setOption(key, p);
} else if (is_double(valStr)) {
InstructionParameter p(std::stod(valStr));
inst->setOption(key, p);
} else {
InstructionParameter p(valStr);
inst->setOption(key, p);
}
// FIXME HANDLE OTHER TYPES ???
}
f->addInstruction(inst);
} else if (xacc::hasService<IRGenerator>(gateName)) {
// HERE we have something like uccsd(n_qubits=4, n_electrons=2)
auto generatorName = gateName;
std::map<std::string, InstructionParameter> params;
for (int i = 1; i < ctx->explist()->exp().size(); i++) {
auto key = ctx->explist()->exp(i)->id()->getText();
for (int i = 0; i < ctx->explist()->exp().size(); i++) {
auto key = ctx->explist()->exp(i)->key()->getText();
auto valStr = ctx->explist()->exp(i)->exp(0)->getText();
if (is_int(valStr)) {
params.insert({key, InstructionParameter(std::stoi(valStr))});
......@@ -119,6 +190,8 @@ void PyXACCListener::enterUop(PyXACCIRParser::UopContext *ctx) {
} else {
params.insert({key, InstructionParameter(valStr)});
}
// FIXME HANDLE OTHER TYPES
}
// Add the Function's InstructionParameters
......@@ -149,8 +222,7 @@ void PyXACCListener::enterUop(PyXACCIRParser::UopContext *ctx) {
}
for (auto i : genF->getInstructions()) {
f->addInstruction(
i); // Thanks to Zach's code this will add the Parameters
f->addInstruction(i);
}
} else if (gateName == "qmi") {
......@@ -165,56 +237,60 @@ void PyXACCListener::enterUop(PyXACCIRParser::UopContext *ctx) {
auto gate = provider->createInstruction(gateName, qubits, params);
f->addInstruction(gate);
} else if (ctx->explist()->exp().size() > 0) {
} /*else if (gateName == "xacc") {
auto paramStr = ctx->explist()->exp(0);
std::vector<int> qubits;
std::vector<InstructionParameter> params;
for (int i = 0; i < ctx->explist()->exp().size(); i++) {
// First arg could be a real value (3.14), a string (id), or a general
// expression (0.5*t0)
if (i == 0 && (ctx->explist()->exp(i)->real() != nullptr ||
ctx->explist()->exp(i)->id() != nullptr ||
!ctx->explist()->exp(i)->exp().empty())) {
// we have a parameter for a parameterized gate
auto tmp = ctx->explist()->exp(i);
if (tmp->real() != nullptr || tmp->id() != nullptr) {
auto str = ctx->explist()->exp(i)->getText();
auto param = is_double(str) ? InstructionParameter(std::stod(str))
: InstructionParameter(str);
params.push_back(param);
} else if (tmp->exp().size() == 1 && tmp->exp(0)->real() != nullptr) {
// this is a neg double
params.push_back(InstructionParameter(std::stod(tmp->getText())));
} else {
params.push_back(InstructionParameter(tmp->getText()));
}
// SOON TO BE DEPRECATED IN FAVOR OR IRGENERATOR()
auto generatorName = ctx->explist()->exp(0)->getText();
std::map<std::string, InstructionParameter> params;
for (int i = 1; i < ctx->explist()->exp().size(); i++) {
auto key = ctx->explist()->exp(i)->id()->getText();
auto valStr = ctx->explist()->exp(i)->exp(0)->getText();
if (is_int(valStr)) {
params.insert({key, InstructionParameter(std::stoi(valStr))});
} else if (is_double(valStr)) {
params.insert({key, InstructionParameter(std::stod(valStr))});
} else {
// std::cout << "HEY WE SHOULD BE ADDING A QUBIT"
qubits.push_back(std::stoi(ctx->explist()->exp(i)->INT()->getText()));
params.insert({key, InstructionParameter(valStr)});
}
}
std::shared_ptr<Instruction> gate;
if (gateName == "Measure") {
std::vector<int> measurebit{qubits[0]};
InstructionParameter p1(qubits[1]);
gate = provider->createInstruction(gateName, measurebit);
gate->setParameter(0, p1);
} else {
gate = provider->createInstruction(gateName, qubits, params);
// Add the Function's InstructionParameters
for (int i = 0; i < f->nParameters(); i++) {
params.insert({"param_" + std::to_string(i), f->getParameter(i)});
}
f->addInstruction(gate);
auto generator = xacc::getService<xacc::IRGenerator>(generatorName);
auto genF = generator->generate(params);
// We may have a IRGenerator that produces d-wave functions,
// if so, we will not have set to correct provider
if (!std::dynamic_pointer_cast<GateFunction>(genF)) {
if (!xacc::hasCompiler("dwave-qmi")) {
xacc::error(
"Cannot run decorated code for d-wave without d-wave plugins.");
}
f = xacc::getService<IRProvider>("dwave")->createFunction(
f->name(), {}, f->getParameters());
auto dwcompiler = xacc::getCompiler("dwave-qmi");
// auto acc = xacc::getAccelerator("dwave");
auto buff = accelerator->getBuffer(bufferName);
buff->addExtraInfo("ir-generator", ExtraInfo(generator->name()));
} else {
xacc::error("Only permitting gates with 1 parameter for now.");
auto xaccKernelSrcStr = dwcompiler->translate("", genF);
auto embeddedCode = dwcompiler->compile(xaccKernelSrcStr, accelerator);
genF = embeddedCode->getKernels()[0];
}
for (auto i : genF->getInstructions()) {
f->addInstruction(i);
}
}*/
else {
xacc::error(gateName + " is an invalid instruction for the PyXACC IR compiler.");
}
}
void PyXACCListener::enterAllbitsOp(PyXACCIRParser::AllbitsOpContext *ctx) {
std::cout << "DOT DOT? " << ctx->getText() << "\n";
auto gateName = ctx->gatename->getText();
boost::trim(gateName);
......@@ -239,7 +315,7 @@ void PyXACCListener::enterAllbitsOp(PyXACCIRParser::AllbitsOpContext *ctx) {
int start = 0, end = nQubits - 1;
if (ctx->INT().size() == 1) {
xacc::error("You cannot specify GATE(INT ...) or GATE(...INT). Only "
"GATE(...) or GATE(INT...INT).");
"GATE(INT...INT).");
} else if (ctx->INT().size() == 2) {
start = std::stoi(ctx->INT(0)->getText());
end = std::stoi(ctx->INT(1)->getText());
......@@ -250,7 +326,6 @@ void PyXACCListener::enterAllbitsOp(PyXACCIRParser::AllbitsOpContext *ctx) {
xacc::error("Invalid use of ellipses: " + ctx->getText());
}
std::cout << "HELLO: " << start << ", " << end << ", " << nQubits << "\n";
for (int i = start; i <= end; i++) {
auto inst = provider->createInstruction(gateName, {i});
f->addInstruction(inst);
......
#!/bin/bash
set - o errexit
java -jar antlr-4.7.1-complete.jar -Dlanguage=Cpp -listener -o generated/ -package pyxacc PyXACCIR.g4
java -jar antlr-4.7.2-complete.jar -Dlanguage=Cpp -listener -o generated/ -package pyxacc PyXACCIR.g4
......@@ -8,23 +8,7 @@ null
'return'
'*'
'...'
'X'
'Rx'
'Rz'
'Ry'
'Y'
'Z'
'CNOT'
'CZ'
'CX'
'H'
'Swap'
'Identity'
'CPhase'
'Measure'
'MEASURE'
'xacc'
'qmi'
',...,'
'pi'
'+'
'-'
......@@ -76,22 +60,6 @@ null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
COMMENT
ID
REAL
......@@ -115,6 +83,7 @@ allbitsOp
gate
explist
exp
key
coupler
unaryop
id
......@@ -123,4 +92,4 @@ string
atn:
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 50, 193, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 3, 2, 7, 2, 42, 10, 2, 12, 2, 14, 2, 45, 11, 2, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 51, 10, 3, 3, 3, 7, 3, 54, 10, 3, 12, 3, 14, 3, 57, 11, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 6, 5, 66, 10, 5, 13, 5, 14, 5, 67, 3, 6, 6, 6, 71, 10, 6, 13, 6, 14, 6, 72, 3, 6, 5, 6, 76, 10, 6, 3, 7, 3, 7, 5, 7, 80, 10, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 5, 9, 87, 10, 9, 3, 10, 3, 10, 3, 10, 5, 10, 92, 10, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 5, 11, 100, 10, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 5, 12, 114, 10, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 7, 14, 121, 10, 14, 12, 14, 14, 14, 124, 11, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 5, 15, 148, 10, 15, 3, 15, 7, 15, 151, 10, 15, 12, 15, 14, 15, 154, 11, 15, 3, 15, 5, 15, 157, 10, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 7, 15, 174, 10, 15, 12, 15, 14, 15, 177, 11, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 2, 3, 28, 21, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 2, 4, 3, 2, 11, 27, 3, 2, 38, 43, 2, 200, 2, 43, 3, 2, 2, 2, 4, 46, 3, 2, 2, 2, 6, 62, 3, 2, 2, 2, 8, 65, 3, 2, 2, 2, 10, 75, 3, 2, 2, 2, 12, 79, 3, 2, 2, 2, 14, 81, 3, 2, 2, 2, 16, 83, 3, 2, 2, 2, 18, 91, 3, 2, 2, 2, 20, 99, 3, 2, 2, 2, 22, 113, 3, 2, 2, 2, 24, 115, 3, 2, 2, 2, 26, 117, 3, 2, 2, 2, 28, 156, 3, 2, 2, 2, 30, 178, 3, 2, 2, 2, 32, 184, 3, 2, 2, 2, 34, 186, 3, 2, 2, 2, 36, 188, 3, 2, 2, 2, 38, 190, 3, 2, 2, 2, 40, 42, 5, 4, 3, 2, 41, 40, 3, 2, 2, 2, 42, 45, 3, 2, 2, 2, 43, 41, 3, 2, 2, 2, 43, 44, 3, 2, 2, 2, 44, 3, 3, 2, 2, 2, 45, 43, 3, 2, 2, 2, 46, 47, 7, 3, 2, 2, 47, 48, 5, 34, 18, 2, 48, 55, 7, 4, 2, 2, 49, 51, 7, 5, 2, 2, 50, 49, 3, 2, 2, 2, 50, 51, 3, 2, 2, 2, 51, 52, 3, 2, 2, 2, 52, 54, 5, 18, 10, 2, 53, 50, 3, 2, 2, 2, 54, 57, 3, 2, 2, 2, 55, 53, 3, 2, 2, 2, 55, 56, 3, 2, 2, 2, 56, 58, 3, 2, 2, 2, 57, 55, 3, 2, 2, 2, 58, 59, 7, 6, 2, 2, 59, 60, 7, 7, 2, 2, 60, 61, 5, 6, 4, 2, 61, 5, 3, 2, 2, 2, 62, 63, 5, 8, 5, 2, 63, 7, 3, 2, 2, 2, 64, 66, 5, 10, 6, 2, 65, 64, 3, 2, 2, 2, 66, 67, 3, 2, 2, 2, 67, 65, 3, 2, 2, 2, 67, 68, 3, 2, 2, 2, 68, 9, 3, 2, 2, 2, 69, 71, 5, 12, 7, 2, 70, 69, 3, 2, 2, 2, 71, 72, 3, 2, 2, 2, 72, 70, 3, 2, 2, 2, 72, 73, 3, 2, 2, 2, 73, 76, 3, 2, 2, 2, 74, 76, 5, 14, 8, 2, 75, 70, 3, 2, 2, 2, 75, 74, 3, 2, 2, 2, 76, 11, 3, 2, 2, 2, 77, 80, 5, 20, 11, 2, 78, 80, 7, 8, 2, 2, 79, 77, 3, 2, 2, 2, 79, 78, 3, 2, 2, 2, 80, 13, 3, 2, 2, 2, 81, 82, 7, 44, 2, 2, 82, 15, 3, 2, 2, 2, 83, 86, 5, 18, 10, 2, 84, 85, 7, 5, 2, 2, 85, 87, 5, 16, 9, 2, 86, 84, 3, 2, 2, 2, 86, 87, 3, 2, 2, 2, 87, 17, 3, 2, 2, 2, 88, 92, 5, 34, 18, 2, 89, 90, 7, 9, 2, 2, 90, 92, 5, 34, 18, 2, 91, 88, 3, 2, 2, 2, 91, 89, 3, 2, 2, 2, 92, 19, 3, 2, 2, 2, 93, 94, 5, 24, 13, 2, 94, 95, 7, 4, 2, 2, 95, 96, 5, 26, 14, 2, 96, 97, 7, 6, 2, 2, 97, 100, 3, 2, 2, 2, 98, 100, 5, 22, 12, 2, 99, 93, 3, 2, 2, 2, 99, 98, 3, 2, 2, 2, 100, 21, 3, 2, 2, 2, 101, 102, 5, 24, 13, 2, 102, 103, 7, 4, 2, 2, 103, 104, 7, 10, 2, 2, 104, 105, 7, 6, 2, 2, 105, 114, 3, 2, 2, 2, 106, 107, 5, 24, 13, 2, 107, 108, 7, 4, 2, 2, 108, 109, 7, 47, 2, 2, 109, 110, 7, 10, 2, 2, 110, 111, 7, 47, 2, 2, 111, 112, 7, 6, 2, 2, 112, 114, 3, 2, 2, 2, 113, 101, 3, 2, 2, 2, 113, 106, 3, 2, 2, 2, 114, 23, 3, 2, 2, 2, 115, 116, 9, 2, 2, 2, 116, 25, 3, 2, 2, 2, 117, 122, 5, 28, 15, 2, 118, 119, 7, 5, 2, 2, 119, 121, 5, 28, 15, 2, 120, 118, 3, 2, 2, 2, 121, 124, 3, 2, 2, 2, 122, 120, 3, 2, 2, 2, 122, 123, 3, 2, 2, 2, 123, 27, 3, 2, 2, 2, 124, 122, 3, 2, 2, 2, 125, 126, 8, 15, 1, 2, 126, 157, 5, 36, 19, 2, 127, 157, 7, 47, 2, 2, 128, 157, 7, 28, 2, 2, 129, 157, 5, 34, 18, 2, 130, 131, 7, 30, 2, 2, 131, 157, 5, 28, 15, 8, 132, 133, 7, 4, 2, 2, 133, 134, 5, 28, 15, 2, 134, 135, 7, 6, 2, 2, 135, 157, 3, 2, 2, 2, 136, 137, 5, 32, 17, 2, 137, 138, 7, 4, 2, 2, 138, 139, 5, 28, 15, 2, 139, 140, 7, 6, 2, 2, 140, 157, 3, 2, 2, 2, 141, 142, 5, 34, 18, 2, 142, 143, 7, 33, 2, 2, 143, 144, 5, 28, 15, 4, 144, 157, 3, 2, 2, 2, 145, 152, 7, 34, 2, 2, 146, 148, 7, 5, 2, 2, 147, 146, 3, 2, 2, 2, 147, 148, 3, 2, 2, 2, 148, 149, 3, 2, 2, 2, 149, 151, 5, 30, 16, 2, 150, 147, 3, 2, 2, 2, 151, 154, 3, 2, 2, 2, 152, 150, 3, 2, 2, 2, 152, 153, 3, 2, 2, 2, 153, 155, 3, 2, 2, 2, 154, 152, 3, 2, 2, 2, 155, 157, 7, 35, 2, 2, 156, 125, 3, 2, 2, 2, 156, 127, 3, 2, 2, 2, 156, 128, 3, 2, 2, 2, 156, 129, 3, 2, 2, 2, 156, 130, 3, 2, 2, 2, 156, 132, 3, 2, 2, 2, 156, 136, 3, 2, 2, 2, 156, 141, 3, 2, 2, 2, 156, 145, 3, 2, 2, 2, 157, 175, 3, 2, 2, 2, 158, 159, 12, 12, 2, 2, 159, 160, 7, 29, 2, 2, 160, 174, 5, 28, 15, 13, 161, 162, 12, 11, 2, 2, 162, 163, 7, 30, 2, 2, 163, 174, 5, 28, 15, 12, 164, 165, 12, 10, 2, 2, 165, 166, 7, 9, 2, 2, 166, 174, 5, 28, 15, 11, 167, 168, 12, 9, 2, 2, 168, 169, 7, 31, 2, 2, 169, 174, 5, 28, 15, 10, 170, 171, 12, 7, 2, 2, 171, 172, 7, 32, 2, 2, 172, 174, 5, 28, 15, 8, 173, 158, 3, 2, 2, 2, 173, 161, 3, 2, 2, 2, 173, 164, 3, 2, 2, 2, 173, 167, 3, 2, 2, 2, 173, 170, 3, 2, 2, 2, 174, 177, 3, 2, 2, 2, 175, 173, 3, 2, 2, 2, 175, 176, 3, 2, 2, 2, 176, 29, 3, 2, 2, 2, 177, 175, 3, 2, 2, 2, 178, 179, 7, 36, 2, 2, 179, 180, 7, 47, 2, 2, 180, 181, 7, 5, 2, 2, 181, 182, 7, 47, 2, 2, 182, 183, 7, 37, 2, 2, 183, 31, 3, 2, 2, 2, 184, 185, 9, 3, 2, 2, 185, 33, 3, 2, 2, 2, 186, 187, 7, 45, 2, 2, 187, 35, 3, 2, 2, 2, 188, 189, 7, 46, 2, 2, 189, 37, 3, 2, 2, 2, 190, 191, 7, 48, 2, 2, 191, 39, 3, 2, 2, 2, 19, 43, 50, 55, 67, 72, 75, 79, 86, 91, 99, 113, 122, 147, 152, 156, 173, 175]
\ No newline at end of file
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 34, 197, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 3, 2, 7, 2, 44, 10, 2, 12, 2, 14, 2, 47, 11, 2, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 53, 10, 3, 3, 3, 7, 3, 56, 10, 3, 12, 3, 14, 3, 59, 11, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 6, 5, 68, 10, 5, 13, 5, 14, 5, 69, 3, 6, 6, 6, 73, 10, 6, 13, 6, 14, 6, 74, 3, 6, 5, 6, 78, 10, 6, 3, 7, 3, 7, 5, 7, 82, 10, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 5, 9, 89, 10, 9, 3, 10, 3, 10, 3, 10, 5, 10, 94, 10, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 5, 11, 102, 10, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 5, 12, 116, 10, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 7, 14, 123, 10, 14, 12, 14, 14, 14, 126, 11, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 5, 15, 150, 10, 15, 3, 15, 7, 15, 153, 10, 15, 12, 15, 14, 15, 156, 11, 15, 3, 15, 5, 15, 159, 10, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 7, 15, 176, 10, 15, 12, 15, 14, 15, 179, 11, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 2, 3, 28, 22, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 2, 3, 3, 2, 22, 27, 2, 203, 2, 45, 3, 2, 2, 2, 4, 48, 3, 2, 2, 2, 6, 64, 3, 2, 2, 2, 8, 67, 3, 2, 2, 2, 10, 77, 3, 2, 2, 2, 12, 81, 3, 2, 2, 2, 14, 83, 3, 2, 2, 2, 16, 85, 3, 2, 2, 2, 18, 93, 3, 2, 2, 2, 20, 101, 3, 2, 2, 2, 22, 115, 3, 2, 2, 2, 24, 117, 3, 2, 2, 2, 26, 119, 3, 2, 2, 2, 28, 158, 3, 2, 2, 2, 30, 180, 3, 2, 2, 2, 32, 182, 3, 2, 2, 2, 34, 188, 3, 2, 2, 2, 36, 190, 3, 2, 2, 2, 38, 192, 3, 2, 2, 2, 40, 194, 3, 2, 2, 2, 42, 44, 5, 4, 3, 2, 43, 42, 3, 2, 2, 2, 44, 47, 3, 2, 2, 2, 45, 43, 3, 2, 2, 2, 45, 46, 3, 2, 2, 2, 46, 3, 3, 2, 2, 2, 47, 45, 3, 2, 2, 2, 48, 49, 7, 3, 2, 2, 49, 50, 5, 36, 19, 2, 50, 57, 7, 4, 2, 2, 51, 53, 7, 5, 2, 2, 52, 51, 3, 2, 2, 2, 52, 53, 3, 2, 2, 2, 53, 54, 3, 2, 2, 2, 54, 56, 5, 18, 10, 2, 55, 52, 3, 2, 2, 2, 56, 59, 3, 2, 2, 2, 57, 55, 3, 2, 2, 2, 57, 58, 3, 2, 2, 2, 58, 60, 3, 2, 2, 2, 59, 57, 3, 2, 2, 2, 60, 61, 7, 6, 2, 2, 61, 62, 7, 7, 2, 2, 62, 63, 5, 6, 4, 2, 63, 5, 3, 2, 2, 2, 64, 65, 5, 8, 5, 2, 65, 7, 3, 2, 2, 2, 66, 68, 5, 10, 6, 2, 67, 66, 3, 2, 2, 2, 68, 69, 3, 2, 2, 2, 69, 67, 3, 2, 2, 2, 69, 70, 3, 2, 2, 2, 70, 9, 3, 2, 2, 2, 71, 73, 5, 12, 7, 2, 72, 71, 3, 2, 2, 2, 73, 74, 3, 2, 2, 2, 74, 72, 3, 2, 2, 2, 74, 75, 3, 2, 2, 2, 75, 78, 3, 2, 2, 2, 76, 78, 5, 14, 8, 2, 77, 72, 3, 2, 2, 2, 77, 76, 3, 2, 2, 2, 78, 11, 3, 2, 2, 2, 79, 82, 5, 20, 11, 2, 80, 82, 7, 8, 2, 2, 81, 79, 3, 2, 2, 2, 81, 80, 3, 2, 2, 2, 82, 13, 3, 2, 2, 2, 83, 84, 7, 28, 2, 2, 84, 15, 3, 2, 2, 2, 85, 88, 5, 18, 10, 2, 86, 87, 7, 5, 2, 2, 87, 89, 5, 16, 9, 2, 88, 86, 3, 2, 2, 2, 88, 89, 3, 2, 2, 2, 89, 17, 3, 2, 2, 2, 90, 94, 5, 36, 19, 2, 91, 92, 7, 9, 2, 2, 92, 94, 5, 36, 19, 2, 93, 90, 3, 2, 2, 2, 93, 91, 3, 2, 2, 2, 94, 19, 3, 2, 2, 2, 95, 96, 5, 24, 13, 2, 96, 97, 7, 4, 2, 2, 97, 98, 5, 26, 14, 2, 98, 99, 7, 6, 2, 2, 99, 102, 3, 2, 2, 2, 100, 102, 5, 22, 12, 2, 101, 95, 3, 2, 2, 2, 101, 100, 3, 2, 2, 2, 102, 21, 3, 2, 2, 2, 103, 104, 5, 24, 13, 2, 104, 105, 7, 4, 2, 2, 105, 106, 7, 10, 2, 2, 106, 107, 7, 6, 2, 2, 107, 116, 3, 2, 2, 2, 108, 109, 5, 24, 13, 2, 109, 110, 7, 4, 2, 2, 110, 111, 7, 31, 2, 2, 111, 112, 7, 11, 2, 2, 112, 113, 7, 31, 2, 2, 113, 114, 7, 6, 2, 2, 114, 116, 3, 2, 2, 2, 115, 103, 3, 2, 2, 2, 115, 108, 3, 2, 2, 2, 116, 23, 3, 2, 2, 2, 117, 118, 5, 36, 19, 2, 118, 25, 3, 2, 2, 2, 119, 124, 5, 28, 15, 2, 120, 121, 7, 5, 2, 2, 121, 123, 5, 28, 15, 2, 122, 120, 3, 2, 2, 2, 123, 126, 3, 2, 2, 2, 124, 122, 3, 2, 2, 2, 124, 125, 3, 2, 2, 2, 125, 27, 3, 2, 2, 2, 126, 124, 3, 2, 2, 2, 127, 128, 8, 15, 1, 2, 128, 159, 5, 38, 20, 2, 129, 159, 7, 31, 2, 2, 130, 159, 7, 12, 2, 2, 131, 159, 5, 36, 19, 2, 132, 133, 7, 14, 2, 2, 133, 159, 5, 28, 15, 8, 134, 135, 7, 4, 2, 2, 135, 136, 5, 28, 15, 2, 136, 137, 7, 6, 2, 2, 137, 159, 3, 2, 2, 2, 138, 139, 5, 34, 18, 2, 139, 140, 7, 4, 2, 2, 140, 141, 5, 28, 15, 2, 141, 142, 7, 6, 2, 2, 142, 159, 3, 2, 2, 2, 143, 144, 5, 30, 16, 2, 144, 145, 7, 17, 2, 2, 145, 146, 5, 28, 15, 4, 146, 159, 3, 2, 2, 2, 147, 154, 7, 18, 2, 2, 148, 150, 7, 5, 2, 2, 149, 148, 3, 2, 2, 2, 149, 150, 3, 2, 2, 2, 150, 151, 3, 2, 2, 2, 151, 153, 5, 32, 17, 2, 152, 149, 3, 2, 2, 2, 153, 156, 3, 2, 2, 2, 154, 152, 3, 2, 2, 2, 154, 155, 3, 2, 2, 2, 155, 157, 3, 2, 2, 2, 156, 154, 3, 2, 2, 2, 157, 159, 7, 19, 2, 2, 158, 127, 3, 2, 2, 2, 158, 129, 3, 2, 2, 2, 158, 130, 3, 2, 2, 2, 158, 131, 3, 2, 2, 2, 158, 132, 3, 2, 2, 2, 158, 134, 3, 2, 2, 2, 158, 138, 3, 2, 2, 2, 158, 143, 3, 2, 2, 2, 158, 147, 3, 2, 2, 2, 159, 177, 3, 2, 2, 2, 160, 161, 12, 12, 2, 2, 161, 162, 7, 13, 2, 2, 162, 176, 5, 28, 15, 13, 163, 164, 12, 11, 2, 2, 164, 165, 7, 14, 2, 2, 165, 176, 5, 28, 15, 12, 166, 167, 12, 10, 2, 2, 167, 168, 7, 9, 2, 2, 168, 176, 5, 28, 15, 11, 169, 170, 12, 9, 2, 2, 170, 171, 7, 15, 2, 2, 171, 176, 5, 28, 15, 10, 172, 173, 12, 7, 2, 2, 173, 174, 7, 16, 2, 2, 174, 176, 5, 28, 15, 8, 175, 160, 3, 2, 2, 2, 175, 163, 3, 2, 2, 2, 175, 166, 3, 2, 2, 2, 175, 169, 3, 2, 2, 2, 175, 172, 3, 2, 2, 2, 176, 179, 3, 2, 2, 2, 177, 175, 3, 2, 2, 2, 177, 178, 3, 2, 2, 2, 178, 29, 3, 2, 2, 2, 179, 177, 3, 2, 2, 2, 180, 181, 5, 36, 19, 2, 181, 31, 3, 2, 2, 2, 182, 183, 7, 20, 2, 2, 183, 184, 7, 31, 2, 2, 184, 185, 7, 5, 2, 2, 185, 186, 7, 31, 2, 2, 186, 187, 7, 21, 2, 2, 187, 33, 3, 2, 2, 2, 188, 189, 9, 2, 2, 2, 189, 35, 3, 2, 2, 2, 190, 191, 7, 29, 2, 2, 191, 37, 3, 2, 2, 2, 192, 193, 7, 30, 2, 2, 193, 39, 3, 2, 2, 2, 194, 195, 7, 32, 2, 2, 195, 41, 3, 2, 2, 2, 19, 45, 52, 57, 69, 74, 77, 81, 88, 93, 101, 115, 124, 149, 154, 158, 175, 177]
\ No newline at end of file
......@@ -23,29 +23,13 @@ T__21=22
T__22=23
T__23=24
T__24=25
T__25=26
T__26=27
T__27=28
T__28=29
T__29=30
T__30=31
T__31=32
T__32=33
T__33=34
T__34=35
T__35=36
T__36=37
T__37=38
T__38=39
T__39=40
T__40=41
COMMENT=42
ID=43
REAL=44
INT=45
STRING=46
WS=47
EOL=48
COMMENT=26
ID=27
REAL=28
INT=29
STRING=30
WS=31
EOL=32
'def'=1
'('=2
','=3
......@@ -54,36 +38,20 @@ EOL=48
'return'=6
'*'=7
'...'=8
'X'=9
'Rx'=10
'Rz'=11
'Ry'=12
'Y'=13
'Z'=14
'CNOT'=15
'CZ'=16
'CX'=17
'H'=18
'Swap'=19
'Identity'=20
'CPhase'=21
'Measure'=22
'MEASURE'=23
'xacc'=24
'qmi'=25
'pi'=26
'+'=27
'-'=28
'/'=29
'^'=30
'='=31
'\'['=32
']\''=33
'['=34
']'=35
'sin'=36
'cos'=37
'tan'=38
'exp'=39
'ln'=40
'sqrt'=41
',...,'=9
'pi'=10
'+'=11
'-'=12
'/'=13
'^'=14
'='=15
'\'['=16
']\''=17
'['=18
']'=19
'sin'=20
'cos'=21
'tan'=22
'exp'=23
'ln'=24
'sqrt'=25
// Generated from PyXACCIR.g4 by ANTLR 4.7.1
// Generated from PyXACCIR.g4 by ANTLR 4.7.2
#include "PyXACCIRBaseListener.h"
using namespace pyxacc;
// Generated from PyXACCIR.g4 by ANTLR 4.7.1
// Generated from PyXACCIR.g4 by ANTLR 4.7.2
#pragma once
#include "antlr4-runtime.h"
#include "PyXACCIRListener.h"
namespace pyxacc {
/**
* This class provides an empty implementation of PyXACCIRListener,
* which can be extended to create a listener which only needs to handle a
* subset of the available methods.
* which can be extended to create a listener which only needs to handle a subset
* of the available methods.
*/
class PyXACCIRBaseListener : public PyXACCIRListener {
class PyXACCIRBaseListener : public PyXACCIRListener {
public:
virtual void enterXaccsrc(PyXACCIRParser::XaccsrcContext * /*ctx*/) override {
}
virtual void exitXaccsrc(PyXACCIRParser::XaccsrcContext * /*ctx*/) override {}
virtual void
enterXacckernel(PyXACCIRParser::XacckernelContext * /*ctx*/) override {}
virtual void
exitXacckernel(PyXACCIRParser::XacckernelContext * /*ctx*/) override {}
virtual void enterXaccsrc(PyXACCIRParser::XaccsrcContext * /*ctx*/) override { }
virtual void exitXaccsrc(PyXACCIRParser::XaccsrcContext * /*ctx*/) override { }
virtual void enterXacckernel(PyXACCIRParser::XacckernelContext * /*ctx*/) override { }
virtual void exitXacckernel(PyXACCIRParser::XacckernelContext * /*ctx*/) override { }
virtual void enterMainprog(PyXACCIRParser::MainprogContext * /*ctx*/) override { }
virtual void exitMainprog(PyXACCIRParser::MainprogContext * /*ctx*/) override { }
virtual void enterProgram(PyXACCIRParser::ProgramContext * /*ctx*/) override { }
virtual void exitProgram(PyXACCIRParser::ProgramContext * /*ctx*/) override { }
virtual void enterLine(PyXACCIRParser::LineContext * /*ctx*/) override { }
virtual void exitLine(PyXACCIRParser::LineContext * /*ctx*/) override { }
virtual void
enterMainprog(PyXACCIRParser::MainprogContext * /*ctx*/) override {}
virtual void
exitMainprog(PyXACCIRParser::MainprogContext * /*ctx*/) override {}
virtual void enterStatement(PyXACCIRParser::StatementContext * /*ctx*/) override { }
virtual void exitStatement(PyXACCIRParser::StatementContext * /*ctx*/) override { }
virtual void enterProgram(PyXACCIRParser::ProgramContext * /*ctx*/) override {
}
virtual void exitProgram(PyXACCIRParser::ProgramContext * /*ctx*/) override {}
virtual void enterComment(PyXACCIRParser::CommentContext * /*ctx*/) override { }
virtual void exitComment(PyXACCIRParser::CommentContext * /*ctx*/) override { }
virtual void enterLine(PyXACCIRParser::LineContext * /*ctx*/) override {}
virtual void exitLine(PyXACCIRParser::LineContext * /*ctx*/) override {}
virtual void enterParamlist(PyXACCIRParser::ParamlistContext * /*ctx*/) override { }
virtual void exitParamlist(PyXACCIRParser::ParamlistContext * /*ctx*/) override { }
virtual void
enterStatement(PyXACCIRParser::StatementContext * /*ctx*/) override {}
virtual void
exitStatement(PyXACCIRParser::StatementContext * /*ctx*/) override {}
virtual void enterParam(PyXACCIRParser::ParamContext * /*ctx*/) override { }
virtual void exitParam(PyXACCIRParser::ParamContext * /*ctx*/) override { }
virtual void enterComment(PyXACCIRParser::CommentContext * /*ctx*/) override {
}
virtual void exitComment(PyXACCIRParser::CommentContext * /*ctx*/) override {}
virtual void enterUop(PyXACCIRParser::UopContext * /*ctx*/) override { }
virtual void exitUop(PyXACCIRParser::UopContext * /*ctx*/) override { }
virtual void
enterParamlist(PyXACCIRParser::ParamlistContext * /*ctx*/) override {}
virtual void
exitParamlist(PyXACCIRParser::ParamlistContext * /*ctx*/) override {}
virtual void enterAllbitsOp(PyXACCIRParser::AllbitsOpContext * /*ctx*/) override { }
virtual void exitAllbitsOp(PyXACCIRParser::AllbitsOpContext * /*ctx*/) override { }
virtual void enterParam(PyXACCIRParser::ParamContext * /*ctx*/) override {}
virtual void exitParam(PyXACCIRParser::ParamContext * /*ctx*/) override {}
virtual void enterGate(PyXACCIRParser::GateContext * /*ctx*/) override { }
virtual void exitGate(PyXACCIRParser::GateContext * /*ctx*/) override { }
virtual void enterUop(PyXACCIRParser::UopContext * /*ctx*/) override {}
virtual void exitUop(PyXACCIRParser::UopContext * /*ctx*/) override {}
virtual void enterExplist(PyXACCIRParser::ExplistContext * /*ctx*/) override { }
virtual void exitExplist(PyXACCIRParser::ExplistContext * /*ctx*/) override { }
virtual void
enterAllbitsOp(PyXACCIRParser::AllbitsOpContext * /*ctx*/) override {}
virtual void
exitAllbitsOp(PyXACCIRParser::AllbitsOpContext * /*ctx*/) override {}