1
0

main.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { IVProgParser } from './ast/ivprogParser';
  2. import { IVProgProcessor } from './processor/ivprogProcessor';
  3. import {DOMInput} from './io/domInput';
  4. import {DOMOutput} from './io/domOutput';
  5. import { LanguageService } from './services/languageService';
  6. import { LocalizedStrings } from './services/localizedStringsService';
  7. const ivprogLexer = LanguageService.getCurrentLexer();
  8. console.log(LocalizedStrings.getUI('start'));
  9. // const lexer = new ivprogLexer(new InputStream(input));
  10. // const stream = new CommonTokenStream(lexer);
  11. // stream.fill();
  12. // let i = 1;
  13. // let token = null;
  14. // while ((token = stream.LT(i)).type !== ivprogLexer.EOF && token.type !== ivprogLexer.WHITESPACE) {
  15. // console.log(`${token.type}-${token.text}`);
  16. // console.log('\n')
  17. // i++;
  18. // }
  19. // const anaSin = new IVProgParser(input, ivprogLexer);
  20. const editor = new JsonEditor('#json-renderer', {});
  21. const domIn = new DOMInput('#dom-in');
  22. const domOut = new DOMOutput('#dom-out');
  23. // proc.interpretAST().then( sto => {
  24. // console.log(sto.applyStore('a'));
  25. // }).catch(e => console.log(e));
  26. try {
  27. $('#btn').click( () => {
  28. const input = $('#input').val();
  29. const analiser = new IVProgParser(input, ivprogLexer);
  30. try {
  31. const data = analiser.parseTree();
  32. const proc = new IVProgProcessor(data);
  33. proc.registerInput(domIn);
  34. domOut.clear();
  35. proc.registerOutput(domOut);
  36. proc.interpretAST().then(_ => editor.load({}))
  37. .catch( e => {alert(e);console.log(e);});
  38. } catch (error) {
  39. alert(error);
  40. console.log(error);
  41. }
  42. });
  43. } catch(a) {
  44. console.log(a);
  45. }