public Object valueFromLiteralToken(LexicalLiteralToken token) { switch (token.OperandNodeType) { case ParseNodeType.Nil: return(null); case ParseNodeType.True: return(trueConstant); case ParseNodeType.False: return(falseConstant); case ParseNodeType.Integer: return(((IntegerLiteralToken)token).SmallIntegerValue); case ParseNodeType.ScaledDecimal: throw new UnimplementedPrimitiveException(); case ParseNodeType.SinglePrecision: return(((SinglePrecisionLiteralToken)token).FloatValue); case ParseNodeType.DoublePrecision: return(((DoublePrecisionLiteralToken)token).DoubleValue); case ParseNodeType.QuadPrecision: return(((QuadPrecisionLiteralToken)token).DecimalValue); case ParseNodeType.Char: return(((CharLiteralToken)token).CharValue); case ParseNodeType.String: var stString = objectSpace.newString(((StringLiteralToken)token).StringValue); stString.beImmutable(); return(stString); case ParseNodeType.Symbol: return(symbolFrom((SymbolLiteralToken)token)); case ParseNodeType.LiteralBindingReference: LiteralBindingReferenceToken lbrToken = (LiteralBindingReferenceToken)token; var pathName = objectSpace.pathnameFromString(lbrToken.StringValue); pathName.beImmutable(); return(pathName); case ParseNodeType.ByteArray: var stByteArray = objectSpace.newByteArray(((ByteArrayLiteralToken)token).ByteArray); stByteArray.beImmutable(); return(stByteArray); case ParseNodeType.Array: ArrayLiteralToken arrayToken = (ArrayLiteralToken)token; var elements = new List <Object>(); arrayToken.elementsDo(element => elements.Add(valueFromLiteralToken(element))); var stArray = objectSpace.newArray(elements.ToArray()); stArray.beImmutable(); return(stArray); default: return(null); } }
public override AbstractSyntaxTreeNode applyToArrayLiteralToken(ArrayLiteralToken operand) { return(Context.newReducedNode(valueFromLiteralToken(operand))); }
// Lexical Tokens public virtual T applyToArrayLiteralToken(ArrayLiteralToken operand) { return(applyToParseTreeNode(operand)); }