Example #1
0
        public override Exp Analy( )
        {
            LiteralKind  = LiteralToken.Kind;
            LiteralValue = LiteralToken.GetText();

            if (LiteralKind == TokenKind.LiteralInt)
            {
                RetType = ZTypeManager.ZINT;// .GetByZType( typeof(整数));// intType;
            }
            else if (LiteralKind == TokenKind.LiteralFloat)
            {
                RetType = ZTypeManager.ZFLOAT;//.GetByZType(typeof(浮点数));//floatType;
            }
            else if (LiteralKind == TokenKind.LiteralString)
            {
                RetType = ZTypeManager.ZSTRING;//.GetByZType(typeof(文本));//stringType;
            }
            else if (LiteralKind == TokenKind.True || LiteralKind == TokenKind.False)
            {
                RetType = ZTypeManager.ZBOOL;//.GetByZType(typeof(判断符));//boolType;
            }
            else if (LiteralKind == TokenKind.NULL)
            {
                RetType = null; //ZTypeCache.CreateZRealType(typeof(整数));// null;
            }
            else
            {
                ErrorE(this.Postion, LiteralToken.ToCode() + "不是正确的值");
                //return null;
            }
            return(this);
        }
Example #2
0
        public override Exp Analy(AnalyExpContext context)
        {
            base.Analy(context);
            LiteralKind  = LiteralToken.Kind;
            LiteralValue = LiteralToken.GetText();

            if (LiteralKind == TokenKind.LiteralInt)
            {
                RetType = intType;
            }
            else if (LiteralKind == TokenKind.LiteralFloat)
            {
                RetType = floatType;
            }
            else if (LiteralKind == TokenKind.LiteralString)
            {
                RetType = stringType;
            }
            else if (LiteralKind == TokenKind.True || LiteralKind == TokenKind.False)
            {
                RetType = boolType;
            }
            else if (LiteralKind == TokenKind.NULL)
            {
                RetType = null;
            }
            else
            {
                error(LiteralToken.ToCode() + "不是正确的值");
                return(null);
            }
            return(this);
        }