SHARE
TWEET

Untitled

a guest Dec 3rd, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var LineReader = require('node-line-reader').LineReader;
  2. const fs = require('fs');
  3.  
  4. let mem = [5,9,4,2,7,8];
  5. let accumulator = 0;
  6. let R0 = 0;
  7. let marks = [];
  8. let counter = 0;
  9.  
  10. fs.readFile('code.txt', {encoding: 'utf-8'}, function(err, data) {
  11.     if (!err) {
  12.         let code = data.replace(/,/g,'').replace(/\r/g,'').split('\n');
  13.         let filtered = code.filter((val, i, arr) => {
  14.             return val != '';
  15.         });
  16.         runProgram(filtered);
  17.     } else {
  18.         console.log(err);
  19.     }
  20. });
  21.  
  22. const runProgram = (sourceCode) => {
  23.     while(counter < sourceCode.length - 1) {
  24.         if (sourceCode[counter].includes(':')) {
  25.             marks.push({pos: counter, val: sourceCode[counter].replace(/:/g,'')});
  26.         } else {
  27.             processCommand(sourceCode[counter]);
  28.         }
  29.         counter++;
  30.     }
  31.     console.log(marks);
  32. }
  33.  
  34. const processCommand = (line) => {
  35.     let data = line.split(' ');
  36.     console.log(data);
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top