示例#1
0
        public override void Set_作用域(作用域 作用域)
        {
            base.Set_作用域(作用域);

            作用域 小括号作用域 = new 作用域();

            for (int i = 0; i < this.小括号表达式s.Length; i++)
            {
                表达式 express = this.小括号表达式s[i];

                if (express == null)
                {
                    continue;
                }

                变量声明和初始化 变量声明 = express as 变量声明和初始化;

                if (变量声明 != null)
                {
                    小括号作用域.Add_变量定义(变量声明, 变量声明.chars);
                }

                express.Set_作用域(小括号作用域);
            }

            小括号作用域.Set_作用域(作用域);
            this.子句.Set_作用域(小括号作用域);
        }
示例#2
0
        private static 作用域 Parse_形参列表(char[] chars, int 左小括号位置, int 右小括号位置)
        {
            作用域 形参列表 = new 作用域();

            StrSpan span = StrUtil.Trim(chars, 左小括号位置 + 1, 右小括号位置 - 1, Parser._whiteSpaces);

            if (span.isEmpty)
            {
                return(形参列表);
            }

            List <StrSpan> list = Parser.在_单引号双引号_以外_Split(chars, span.iLeft, span.iRight, ',');

            StrSpan span形参;

            for (int i = 0; i < list.Count; i++)
            {
                span形参 = list[i];

                形参 形参 = Parse_形参(chars, span形参);

                形参列表.Add_变量定义(形参, chars);
                //if (形参列表.dic变量声明.ContainsKey(形参.name))
                //    throw new 语法错误_Exception("参数名 \"" + 形参.name + "\" 重复 。", chars, 形参.变量名位置);

                //形参列表.dic变量声明.Add(形参.name, 形参);
            }

            return(形参列表);
        }
        public override void Set_作用域(作用域 作用域)
        {
            throw new NotImplementedException();
            //base.Set_作用域(作用域);

            //this.变量声明.Set_作用域(作用域);
        }
示例#4
0
        public override void Set_作用域(作用域 作用域)
        {
            base.Set_作用域(作用域);

            this.左边的表达式.Set_作用域(作用域);

            this.右边的表达式.Set_作用域(作用域);
        }
示例#5
0
文件: if_语句.cs 项目: qipa/InnerC
        public override void Set_作用域(作用域 作用域)
        {
            base.Set_作用域(作用域);

            this.if_判断.Set_作用域(作用域);

            this.子句.Set_父作用域(作用域);
        }
示例#6
0
        public override void Set_作用域(作用域 作用域)
        {
            base.Set_作用域(作用域);

            if (this.返回值 != null)
            {
                this.返回值.Set_作用域(作用域);
            }
        }
示例#7
0
        public override void Set_作用域(作用域 作用域)
        {
            base.Set_作用域(作用域);

            //foreach(表达式 维度_Length in this.list_数组维度_Length)
            //{
            //    维度_Length.Set_作用域(作用域);
            //}
        }
示例#8
0
        public override void Set_作用域(作用域 作用域)
        {
            base.Set_作用域(作用域);

            this.while_条件.Set_作用域(作用域);

            this.子句.Set_父作用域(作用域);

            作用域.Set_所在的_while_for_语句(this);
        }
        public override void Set_作用域(作用域 作用域)
        {
            base.Set_作用域(作用域);

            this.左边的表达式.Set_作用域(作用域);

            foreach (表达式 标 in this.list下标)
            {
                标.Set_作用域(作用域);
            }
        }
        public override void Set_作用域(作用域 作用域)
        {
            base.Set_作用域(作用域);

            this.类型.Set_作用域(作用域);

            if (this.初始值 != null)
            {
                this.初始值.Set_作用域(作用域);
            }
            //this.作用域.Add_变量定义(this, this.chars);
        }
        public override void Set_作用域(作用域 作用域)
        {
            base.Set_作用域(作用域);

            表达式 实参;

            for (int i = 0; i < list实参.Count; i++)
            {
                实参 = list实参[i];

                实参.Set_作用域(作用域);
            }
        }
示例#12
0
        public static 结构体 Parse(char[] chars, 第一层_代码块 代码块)
        {
            StrSpan span = StrUtil.Trim(chars, 代码块.iLeft, 代码块.iRight, Parser._whiteSpaces);

            int struct关键字位置;

            int j = 代码块.大括号块.iLeft - 1;

            while (true)
            {
                struct关键字位置 = StrUtil.FindBackward(chars, span.iLeft, j, "struct");

                if (struct关键字位置 == -1)
                {
                    return(null);
                }

                if (StrUtil.IsOneOf(chars[struct关键字位置 + 6], Parser._whiteSpaces))
                {
                    break;
                }

                j = struct关键字位置 - 1;
            }

            StrSpan span结构体名 = StrUtil.Trim(chars, struct关键字位置 + 6, 代码块.大括号块.iLeft - 1, Parser._whiteSpaces);

            if (span结构体名.isEmpty)
            {
                throw new 语法错误_Exception("缺少 结构体名 。", chars, struct关键字位置 + 6);
            }

            string 结构体名 = new string(chars, span结构体名.iLeft, span结构体名.iRight - span结构体名.iLeft + 1);

            if (!Util.Check_是否_下划线字母数字_且以_下划线字母_开头(结构体名))
            {
                throw new 语法错误_Exception("无效的 结构体名 \"" + 结构体名 + "\",结构体名 应由 下划线字母数字 组成且以 下划线或字母 开头 。", chars, span结构体名.iLeft);
            }

            if (Util.Check_是否关键字(结构体名))
            {
                throw new 语法错误_Exception("无效的 结构体名 \"" + 结构体名 + "\",结构体名 不能和 关键字 相同 。", chars, span结构体名.iLeft);
            }

            //Dictionary<string, 字段声明> dic字段声明 = Parse_字段声明(chars, 代码块.大括号块);
            作用域 字段声明 = Parse_字段声明(chars, 代码块.大括号块);

            return(new 结构体(结构体名, 字段声明, span结构体名.iLeft));
            //return new 结构体(结构体名, dic字段声明, span结构体名.iLeft);
        }
示例#13
0
文件: if_语句.cs 项目: qipa/InnerC
        public override void Set_作用域(作用域 作用域)
        {
            base.Set_作用域(作用域);

            if_分句 if_分句;

            for (int i = 0; i < this.if_分句_和_else_if_分句_List.Count; i++)
            {
                if_分句 = this.if_分句_和_else_if_分句_List[i];

                if_分句.Set_作用域(作用域);
            }

            if (this.最后结尾的_else_分句 != null)
            {
                this.最后结尾的_else_分句.Set_父作用域(作用域);
            }
        }
示例#14
0
        //private static Dictionary<string, 字段声明> Parse_字段声明(char[] chars, StrSpan 大括号块)
        private static 作用域 Parse_字段声明(char[] chars, StrSpan 大括号块)
        {
            //Dictionary<string, 字段声明> dic字段声明 = new Dictionary<string, 字段声明>();
            作用域 字段声明 = new 作用域();

            StrSpan span = StrUtil.Trim(chars, 大括号块.iLeft + 1, 大括号块.iRight - 1, Parser._whiteSpaces);

            //if (span.isEmpty)
            //    return dic字段声明;

            if (span.isEmpty)
            {
                return(字段声明);
            }

            List <StrSpan> list = Parser.在_单引号双引号_以外_Split(chars, span.iLeft, span.iRight, ',');

            StrSpan span字段;

            for (int i = 0; i < list.Count; i++)
            {
                span字段 = list[i];

                字段声明 字段 = Parse_字段(chars, span字段);

                //if (dic字段声明.ContainsKey(字段.name))
                if (字段声明.dic变量声明.ContainsKey(字段.name))
                {
                    throw new 语法错误_Exception("字段名 \"" + 字段.name + "\" 重复 。", chars, 字段.变量名位置);
                }

                //dic字段声明.Add(字段.name, 字段);
                字段声明.dic变量声明.Add(字段.name, 字段);
            }

            return(字段声明);
            //return dic字段声明;
        }
示例#15
0
        public override void Set_作用域(作用域 作用域)
        {
            base.Set_作用域(作用域);

            this.变量.Set_作用域(作用域);
        }
示例#16
0
        public static 函数 Parse(char[] chars, 第一层_代码块 代码块)
        {
            //int i;

            //int beginIndex = 上一个大括号块 == null ? 0 : 上一个大括号块.iRight + 1;
            //int endIndex = 大括号块.iLeft - 1;

            //i = Parser.从右向左寻找_分号_单引号_双引号(chars, beginIndex, endIndex);

            //if (i != -1)
            //    beginIndex = i + 1;

            //StrSpan span = new StrSpan(beginIndex, 大括号块.iRight);

            //int args_beginIndex;
            //int args_endIndex;

            StrSpan span = StrUtil.Trim(chars, 代码块.iLeft, 代码块.iRight, Parser._whiteSpaces);

            int 右小括号位置 = StrUtil.FindBackwardUntilNot(chars, span.iLeft, 代码块.大括号块.iLeft - 1, Parser._whiteSpaces);

            if (右小括号位置 == -1)
            {
                throw new 语法错误_Exception("函数定义错误: 函数头为空 。", chars, 代码块.大括号块.iLeft - 1);
            }

            if (chars[右小括号位置] != ')')
            {
                throw new 语法错误_Exception("函数定义错误: 函数头 缺少 右小括号 \"(\" 。", chars, 右小括号位置);
            }

            //int 右小括号位置 = StrUtil.FindBackward(chars, 代码块.iLeft, 代码块.大括号块.iLeft - 1, ')');

            //if (右小括号位置 == -1)
            //    throw new InnerCException("函数定义错误: 函数头 缺少 右小括号 \"(\" 。", chars, beginIndex - 1);

            //args_endIndex = i - 1;
            //beginIndex = i - 1;

            int 左小括号位置 = StrUtil.FindBackward(chars, span.iLeft, 右小括号位置 - 1, '(');

            if (左小括号位置 == -1)
            {
                throw new 语法错误_Exception("函数定义错误: 函数头 缺少 左小括号 \"(\" 。", chars, span.iLeft);
            }

            int 函数名结束位置 = StrUtil.FindBackwardUntilNot(chars, span.iLeft, 左小括号位置 - 1, Parser._whiteSpaces);

            if (!Util.Check_是否_下划线字母数字(chars[函数名结束位置]))
            {
                throw new 语法错误_Exception("函数定义错误: 缺少 函数名 。", chars, 函数名结束位置);
            }

            int 函数名开始位置的前一个位置 = Parser.向左寻找_不是_下划线字母数字_的字符(chars, span.iLeft, 函数名结束位置);



            int 函数名开始位置;

            if (函数名开始位置的前一个位置 == -1)
            {
                函数名开始位置 = span.iLeft;
            }
            else
            {
                函数名开始位置 = 函数名开始位置的前一个位置 + 1;
            };

            char c = chars[函数名开始位置];

            string 函数名 = new string(chars, 函数名开始位置, 函数名结束位置 - 函数名开始位置 + 1);

            if (!(c == '_' || StrUtil.IsLetter(c)))
            {
                throw new 语法错误_Exception("无效的 函数名 \"" + 函数名 + "\",函数名 应由 下划线字母数字 组成且以 下划线或字母 开头 。", chars, 函数名开始位置);
            }

            if (Util.Check_是否关键字(函数名))
            {
                throw new 语法错误_Exception("无效的 函数名 \"" + 函数名 + "\",函数名 不能和 关键字 相同 。", chars, 函数名开始位置);
            }

            //变量声明 返回类型;

            //if (函数名开始位置 == span.iLeft)
            //{
            //    return Parse(chars, -1, -1, span.iLeft, 函数名结束位置, 左小括号位置, 右小括号位置, 代码块.大括号块.iLeft, 代码块.大括号块.iRight);
            //}


            //c = chars[函数名开始位置 - 1];

            //if (!StrUtil.IsOneOf(c, Parser._whiteSpaces和星号))
            //    throw new InnerCException("未结束的语句,可能缺少分号 \";\" 。", chars, 函数名开始位置 - 1);

            int 报错位置;

            类型 返回类型 = Parse_返回类型(chars, span.iLeft, 函数名开始位置 - 1, out 报错位置);

            if (报错位置 != -1)
            {
                throw new 语法错误_Exception("未结束的语句,可能缺少分号 \";\" 。", chars, 报错位置);
            }


            作用域  形参列表 = Parse_形参列表(chars, 左小括号位置, 右小括号位置);
            块作用域 函数体  = Parse_函数体(chars, 代码块.大括号块);



            return(new 函数(返回类型, 函数名, 形参列表, 函数体, 函数名开始位置));

            //int 空白和星号开始的位置的前一个位置 = StrUtil.FindBackwardUntilNot(chars, span.iLeft, 函数名开始位置 - 1, Parser._whiteSpaces和星号);

            //int 空白和星号开始位置;

            //if (空白和星号开始的位置的前一个位置 == -1)
            //{
            //    K
            //}


            //args_beginIndex = i + 1;
            //beginIndex = i - 1;

            //StrSpan 函数名和返回值 = StrUtil.Trim(chars, beginIndex, endIndex, Parser._whiteSpaces);

            //if (函数名和返回值.isEmpty)
            //    throw new InnerCException("函数定义错误: 缺少 函数名 。", chars, beginIndex - 1);

            //StrSpan[] spans = Parser.从右向左寻找第一个空白字符以此Split将得到的两个字符串Trim返回(chars, 函数名和返回值.iLeft, 函数名和返回值.iRight);

            //StrSpan 参数列表 = new StrSpan(args_beginIndex, args_endIndex);
            //StrSpan 函数体 = StrUtil.Trim(chars, 大括号块.iLeft + 1, 大括号块.iRight - 1, Parser._whiteSpaces);

            //return new 函数块(span, spans[0], spans[1], 参数列表, 函数体);
        }