org.jruby.ast.LiteralNode Maven / Gradle / Ivy
package org.jruby.ast;
import java.util.List;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.lexer.yacc.Token;
/**
* This is not a node in the classic sense in that it has no defined or
* interpret method which can be called. It just stores the position of
* the literal and the name/value of the literal. We made it a node so that
* the parser needs to work less hard in its productions. dynamic literals
* are nodes and by having literals also be nodes means they have a common
* subtype which is not Object.
*/
public class LiteralNode extends Node implements InvisibleNode {
private String name;
public LiteralNode(Token token) {
super(token.getPosition());
this.name = (String) token.getValue();
}
public String getName() {
return name;
}
/**
* Accept for the visitor pattern.
* @param iVisitor the visitor
**/
public Object accept(NodeVisitor iVisitor) {
return iVisitor.visitLiteralNode(this);
}
public List childNodes() {
return EMPTY_LIST;
}
@Override
public NodeType getNodeType() {
return NodeType.LITERALNODE;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy