serene-simple/src/main/java/serene/simple/Main.java

47 lines
1.1 KiB
Java
Raw Normal View History

/*
* This Java source file was generated by the Gradle 'init' task.
*/
package serene.simple;
import java.io.IOException;
import java.io.ByteArrayInputStream;
import java.io.Console;
import java.io.FileInputStream;
public class Main {
public static void main(String[] args) throws IOException {
if (args.length == 0) {
startRepl();
}
runSerene(args[0]);
}
private static void startRepl() {
Environment rootEnv = Environment.getBaseEnvironment();
Console console = System.console();
while(true) {
String inputData = console.readLine("serene-> ");
if (expr == null) break;
ByteArrayInputStream inputStream = new ByteArrayInputStream(inputData.getBytes());
ListNode<Node> nodes = Reader.read(inputStream);
...
}
}
private static void runSerene(String filePath) throws IOException {
Environment rootEnv = Environment.getBaseEnvironment();
ListNode<Node> nodes = Reader.read(new FileInputStream(filePath));
for (Node n : nodes) {
n.eval(rootEnv);
}
}
}