1
0

runner.js 1.6 KB

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