Example #1
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 #2
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 #3
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);
            }
        }