Exemple #1
0
 public void Analy(FnName fnName)
 {
     //this.symbols = parentTable;
     foreach (var ch in TextContent)
     {
         if (ch >= '0' && ch <= '9')
         {
             error("过程名称中不能出现数字");
             break;
         }
     }
 }
Exemple #2
0
        public bool Analy(FnName fn, int argIndex)
        {
            var symbols = fn.MethodAST.MethodContext.Symbols;

            if (ArgTypeToken != null && ArgNameToken != null)
            {
                ArgName = ArgNameToken.GetText();
                if (ArgTypeToken.IsKeyIdent("类型"))
                {
                    ArgType      = typeof(object);
                    IsGenericArg = true;
                }
                else
                {
                    IsGenericArg = false;
                    string     argTypeName = ArgTypeToken.GetText();
                    SymbolInfo symbol      = symbols.Get(argTypeName);
                    if (symbol != null)
                    {
                        SymbolDefClass defClass = symbol as SymbolDefClass;
                        if (defClass != null)
                        {
                            ArgType = defClass.ClassBuilder;
                        }
                    }

                    if (ArgType == null)
                    {
                        //var gcls = fn.MethodAST.MethodContext.ClassContext.ImportContext.SearchGCL(argTypeName);
                        //if (gcls.Length == 1)
                        //{
                        //    ArgType = gcls[0].ForType;
                        //}
                        var gcl = fn.MethodAST.MethodContext.ClassContext.SearchType(argTypeName); //
                        if (gcl != null)
                        {
                            ArgType = gcl.ForType;
                        }
                        if (ArgType == null)
                        {
                            error(string.Format("不存在或者不确定'{0}'类型", argTypeName));
                            return(false);
                        }
                    }
                }
                if (ArgType != null)
                {
                    if (symbols.Contains(ArgName))
                    {
                        errorf("'{0}'已经存在相同的名称", ArgName);
                        return(false);
                    }
                    else
                    {
                        SymbolArg argSymbol = new SymbolArg(ArgName, ArgType, argIndex, IsGenericArg);
                        symbols.AddSafe(argSymbol);
                    }
                }
            }
            else
            {
                error("参数不正确");
                return(false);
            }
            return(true);
        }