You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.9 KiB

  1. #!/usr/bin/env node
  2. /*
  3. Copyright 2018 0kims association
  4. This file is part of jaz (Zero Knowlage Circuit compiler).
  5. jaz is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. jaz is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with jaz. If not, see <https://www.gnu.org/licenses/>.
  15. */
  16. /* eslint-disable no-console */
  17. const fs = require("fs");
  18. const path = require("path");
  19. const compiler = require("./src/compiler");
  20. const argv = require("yargs")
  21. .version(function() {
  22. return require("./package").version;
  23. })
  24. .usage("jaz -s [input source circuit file] -o [output definition circuit file]")
  25. .alias("s", "source")
  26. .alias("o", "output")
  27. .require(["s","o"])
  28. .help("h")
  29. .alias("h", "help")
  30. .epilogue(`Copyright (C) 2018 0kims association
  31. This program comes with ABSOLUTELY NO WARRANTY;
  32. This is free software, and you are welcome to redistribute it
  33. under certain conditions; see the COPYING file in the official
  34. repo directory at https://github.com/iden3/jaz `)
  35. .argv;
  36. const fullFileName = path.resolve(process.cwd(), argv.source);
  37. compiler(fullFileName).then( (cir) => {
  38. fs.writeFileSync(argv.output, JSON.stringify(cir, null, 1), "utf8");
  39. }, (err) => {
  40. console.error(`ERROR at ${err.errFile}:${err.pos.first_line},${err.pos.first_column}-${err.pos.last_line},${err.pos.last_column} ${err.errStr}`);
  41. console.error(JSON.stringify(err.ast, null, 1));
  42. process.exit(1);
  43. });