Closed hkar19 closed 2 years ago
fs.readFileSync in jaksel-interpreter.js will yield different result when run on windows platform. see this stackoverflow answer
fs.readFileSync
jaksel-interpreter.js
we need to replace endline \r\n with \n to accomodate further parsing downstream.
\r\n
\n
# run on windows # notice the `\r\n` does not exist in mac or linux. { inputJaksel: 'literally umur itu 21\r\n' + 'spill "Umur lu " + umur\r\n' + 'kalo umur lebih gede 20\r\n' + ' spill "Elu tua"\r\n' + ' literally umurgua itu umur + 10\r\n' + ' spill "Kalo gua umurnya " + umurgua\r\n' + ' kalo umurgua lebih gede 30\r\n' + ' spill "gua lebih tua"\r\n' + ' udahan\r\n' + 'kalogak\r\n' + ' spill "dasar bocil"\r\n' + 'udahan\r\n' + 'spill "Udahan ah"' } { cmdLines: [ 'literally umur itu 21', 'spill "Umur lu " + umur\r', 'kalo umur lebih gede 20\r', ' spill "Elu tua"\r', ' literally umurgua itu umur + 10\r', ' spill "Kalo gua umurnya " + umurgua\r', ' kalo umurgua lebih gede 30\r', ' spill "gua lebih tua"\r', ' udahan\r', 'kalogak\r', ' spill "dasar bocil"\r', 'udahan\r', 'spill "Udahan ah"' ], cmds: [ { exp: 'let umur = 21;' }, { exp: 'console.log("Umur lu " + umur);' }, { exp: 'if (umur > 20\r)', openGroup: true }, { exp: 'console.log("Elu tua");' }, { exp: 'let umurgua = umur + 10\r;' }, { exp: 'console.log("Kalo gua umurnya " + umurgua);' }, { exp: 'if (umurgua > 30\r)', openGroup: true }, { exp: 'console.log("gua lebih tua");' }, { exp: 'console.log("dasar bocil");' }, { exp: 'console.log("Udahan ah");' } ], input: 'literally umur itu 21\r\n' + 'spill "Umur lu " + umur\r\n' + 'kalo umur lebih gede 20\r\n' + ' spill "Elu tua"\r\n' + ' literally umurgua itu umur + 10\r\n' + ' spill "Kalo gua umurnya " + umurgua\r\n' + ' kalo umurgua lebih gede 30\r\n' + ' spill "gua lebih tua"\r\n' + ' udahan\r\n' + 'kalogak\r\n' + ' spill "dasar bocil"\r\n' + 'udahan\r\n' + 'spill "Udahan ah"', }
Nice fix !, Thank you.
fs.readFileSync
injaksel-interpreter.js
will yield different result when run on windows platform. see this stackoverflow answerwe need to replace endline
\r\n
with\n
to accomodate further parsing downstream.