Example #1
0
        public void AnalyClassMemberName()
        {
            var            tyedimNames = GetTypeDimWords();
            NameTypeParser parser      = new NameTypeParser(tyedimNames);

            if (PropertiesesSection != null)
            {
                PropertiesesSection.ClassContext = this.ClassContext;
                PropertiesesSection.FileContext  = this.ClassContext.FileContext;
                PropertiesesSection.AnalyName(parser);
            }

            foreach (SectionConstructor item in this.Constructors)
            {
                item.FileContext = this.FileContext;
                item.ProcContext = new ContextProc(this.ClassContext);
                item.ProcContext.IsConstructor = true;
                this.ClassContext.ProcManagerContext.ProcContextList.Add(item.ProcContext);
                item.AnalyName(parser);
            }

            foreach (SectionProc item in Proces)
            {
                item.FileContext = this.FileContext;
                item.ProcContext = new ContextProc(this.ClassContext);
                this.ClassContext.ProcManagerContext.ProcContextList.Add(item.ProcContext);
                item.AnalyName(parser);
            }
        }
Example #2
0
 public void AnalyName(NameTypeParser parser)
 {
     //NameTypeParser parser = new NameTypeParser(collection);
     NamePart.ProcContext = this.ProcContext;
     NamePart.AnalyName(parser);
     AnalyRet(parser);
 }
Example #3
0
        private bool AnlayNameBody(NameTypeParser parser)
        {
            bool isStatic = this.ProcContext.IsStatic;

            ProcDesc = new ZMethodDesc();
            //int argIndex = this.procContext.IsStatic ? 0 : 1;
            int argIndex = isStatic ? 0 : 1;

            for (int i = 0; i < NameTerms.Count; i++)
            {
                var term = NameTerms[i];
                if (term is Token)
                {
                    var    textterm = term as Token;
                    string namePart = textterm.GetText();
                    ProcDesc.Add(namePart);

                    WordInfo info = new WordInfo(namePart, WordKind.ProcNamePart, this);
                    this.ProcContext.ProcNameWordDictionary.Add(info);
                }
                else if (term is ProcArg)
                {
                    AnalyArg(term as ProcArg, parser, ProcDesc);
                }
            }
            return(true);
        }
Example #4
0
 public void AnalyName(NameTypeParser parser)
 {
     foreach (var item in Properties)
     {
         item.AnalyName(parser, this.ClassContext.PropertyContext, this.ClassContext);
     }
 }
Example #5
0
 public void AnalyName(NameTypeParser parser)
 {
     foreach (var arg in Args)
     {
         arg.ProcContext = this.ProcContext;
         arg.Analy(parser);
         ZMethodNormalArg procArg = new ZMethodNormalArg(arg.ArgName, arg.ArgZType);
         constructorDesc.Add(procArg);
     }
 }
Example #6
0
        public void AnalyArg(ProcArg argTree, NameTypeParser parser, ZMethodDesc desc)
        {
            //ProcArg argTree = term as ProcArg;
            argTree.ProcContext = this.ProcContext;
            argTree.Analy(parser);
            ZMethodNormalArg procArg = new ZMethodNormalArg(argTree.ArgName, argTree.ArgZType);

            desc.Add(procArg);
            //argIndex++;
        }
Example #7
0
 public bool AnalyNameType(NameTypeParser parser)
 {
     NameTypeParser.ParseResult result = parser.ParseVar(ArgToken);
     if (result != null)
     {
         ArgName  = result.VarName;
         ArgZType = result.ZType;
         return(true);
     }
     return(false);
 }
Example #8
0
 public void Analy(NameTypeParser parser)
 {
     ArgText = ArgToken.GetText();
     if (AnalyNameType(parser))
     {
         SymbolArg argSymbol = new SymbolArg(ArgName, ArgZType, this.ProcContext.CreateArgIndex(ArgName));
         this.ProcContext.Symbols.Add(argSymbol);
         WordInfo word = new WordInfo(ArgName, WordKind.ArgName, this);
         this.ProcContext.ProcVarWordDictionary.Add(word);
     }
 }
Example #9
0
        public override void Analy( )
        {
            var            tyedimNames = GetTypeWords();
            NameTypeParser parser      = new NameTypeParser(tyedimNames);

            NameTypeParser.ParseResult result = parser.ParseVar(ExceptionTypeVarToken);
            exTypeName = result.TypeName;
            exType     = result.ZType;
            exName     = result.VarName;
            var symbols = this.ProcContext.Symbols;
            //exTypeName = ExceptionTypeToken.GetText();
            //exType = ZTypeCache.GetByZName(exTypeName)[0];

            //if (exType == null)
            //{
            //    errorf(ExceptionTypeToken.Postion, "类型'{0}'不存在", exTypeName);
            //}
            //exName = ExceptionVarToken.GetText();
            var exSymbol2 = symbols.Get(exName);

            if (exSymbol2 == null)
            {
                exSymbol = new SymbolLocalVar(exName, exType);
                exSymbol.LoacalVarIndex = this.ProcContext.CreateLocalVarIndex(exName);
            }
            else
            {
                if (exSymbol2 is SymbolLocalVar)
                {
                    exSymbol = exSymbol2 as SymbolLocalVar;
                    if (exSymbol.SymbolZType != exType)
                    {
                        ErrorE(ExceptionTypeVarToken.Position, "变量'{0}'的类型与异常的类型不一致", exName);
                    }
                }
                else
                {
                    ErrorE(ExceptionTypeVarToken.Position, "变量名称'{0}'已经使用过", exName);
                }
            }
            symbols.Add(exSymbol);
            CatchBody.ProcContext = this.ProcContext;
            CatchBody.Analy();
        }
Example #10
0
 private bool AnalyRet(NameTypeParser parser)
 {
     if (RetToken == null)
     {
         RetZType = ZTypeManager.ZVOID;
     }
     else
     {
         NameTypeParser.ParseResult result = parser.ParseType(RetToken);
         if (result != null)
         {
             RetZType = result.ZType;
             return(true);
         }
         else
         {
             RetZType = ZTypeManager.ZVOID;
             errorf(RetToken.Position, "过程的结果'{0}'不存在", RetToken.GetText());
         }
     }
     this.ProcContext.RetZType = RetZType;
     return(false);
 }
Example #11
0
        public void AnalyName(NameTypeParser parser, PropertyContextCollection context, ContextClass classContext)
        {
            this.FileContext = classContext.FileContext;
            NameTypeParser.ParseResult result = parser.ParseVar(NameToken);
            if (result != null)
            {
                PropertyName  = result.TypeName;
                PropertyZType = result.ZType;

                if (context.Dict.ContainsKey(PropertyName))
                {
                    ErrorE(NameToken.Position, "属性'{0}'重复", PropertyName);
                }
                else
                {
                    WordInfo word = new WordInfo(PropertyName, WordKind.MemberName, this);
                    context.Dict.Add(word);
                }

                PropertySymbol = new SymbolDefProperty(PropertyName, PropertyZType, classContext.IsStaticClass);
                PropertySymbol.HasDefaultValue = true;
                classContext.MemberDictionary.Add(PropertySymbol);
            }
        }
Example #12
0
 public void AnalyName(NameTypeParser parser)
 {
     AnlayNameBody(parser);
     this.ProcContext.ProcDesc = ProcDesc;
 }