-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompilerTest.java
More file actions
26 lines (21 loc) · 776 Bytes
/
Copy pathCompilerTest.java
File metadata and controls
26 lines (21 loc) · 776 Bytes
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
package de.emilschlampp.scheCPU.examples.compile;
import de.emilschlampp.scheCPU.examples.Main;
import de.emilschlampp.scheCPU.compile.Compiler;
import java.io.FileOutputStream;
import java.util.Scanner;
public class CompilerTest {
public static void main(String[] args) throws Throwable {
Scanner scanner = new Scanner(Main.class.getResourceAsStream("/simple-loadstrm.sasm"));
String l = "";
while (scanner.hasNextLine()) {
l+="\n"+scanner.nextLine();
}
if(!l.isEmpty()) {
l = l.substring(1);
}
byte[] code = new Compiler(l).compile();
FileOutputStream outputStream = new FileOutputStream("compile.sbin");
outputStream.write(code);
outputStream.close();
}
}