quit builtin function has been added
This commit is contained in:
parent
0c025241b7
commit
3f3f109c12
|
@ -1,15 +1,15 @@
|
||||||
package serene.simple;
|
package serene.simple;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import serene.simple.builtin.AFn;
|
|
||||||
import serene.simple.builtin.PrintlnFn;
|
import serene.simple.builtin.PrintlnFn;
|
||||||
|
import serene.simple.builtin.QuitFn;
|
||||||
|
|
||||||
|
|
||||||
public class RootScope extends BaseScope {
|
public class RootScope extends BaseScope {
|
||||||
private final BaseScope parent;
|
private final BaseScope parent;
|
||||||
private final HashMap<String, Object> symbolsMapping = new HashMap<String, Object>() {{
|
private final HashMap<String, Object> symbolsMapping = new HashMap<String, Object>() {{
|
||||||
put("println", new PrintlnFn());
|
put("println", new PrintlnFn());
|
||||||
|
put("quit", new QuitFn());
|
||||||
}};
|
}};
|
||||||
// "+", PlusFn,
|
// "+", PlusFn,
|
||||||
// "-", MinusFn,
|
// "-", MinusFn,
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package serene.simple.builtin;
|
||||||
|
|
||||||
|
import serene.simple.BaseScope;
|
||||||
|
|
||||||
|
|
||||||
|
public class QuitFn extends AFn {
|
||||||
|
public String fnName() {
|
||||||
|
return "println";
|
||||||
|
};
|
||||||
|
|
||||||
|
public Object eval(BaseScope scope) {
|
||||||
|
System.exit(0);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue