36 lines
1.0 KiB
Java
36 lines
1.0 KiB
Java
package serene.simple;
|
|
|
|
|
|
public class SpecialForm extends Node {
|
|
private static final SymbolNode DEF = new SymbolNode("def");
|
|
private static final SymbolNode FN = new SymbolNode("fn");
|
|
private static final SymbolNode IF = new SymbolNode("if");
|
|
private static final SymbolNode QUOTE = new SymbolNode("quote");
|
|
|
|
public final ListNode<Node> node;
|
|
|
|
public SpecialForm(ListNode<Node> node) {
|
|
this.node = node;
|
|
}
|
|
|
|
public static Node check(ListNode<Node> l) {
|
|
if (l == ListNode.EMPTY) {
|
|
return l;
|
|
} else if (l.first.equals(DEF)) {
|
|
return new DefSpecialForm(l);
|
|
} else if (l.first.equals(FN)) {
|
|
return new FnSpecialForm(l);
|
|
} else if (l.first.equals(IF)) {
|
|
return new IfSpecialForm(l);
|
|
} else if (l.first.equals(QUOTE)) {
|
|
return new QuoteSpecialForm(l);
|
|
}
|
|
return l;
|
|
}
|
|
|
|
@Override
|
|
public Object eval(Scope scope) {
|
|
throw new SereneException("Can't use SpecialForm directly");
|
|
}
|
|
}
|