|
@@ -6,6 +6,8 @@ import * as Commands from './ast/commands';
|
|
|
import { IVProgParser } from './ast/ivprogParser';
|
|
|
import Lexers from '../grammar/';
|
|
|
import { IVProgProcessor } from './processor/ivprogProcessor';
|
|
|
+import {DOMInput} from './io/domInput';
|
|
|
+import {DOMOutput} from './io/domOutput';
|
|
|
|
|
|
const lang = 'pt_br';
|
|
|
|
|
@@ -29,27 +31,30 @@ const input = `programa {
|
|
|
// console.log('\n')
|
|
|
// i++;
|
|
|
// }
|
|
|
-const anaSin = new IVProgParser(input, ivprogLexer);
|
|
|
-const proc = new IVProgProcessor(anaSin.parseTree());
|
|
|
-proc.interpretAST().then( sto => {
|
|
|
- console.log(sto.applyStore('a'));
|
|
|
-}).catch(e => console.log(e));
|
|
|
-// try {
|
|
|
-// const data = anaSin.parseTree();
|
|
|
-// console.log(data);
|
|
|
-// var editor = new JsonEditor('#json-renderer', data);
|
|
|
-// $('#btn').click( () => {
|
|
|
-// const input = $('#input').val();
|
|
|
-// const analiser = new IVProgParser(input, ivprogLexer);
|
|
|
-// try {
|
|
|
-// const data = analiser.parseTree();
|
|
|
-// console.log(data);
|
|
|
-// editor.load(data);
|
|
|
-// } catch (error) {
|
|
|
-// alert(error);
|
|
|
-// }
|
|
|
+// const anaSin = new IVProgParser(input, ivprogLexer);
|
|
|
+const editor = new JsonEditor('#json-renderer', {});
|
|
|
+const domIn = new DOMInput('#dom-in');
|
|
|
+const domOut = new DOMOutput('#dom-out');
|
|
|
+// proc.interpretAST().then( sto => {
|
|
|
+// console.log(sto.applyStore('a'));
|
|
|
+// }).catch(e => console.log(e));
|
|
|
+try {
|
|
|
+ $('#btn').click( () => {
|
|
|
+ const input = $('#input').val();
|
|
|
+ const analiser = new IVProgParser(input, ivprogLexer);
|
|
|
+ try {
|
|
|
+ const data = analiser.parseTree();
|
|
|
+ const proc = new IVProgProcessor(data);
|
|
|
+ proc.registerInput(domIn);
|
|
|
+ domOut.clear();
|
|
|
+ proc.registerOutput(domOut);
|
|
|
+ proc.interpretAST().then(sto => editor.load(sto.store))
|
|
|
+ .catch( e => alert(e));
|
|
|
+ } catch (error) {
|
|
|
+ alert(error);
|
|
|
+ }
|
|
|
|
|
|
-// });
|
|
|
-// } catch(a) {
|
|
|
-// console.log(a);
|
|
|
-// }
|
|
|
+ });
|
|
|
+} catch(a) {
|
|
|
+ console.log(a);
|
|
|
+}
|