[tlox] Add 'Nil'
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package xyz.ctsk.lox.nodes.expr;
|
||||
|
||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||
import xyz.ctsk.lox.nodes.LoxExpressionNode;
|
||||
|
||||
public class LoxNilLiteralNode extends LoxExpressionNode {
|
||||
@Override
|
||||
public Object executeGeneric(VirtualFrame frame) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package xyz.ctsk.lox.parser;
|
||||
|
||||
import com.oracle.truffle.api.strings.TruffleString;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import xyz.ctsk.lox.LoxException;
|
||||
import xyz.ctsk.lox.nodes.LoxExpressionNode;
|
||||
import xyz.ctsk.lox.nodes.expr.*;
|
||||
|
||||
@@ -22,6 +21,10 @@ public class LoxNodeFactory {
|
||||
return new LoxBooleanLiteralNode(value);
|
||||
}
|
||||
|
||||
public static LoxNilLiteralNode createNilLiteral() {
|
||||
return new LoxNilLiteralNode();
|
||||
}
|
||||
|
||||
public static LoxExpressionNode createUnary(Token op, LoxExpressionNode value) {
|
||||
return switch (op.getText()) {
|
||||
case "-" -> LoxNegNodeGen.create(value);
|
||||
|
||||
@@ -48,6 +48,7 @@ literal returns [LoxExpressionNode result]
|
||||
| STRING { $result = factory.createStringLiteral($STRING); }
|
||||
| TRUE { $result = factory.createBooleanLiteral($TRUE); }
|
||||
| FALSE { $result = factory.createBooleanLiteral($FALSE); }
|
||||
| NIL { $result = factory.createNilLiteral(); }
|
||||
;
|
||||
|
||||
AND: 'and' ;
|
||||
|
||||
Reference in New Issue
Block a user