Skip to content

Commit

Permalink
Merge pull request #4 from dmvjs/ke/esm-and-jest
Browse files Browse the repository at this point in the history
using esm and jest and JS classes
  • Loading branch information
dmvjs authored Jun 16, 2024
2 parents 609791d + 4ee49c5 commit 44e5727
Show file tree
Hide file tree
Showing 12 changed files with 56,814 additions and 12,614 deletions.
56,877 changes: 49,151 additions & 7,726 deletions dist/quantum-circuit.js

Large diffs are not rendered by default.

1,105 changes: 628 additions & 477 deletions dist/quantum-circuit.min.js

Large diffs are not rendered by default.

815 changes: 394 additions & 421 deletions lib/qasm_import/QASMImport.js

Large diffs are not rendered by default.

93 changes: 44 additions & 49 deletions lib/qasm_import/QASMLexer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Generated from QASM.g4 by ANTLR 4.7.1
// jshint ignore: start
var antlr4 = require('antlr4/index');
import {ATNDeserializer, DFA, Lexer, LexerATNSimulator, PredictionContextCache, Token} from "antlr4";


var serializedATN = ["\u0003\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964",
Expand Down Expand Up @@ -187,26 +187,59 @@ var serializedATN = ["\u0003\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964",
"\u00ff\u0107\u0111\u011f\u0003\b\u0002\u0002"].join("");


var atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN);
var atn = new ATNDeserializer().deserialize(serializedATN);

var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });
var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new DFA(ds, index); });

function QASMLexer(input) {
antlr4.Lexer.call(this, input);
this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
return this;
}
export class QASMLexer extends Lexer {
constructor(input) {
super(input);
this._interp = new LexerATNSimulator(this, atn, decisionsToDFA, new PredictionContextCache());
}

channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ];

modeNames = [ "DEFAULT_MODE" ];

literalNames = [ null, "'}'", "'opaque'", "';'", "'('",
"')'", "'if'", "'=='", "'barrier'",
"'OPENQASM'", "'include'", "'qreg'",
"'['", "']'", "'creg'", "'gate'", "'{'",
"'measure'", "'->'", "'reset'", "'U'",
"'CX'", "','", "'^'", "'*'", "'/'",
"'+'", "'-'", "'sin'", "'cos'", "'tan'",
"'exp'", "'ln'", "'sqrt'", "'pi'" ];

symbolicNames = [ null, null, null, null, null, null,
null, null, null, null, null, null,
null, null, null, null, null, null,
null, null, null, null, null, null,
null, null, null, null, null, null,
null, null, null, null, "PI", "REAL",
"SUBREAL", "EXPREAL", "INT", "ID",
"WS", "FILENAME", "COMMENT", "LINE_COMMENT" ];

QASMLexer.prototype = Object.create(antlr4.Lexer.prototype);
QASMLexer.prototype.constructor = QASMLexer;
ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4",
"T__5", "T__6", "T__7", "T__8", "T__9",
"T__10", "T__11", "T__12", "T__13", "T__14",
"T__15", "T__16", "T__17", "T__18", "T__19",
"T__20", "T__21", "T__22", "T__23", "T__24",
"T__25", "T__26", "T__27", "T__28", "T__29",
"T__30", "T__31", "T__32", "PI", "REAL",
"SUBREAL", "EXPREAL", "INT", "ID", "WS",
"FILENAME", "COMMENT", "LINE_COMMENT" ];

grammarFileName = "QASM.g4";

}

Object.defineProperty(QASMLexer.prototype, "atn", {
get : function() {
return atn;
}
});

QASMLexer.EOF = antlr4.Token.EOF;
QASMLexer.EOF = Token.EOF;
QASMLexer.T__0 = 1;
QASMLexer.T__1 = 2;
QASMLexer.T__2 = 3;
Expand Down Expand Up @@ -251,41 +284,3 @@ QASMLexer.FILENAME = 41;
QASMLexer.COMMENT = 42;
QASMLexer.LINE_COMMENT = 43;

QASMLexer.prototype.channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ];

QASMLexer.prototype.modeNames = [ "DEFAULT_MODE" ];

QASMLexer.prototype.literalNames = [ null, "'}'", "'opaque'", "';'", "'('",
"')'", "'if'", "'=='", "'barrier'",
"'OPENQASM'", "'include'", "'qreg'",
"'['", "']'", "'creg'", "'gate'", "'{'",
"'measure'", "'->'", "'reset'", "'U'",
"'CX'", "','", "'^'", "'*'", "'/'",
"'+'", "'-'", "'sin'", "'cos'", "'tan'",
"'exp'", "'ln'", "'sqrt'", "'pi'" ];

QASMLexer.prototype.symbolicNames = [ null, null, null, null, null, null,
null, null, null, null, null, null,
null, null, null, null, null, null,
null, null, null, null, null, null,
null, null, null, null, null, null,
null, null, null, null, "PI", "REAL",
"SUBREAL", "EXPREAL", "INT", "ID",
"WS", "FILENAME", "COMMENT", "LINE_COMMENT" ];

QASMLexer.prototype.ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4",
"T__5", "T__6", "T__7", "T__8", "T__9",
"T__10", "T__11", "T__12", "T__13", "T__14",
"T__15", "T__16", "T__17", "T__18", "T__19",
"T__20", "T__21", "T__22", "T__23", "T__24",
"T__25", "T__26", "T__27", "T__28", "T__29",
"T__30", "T__31", "T__32", "PI", "REAL",
"SUBREAL", "EXPREAL", "INT", "ID", "WS",
"FILENAME", "COMMENT", "LINE_COMMENT" ];

QASMLexer.prototype.grammarFileName = "QASM.g4";



exports.QASMLexer = QASMLexer;

142 changes: 53 additions & 89 deletions lib/qasm_import/QASMListener.js
Original file line number Diff line number Diff line change
@@ -1,177 +1,141 @@
// Generated from QASM.g4 by ANTLR 4.7.1
// jshint ignore: start
var antlr4 = require('antlr4/index');
import {ParseTreeListener} from "antlr4";

// This class defines a complete listener for a parse tree produced by QASMParser.
function QASMListener() {
antlr4.tree.ParseTreeListener.call(this);
return this;
}

QASMListener.prototype = Object.create(antlr4.tree.ParseTreeListener.prototype);
QASMListener.prototype.constructor = QASMListener;
export class QASMListener extends ParseTreeListener {
constructor() {
super();
}

// Enter a parse tree produced by QASMParser#mainprog.
QASMListener.prototype.enterMainprog = function(ctx) {
};
enterMainprog = function(ctx) {
};

// Exit a parse tree produced by QASMParser#mainprog.
QASMListener.prototype.exitMainprog = function(ctx) {
};
exitMainprog = function(ctx) {
};


// Enter a parse tree produced by QASMParser#statement.
QASMListener.prototype.enterStatement = function(ctx) {
};
enterStatement = function(ctx) {
};

// Exit a parse tree produced by QASMParser#statement.
QASMListener.prototype.exitStatement = function(ctx) {
};
exitStatement = function(ctx) {
};


// Enter a parse tree produced by QASMParser#version.
QASMListener.prototype.enterVersion = function(ctx) {
};
enterVersion = function(ctx) {
};

// Exit a parse tree produced by QASMParser#version.
QASMListener.prototype.exitVersion = function(ctx) {
};
exitVersion = function(ctx) {
};


// Enter a parse tree produced by QASMParser#include.
QASMListener.prototype.enterInclude = function(ctx) {
};
enterInclude = function(ctx) {
};

// Exit a parse tree produced by QASMParser#include.
QASMListener.prototype.exitInclude = function(ctx) {
};
exitInclude = function(ctx) {
};


// Enter a parse tree produced by QASMParser#filename.
QASMListener.prototype.enterFilename = function(ctx) {
};
enterFilename = function(ctx) {
};

// Exit a parse tree produced by QASMParser#filename.
QASMListener.prototype.exitFilename = function(ctx) {
};
exitFilename = function(ctx) {
};


// Enter a parse tree produced by QASMParser#decl.
QASMListener.prototype.enterDecl = function(ctx) {
};
enterDecl = function(ctx) {
};

// Exit a parse tree produced by QASMParser#decl.
QASMListener.prototype.exitDecl = function(ctx) {
};
exitDecl = function(ctx) {};


// Enter a parse tree produced by QASMParser#gatedecl.
QASMListener.prototype.enterGatedecl = function(ctx) {
};
enterGatedecl = function(ctx) {};

// Exit a parse tree produced by QASMParser#gatedecl.
QASMListener.prototype.exitGatedecl = function(ctx) {
};

exitGatedecl = function(ctx) {};

// Enter a parse tree produced by QASMParser#goplist.
QASMListener.prototype.enterGoplist = function(ctx) {
};
enterGoplist = function(ctx) {};

// Exit a parse tree produced by QASMParser#goplist.
QASMListener.prototype.exitGoplist = function(ctx) {
};
exitGoplist = function(ctx) {};


// Enter a parse tree produced by QASMParser#qop.
QASMListener.prototype.enterQop = function(ctx) {
};
enterQop = function(ctx) {};

// Exit a parse tree produced by QASMParser#qop.
QASMListener.prototype.exitQop = function(ctx) {
};
exitQop = function(ctx) {};


// Enter a parse tree produced by QASMParser#uop.
QASMListener.prototype.enterUop = function(ctx) {
};
enterUop = function(ctx) {};

// Exit a parse tree produced by QASMParser#uop.
QASMListener.prototype.exitUop = function(ctx) {
};
exitUop = function(ctx) {};


// Enter a parse tree produced by QASMParser#anylist.
QASMListener.prototype.enterAnylist = function(ctx) {
};
enterAnylist = function(ctx) {};

// Exit a parse tree produced by QASMParser#anylist.
QASMListener.prototype.exitAnylist = function(ctx) {
};
exitAnylist = function(ctx) {};


// Enter a parse tree produced by QASMParser#idlist.
QASMListener.prototype.enterIdlist = function(ctx) {
};
enterIdlist = function(ctx) {};

// Exit a parse tree produced by QASMParser#idlist.
QASMListener.prototype.exitIdlist = function(ctx) {
};
exitIdlist = function(ctx) {};


// Enter a parse tree produced by QASMParser#mixedlist.
QASMListener.prototype.enterMixedlist = function(ctx) {
};
enterMixedlist = function(ctx) {};

// Exit a parse tree produced by QASMParser#mixedlist.
QASMListener.prototype.exitMixedlist = function(ctx) {
};
exitMixedlist = function(ctx) {};


// Enter a parse tree produced by QASMParser#argument.
QASMListener.prototype.enterArgument = function(ctx) {
};
enterArgument = function(ctx) {};

// Exit a parse tree produced by QASMParser#argument.
QASMListener.prototype.exitArgument = function(ctx) {
};
exitArgument = function(ctx) {};


// Enter a parse tree produced by QASMParser#explist.
QASMListener.prototype.enterExplist = function(ctx) {
};
enterExplist = function(ctx) {};

// Exit a parse tree produced by QASMParser#explist.
QASMListener.prototype.exitExplist = function(ctx) {
};

exitExplist = function(ctx) {};

// Enter a parse tree produced by QASMParser#exp.
QASMListener.prototype.enterExp = function(ctx) {
};
enterExp = function(ctx) {};

// Exit a parse tree produced by QASMParser#exp.
QASMListener.prototype.exitExp = function(ctx) {
};

exitExp = function(ctx) {};

// Enter a parse tree produced by QASMParser#atom.
QASMListener.prototype.enterAtom = function(ctx) {
};
enterAtom = function(ctx) {};

// Exit a parse tree produced by QASMParser#atom.
QASMListener.prototype.exitAtom = function(ctx) {
};

exitAtom = function(ctx) {};

// Enter a parse tree produced by QASMParser#unaryop.
QASMListener.prototype.enterUnaryop = function(ctx) {
};
enterUnaryop = function(ctx) {};

// Exit a parse tree produced by QASMParser#unaryop.
QASMListener.prototype.exitUnaryop = function(ctx) {
};



exports.QASMListener = QASMListener;
exitUnaryop = function(ctx) {};
}
Loading

0 comments on commit 44e5727

Please sign in to comment.