main.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { IVProgParser } from './ast/ivprogParser';
  2. import { IVProgProcessor } from './processor/ivprogProcessor';
  3. import { SemanticAnalyser } from "./processor/semantic/semanticAnalyser";
  4. import {DOMInput} from './io/domInput';
  5. import {DOMOutput} from './io/domOutput';
  6. import { LanguageService } from './services/languageService';
  7. import { LocalizedStrings } from './services/localizedStringsService';
  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 semAna = new SemanticAnalyser(data);
  34. const proc = new IVProgProcessor(semAna.analyseTree());
  35. proc.registerInput(domIn);
  36. domOut.clear();
  37. proc.registerOutput(domOut);
  38. proc.interpretAST().then(_ => editor.load({}))
  39. .catch( e => {alert(e);console.log(e);});
  40. } catch (error) {
  41. alert(error);
  42. console.log(error);
  43. }
  44. });
  45. } catch(a) {
  46. console.log(a);
  47. }