main.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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(sto => editor.load(sto.store))
  37. .catch( e => alert(e));
  38. } catch (error) {
  39. alert(error);
  40. }
  41. });
  42. } catch(a) {
  43. console.log(a);
  44. }