diff --git a/src/main/java/serene/simple/BaseScope.java b/src/main/java/serene/simple/BaseScope.java index d0d6365..c165190 100644 --- a/src/main/java/serene/simple/BaseScope.java +++ b/src/main/java/serene/simple/BaseScope.java @@ -23,7 +23,7 @@ public abstract class BaseScope { return this.parent.lookupSymbol(symbolName); } else { - throw new RuntimeException(String.format("Variable '%s' is not defined in this scope.", + throw new RuntimeException(String.format("Symbol '%s' is not defined in this scope.", symbolName)); } } diff --git a/src/main/java/serene/simple/Main.java b/src/main/java/serene/simple/Main.java index 0a93c09..b56335e 100644 --- a/src/main/java/serene/simple/Main.java +++ b/src/main/java/serene/simple/Main.java @@ -1,16 +1,21 @@ package serene.simple; import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Scanner; -import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.Console; import java.io.FileInputStream; public class Main { - public static void main(String[] args) throws IOException { + + private static void isJava8() throws RuntimeException { + if (System.getProperty("java.vm.specification.version").equals("1.8")) + throw new RuntimeException("Minimume required version of JDK is 1.8"); + } + + public static void main(String[] args) throws IOException, RuntimeException { + Main.isJava8(); + if (args.length == 0) { startRepl(); return; diff --git a/src/main/java/serene/simple/RootScope.java b/src/main/java/serene/simple/RootScope.java index 8c95eec..6d76f52 100644 --- a/src/main/java/serene/simple/RootScope.java +++ b/src/main/java/serene/simple/RootScope.java @@ -4,7 +4,7 @@ import java.util.HashMap; import serene.simple.builtin.PrintlnFn; import serene.simple.builtin.QuitFn; import serene.simple.builtin.PlusFn; - +import serene.simple.builtin.NewFn; public class RootScope extends BaseScope { private final BaseScope parent; @@ -15,6 +15,7 @@ public class RootScope extends BaseScope { put("System", System.class); put("Boolean", Boolean.class); put("String", String.class); + put("new", new NewFn()); }}; // "+", PlusFn, // "-", MinusFn, @@ -36,7 +37,7 @@ public class RootScope extends BaseScope { return this.symbolsMapping.get(symbolName); } else { - throw new RuntimeException(String.format("Variable '%s' is not defined in this scope.", + throw new RuntimeException(String.format("Symbol '%s' is not defined in this scope.", symbolName)); } }