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

31 lines
905 B
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");
private final ListNode node;
public SpecialForm(ListNode node) {
this.node = node;
}
public static Node check(ListNode 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;
}
}