Exemplo n.º 1
0
        private Exp ParseItemExp(Exp exp)
        {
            //exp.SetContextExp(expContext);
            Exp subExp = exp.Analy();

            return(subExp);
        }
Exemplo n.º 2
0
        private void ParseNamePart(Exp subExp)
        {
            Exp exp2 = subExp.Analy();

            newExpList.Add(exp2);
            tape.MoveNext();
        }
Exemplo n.º 3
0
 protected Exp AnalyExp(Exp exp)
 {
     exp.Stmt = this;
     if (_AnalyExpContext == null)
     {
         _AnalyExpContext = new AnalyExpContext(this.AnalyStmtContext);
     }
     return(exp.Analy(_AnalyExpContext));
 }
Exemplo n.º 4
0
        public Exp Parse(ExpRaw rawExp, ContextExp expContext)
        {
            ExpContext = expContext;
            List <LexToken> tokens = Seg(rawExp.RawTokens);
            ExpParser       parser = new ExpParser();

            Exp exp  = parser.Parse(tokens, ExpContext);
            Exp exp2 = exp.Analy();

            return(exp2);
        }
Exemplo n.º 5
0
        public void AnalyBody(ClassContext classContext)
        {
            if (ValueExp != null)
            {
                MethodContext methodContext = new MethodContext(ClassContext, PropertyName);
                var           symbols       = ClassContext.Symbols;

                AnalyStmtContext stmtContext = new AnalyStmtContext(methodContext, PropertyName);
                AnalyExpContext  expContext  = new AnalyExpContext(stmtContext);
                ValueExp = ValueExp.Analy(expContext);

                if (ValueExp == null)
                {
                    return;
                }
                if (!ReflectionUtil.IsExtends(ValueExp.RetType, PropertyType))
                {
                    error("属性值的类型不正确");
                }
            }
            else
            {
                if (PropertyType.IsValueType)
                {
                    newCode = 4;
                }
                else
                {
                    List <TKTProcArg> args = new List <TKTProcArg>();
                    ProcDesc = new TKTProcDesc();
                    ProcDesc.Add(PropertyGcl.ShowName);
                    ProcDesc.Add(args);
                    TKTProcDesc newProcDesc = searchNewProc(classContext, ProcDesc);
                    if (newProcDesc != null)
                    {
                        newCode = 3;
                    }
                    else
                    {
                        ConstructorDesc = new TKTConstructorDesc(args);
                        TKTConstructorDesc realDesc = PropertyGcl.SearchConstructor(ConstructorDesc);
                        if (realDesc != null)
                        {
                            ConstructorDesc.Constructor = realDesc.Constructor;
                            newCode = 2;
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
 private Exp Parse1(object data)
 {
     if (data is ExpProcNamePart)
     {
         ExpProcNamePart dataExp     = (ExpProcNamePart)data;
         LexToken        tok         = dataExp.PartNameToken;
         string          text        = tok.Text;
         var             ProcContext = this.ExpContext.ProcContext;
         if (ProcContext.IsThisMethodSingle(text))
         {
             ExpCallSingleThis pptExp = new ExpCallSingleThis(this.ExpContext, tok);
             //pptExp.SetContextExp(this.expContext);
             return(pptExp.Analy());
         }
         else if (ProcContext.IsSuperMethodSingle(text))
         {
             ExpCallSingleSuper pptExp = new ExpCallSingleSuper(this.ExpContext, tok);
             //pptExp.SetContextExp(this.expContext);
             return(pptExp.Analy());
         }
         else if (ProcContext.IsUseMethodSingle(text))
         {
             ExpCallSingleUse pptExp = new ExpCallSingleUse(this.ExpContext, tok);
             //pptExp.SetContextExp(this.expContext);
             return(pptExp.Analy());
         }
         else if (ProcContext.IsUsedProperty(text))
         {
             ExpUseProperty eupExp = new ExpUseProperty(this.ExpContext, tok);
             dataExp.CopyFieldsToExp(eupExp);
             Exp exp2 = eupExp.Analy();
             return(exp2);
         }
         else if (ProcContext.IsUsedField(text))
         {
             ExpUseField eufExp = new ExpUseField(this.ExpContext, tok);
             dataExp.CopyFieldsToExp(eufExp);
             Exp exp2 = eufExp.Analy();
             return(exp2);
         }
         else if (ProcContext.IsUsedEnumItem(text))
         {
             ExpUseEnumItem eueExp = new ExpUseEnumItem(this.ExpContext, tok);
             dataExp.CopyFieldsToExp(eueExp);
             Exp exp2 = eueExp.Analy();
             return(exp2);
         }
         else if (IsAssignTo)
         {
             ExpLocalVar localVarExp = new ExpLocalVar(this.ExpContext, tok);
             localVarExp.IsAssignTo = true;
             dataExp.CopyFieldsToExp(localVarExp);
             Exp exp2 = localVarExp.Analy();
             return(exp2);
         }
         else
         {
             /* 在赋值表达式中会处理ExpErrorToken */
             ExpErrorToken errorExp = new ExpErrorToken(dataExp.ExpContext, tok);
             return(errorExp.Analy());
         }
     }
     else if (data is Exp)
     {
         Exp exp2 = (Exp)data;
         //exp2.SetContextExp(this.expContext);
         return(exp2.Analy());
     }
     else
     {
         return(null);
     }
 }