Beispiel #1
0
        public override Exp Analy(AnalyExpContext context)
        {
            base.Analy(context);
            var symbols = this.AnalyExpContext.Symbols;
            OpKind = OpToken.Kind;

           if(OpKind!= TokenKind.ADD && OpKind!= TokenKind.SUB)
           {
               errorf(OpToken.Postion, "运算符'{0}'缺少表达式", OpToken.GetText());
               return null;
           }

           RightExp = RightExp.Analy(context);//RightExp = AnalyExp(RightExp);
           if(RightExp==null)
           {
               TrueAnalyed = false;
               return null;
           }
     
            Type rtype = RightExp.RetType;
            RetType = rtype;
            if(rtype!= typeof(int)&& rtype!= typeof(float) && rtype!= typeof(double) && rtype != typeof(decimal))
            {
                errorf(RightExp.Postion,"不能进行'{0}'运算",OpToken.GetText());
                return null;
            }

            if (OpKind == TokenKind.ADD)
            {
                return RightExp;
            }
            return this;
        }
Beispiel #2
0
 public override Exp Analy(AnalyExpContext context)
 {
     base.Analy(context);
     this.TrueAnalyed = true;
     for (int i = 0; i < InneExps.Count; i++)
     {
         Exp exp = InneExps[i];
         exp = exp.Analy(context);
         if (exp == null)
         {
             TrueAnalyed = false;
         }
         else
         {
             InneExps[i] = exp;
             TrueAnalyed = TrueAnalyed && exp.TrueAnalyed;
         }
     }
     if (InneExps.Count == 1)
     {
         RetType = InneExps[0].RetType;
     }
     else
     {
         RetType = null;
     }
     return(this);
 }
Beispiel #3
0
        public override Exp Analy(AnalyExpContext context)
        {
            base.Analy(context);
            var symbols = this.AnalyExpContext.Symbols;
            Exp exp     = null;

            exp = analyNewExp(context);

            if (exp == null)
            {
                exp = analyDiExp();
            }

            if (exp == null)
            {
                InvokeExp invokeexp = new InvokeExp(this);
                invokeexp.Elements = this.Elements;
                exp = invokeexp;
            }

            if (exp != null)
            {
                exp = exp.Analy(context);//exp = AnalyExp(exp);
                return(exp);
            }

            throw new CompileException("FCallExp无法分析完成");
        }
 public override Exp Analy(AnalyExpContext context)
 {
     base.Analy(context);
     ValueExp = ValueExp.Analy(context);
     if (ValueExp == null)
     {
         return(null);
     }
     RetType = ValueExp.RetType;
     return(this);
 }
Beispiel #5
0
        public override Exp Analy(AnalyExpContext context)
        {
            base.Analy(context);
            identParser = new IdentParser();
            symbols     = this.AnalyExpContext.Symbols;

            IdentName    = IdentToken.GetText();
            classContext = context.StmtContext.MethodContext.ClassContext;

            Exp exp = null;

            exp = analyCurrentClass(context);

            if (exp == null)
            {
                exp = analyParentClass(context);
            }

            if (exp == null)
            {
                exp = analyAsDirectMember(context);
            }

            if (exp == null)
            {
                exp = analyCall(context).Item1;
            }

            if (exp == null)
            {
                if (IdentName.IndexOf('的') != -1 || IdentName.IndexOf('第') != -1)
                {
                    exp = analyDiDe(context);
                }
                else
                {
                    exp = analyType(context);
                }
            }
            if (exp == null)
            {
                exp = dimVar(context);
            }

            if (exp != null)
            {
                exp = exp.Analy(context);//
                return(exp);
            }
            return(null);
        }
Beispiel #6
0
 protected Exp AnalySubExp(Exp exp)
 {
     if (exp == null)
     {
         AnalyCorrect = false;
         return(null);
     }
     else
     {
         exp          = exp.Analy();
         AnalyCorrect = AnalyCorrect && exp.AnalyCorrect;
         return(exp);
     }
 }
Beispiel #7
0
        public override Exp Analy()
        {
            //if (this.IsAnalyed) return this;
            ChainParser parser = new ChainParser();
            //if(DebugStatics.IsInDebug)
            //{
            //    DebugStatics.TempFunc(RawElements);
            //}
            Exp exp  = parser.Parse(RawElements, this.ExpContext, IsAssignTo); //结果已经Analy过
            Exp exp2 = exp.Analy();

            IsAnalyed = true;
            return(exp2);
        }
Beispiel #8
0
        public override Exp Analy( )
        {
            if (IsAnalyed)
            {
                return(this);
            }
            ExpBracketTagNew newTagExp = AnalyToTagNew();

            if (newTagExp != null)
            {
                IsAnalyed         = true;
                this.AnalyCorrect = true;
                return(newTagExp);
            }
            //if(this.InneExps.Count==1)
            //{
            //    if (InneExps[0] is ExpTagNew)
            //    {
            //        ExpBracketTagNew exp = new ExpBracketTagNew(this.LeftBracketToken,
            //            this.RightBracketToken, (InneExps[0] as ExpTagNew));
            //        exp.SetContext(this.ExpContext);
            //        return exp.Analy();
            //    }
            //}
            this.AnalyCorrect = true;
            for (int i = 0; i < InneExps.Count; i++)
            {
                Exp exp = InneExps[i];
                //exp.SetContext(this.ExpContext);
                exp = exp.Analy();
                if (exp == null)
                {
                    AnalyCorrect = false;
                }
                else
                {
                    InneExps[i]  = exp;
                    AnalyCorrect = AnalyCorrect && exp.AnalyCorrect;
                }
            }
            AnalyRet();
            IsAnalyed = true;
            return(this);
        }
Beispiel #9
0
        public override Exp Analy(AnalyExpContext context)
        {
            base.Analy(context);
            var symbols = this.AnalyExpContext.Symbols;

            SubjectExp = SubjectExp.Analy(context); // AnalyExp(SubjectExp);
            ArgExp     = ArgExp.Analy(context);     //AnalyExp(ArgExp);
            var propertyName = "Item";
            var subjType     = SubjectExp.RetType;

            ExProperty = GclUtil.SearchExProperty(propertyName, subjType); //subjType.GetExProperty(propertyName);

            if (ExProperty == null)
            {
                error(SubjectExp.Postion, "不存在索引");
                return(null);
            }
            else
            {
                RetType = ExProperty.Property.PropertyType;
            }
            return(this);
        }