private static 表达式 Parse_变量(char[] chars, List <表达式段> list)
        {
            if (list.Count > 1)
            {
                return(null);
            }

            表达式段 段 = list[0];

            if (段.type != 表达式段_Type.普通段)
            {
                return(null);
            }

            if (!Util.Check_是否_下划线字母数字_且以_下划线字母_开头(chars, 段.iLeft, 段.iRight))
            {
                return(null);
            }

            string name = new string(chars, 段.iLeft, 段.iRight - 段.iLeft + 1);

            变量 变量 = new 变量(name, chars, 段.iLeft);

            //变量.参考位置_iLeft = 段.iLeft;

            return(变量);
        }
        private static 表达式 Parse_函数调用(char[] chars, List <表达式段> list)
        {
            if (list.Count < 2)
            {
                return(null);
            }

            表达式段 段 = list[list.Count - 1];

            if (段.type != 表达式段_Type.小括号段)
            {
                return(null);
            }

            表达式 左边的表达式 = Parse(chars, list[0].iLeft, 段.iLeft - 1);

            变量 函数名 = 左边的表达式 as 变量;

            if (函数名 != null)
            {
                List <表达式> list实参 = Parse_实参(chars, 段);

                return(new 函数调用(函数名.name, list实参, chars, 段.iLeft));
            }

            指针取值 指针取值 = 左边的表达式 as 指针取值;

            if (指针取值 != null)
            {
                List <表达式> list实参 = Parse_实参(chars, 段);

                return(new 函数指针调用(指针取值, list实参, chars, 段.iLeft));
            }

            throw new 语法错误_Exception("函数调用 左边应该是 函数名 或者 指针取值 表达式 如 (* p) 。", chars, 段.iLeft);
            //if (指针取值 == null)
            //    return null;


            //return new 函数调用(左边的表达式, list实参);
        }
Пример #3
0
        private static 变量声明和初始化 Parse_普通变量声明(char[] chars, 表达式 表达式, int p, int l, int 星号Count)
        {
            变量 变量 = 表达式 as 变量;

            if (变量 != null)
            {
                return(new 变量声明和初始化(new 类型(new string(chars, p, l), 星号Count, null), 变量.name, null, 变量.参考位置_iLeft));
            }

            赋值 赋值 = 表达式 as 赋值;

            if (赋值 != null)
            {
                变量 = 赋值.左边的表达式 as 变量;

                if (变量 != null)
                {
                    return(new 变量声明和初始化(new 类型(new string(chars, p, l), 星号Count, null), 变量.name, 赋值.右边的表达式, 变量.参考位置_iLeft));
                }
            }

            return(null);
        }