コード例 #1
0
        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);
            }
        }
コード例 #2
0
 public override AbstractSyntaxTreeNode applyToArrayLiteralToken(ArrayLiteralToken operand)
 {
     return(Context.newReducedNode(valueFromLiteralToken(operand)));
 }
コード例 #3
0
        // Lexical Tokens

        public virtual T applyToArrayLiteralToken(ArrayLiteralToken operand)
        {
            return(applyToParseTreeNode(operand));
        }