transpile.ts 742 B

1234567891011121314151617181920212223242526272829303132
  1. import Transpiler from './transpilers/transpiler'
  2. import _transpiler from './transpilers/all'
  3. //import compile from './runtime/query/compiler'
  4. //import compile from './reference-implementation/molql/compiler'
  5. const transpiler: {[index: string]: Transpiler} = _transpiler
  6. //const util = require('util')
  7. export function parse(lang: string, str: string) {
  8. try {
  9. const query = transpiler[lang](str);
  10. console.log(str);
  11. //console.log(util.inspect(query, {depth: 20, color: true}));
  12. console.log('\n');
  13. return query;
  14. //compile(query)
  15. } catch (e) {
  16. console.log(str);
  17. console.log(e.message);
  18. console.log('\n');
  19. }
  20. }
  21. const [,,lang, str] = process.argv;
  22. if (lang && str) {
  23. parse(lang, str);
  24. }
  25. //export default parse;