-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
49 lines (41 loc) · 1.23 KB
/
Copy pathmain.js
File metadata and controls
49 lines (41 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const fs = require('fs');
const readline = require('readline');
console.log("EZ Java v1 - Compiling")
async function ApplyChanges() {
const fileStream = fs.createReadStream(process.argv.slice(2)[0]);
var loggerq = fs.createWriteStream(process.argv.slice(2)[1])
loggerq.write("")
var logger = fs.createWriteStream(process.argv.slice(2)[1], {
flags: 'a'
})
const rl = readline.createInterface({
input: fileStream,
crlfDelay: Infinity
});
var lines = [];
var plus = 0;
for await (const line of rl) {
lines.push({"line": line, "num": plus})
var out = line.replace("pub", "public")
out = out.replace("stat", "static")
out = out.replace("nul", "void")
out = out.replace("str", "String")
out = out.replace("Sys.log", "System.out.println")
out = out.replace("Sys.print", "System.out.print")
out = out.replace("syscls", "class")
out = out.replace("pkg", "package")
out = out.replace("req", "import")
logger.write("\n" + out)
plus++
}
var line2 = 0;
lines.forEach((value, index, array) => {
if (line2 >= 10) {
console.log(`${value.num}| ${value.line}`)
} else {
console.log(`${value.num} | ${value.line}`)
}
line2++;
})
}
ApplyChanges()