示例#1
0
文件: Util.cs 项目: qipa/InnerC
        public static bool Check_float(char[] chars, int beginIndex, int endIndex)
        {
            char c;

            for (int i = beginIndex; i <= endIndex; i++)
            {
                c = chars[i];

                if (!(StrUtil.IsNumber(c) || c == '.'))
                {
                    return(false);
                }
            }

            c = chars[beginIndex];

            if (c == '.')
            {
                return(false);
            }

            c = chars[endIndex];

            if (c == '.')
            {
                return(false);
            }

            return(true);
        }
示例#2
0
文件: Util.cs 项目: qipa/InnerC
        public static bool Check_是否_下划线字母数字(char c)
        {
            if (c == '_' || StrUtil.IsLetter(c) || StrUtil.IsNumber(c))
            {
                return(true);
            }

            return(false);
        }
示例#3
0
        public static return_语句 Parse_return_语句(char[] chars, int beginIndex, int endIndex, out int 语句结束位置)
        {
            语句结束位置 = -1;

            StrSpan span = StrUtil.Trim(chars, beginIndex, endIndex, Parser._whiteSpaces);

            if (span.isEmpty)
            {
                return(null);
            }

            if (!Parser.开头一段_Equals(chars, span.iLeft, span.iRight, "return"))
            {
                return(null);
            }

            int return后的位置 = span.iLeft + 6;

            if (return后的位置 > span.iRight)
            {
                throw new InnerCException("未结束的 return 语句 。", chars, span.iLeft);
            }

            char c = chars[return后的位置];

            if (c == '_' || StrUtil.IsLetter(c) || StrUtil.IsNumber(c))
            {
                return(null);
            }

            语句结束位置 = Parser.Find_单引号对双引号对以外的内容(chars, return后的位置, span.iRight, ';');

            if (语句结束位置 == -1)
            {
                throw new InnerCException("未结束的 return 语句,缺少分号 \";\" 。", chars, span.iLeft);
            }

            StrSpan span返回值 = StrUtil.Trim(chars, return后的位置, 语句结束位置 - 1, Parser._whiteSpaces);

            表达式 返回值;

            if (span返回值.isEmpty)
            {
                返回值 = null;
            }
            else
            {
                返回值 = 表达式_Parser.Parse(chars, span返回值.iLeft, span返回值.iRight);
            }

            return(new return_语句(返回值));
        }
示例#4
0
        public static continue_语句 Parse_continue_语句(char[] chars, int beginIndex, int endIndex, out int 语句结束位置)
        {
            语句结束位置 = -1;

            StrSpan span = StrUtil.Trim(chars, beginIndex, endIndex, Parser._whiteSpaces);

            if (span.isEmpty)
            {
                return(null);
            }

            if (!Parser.开头一段_Equals(chars, span.iLeft, span.iRight, "continue"))
            {
                return(null);
            }

            int break后的位置 = span.iLeft + 5;

            if (break后的位置 > span.iRight)
            {
                throw new InnerCException("未结束的 continue 语句 。", chars, span.iLeft);
            }

            char c = chars[break后的位置];

            if (c == '_' || StrUtil.IsLetter(c) || StrUtil.IsNumber(c))
            {
                return(null);
            }

            int break后不是空白的位置 = StrUtil.FindForwardUntilNot(chars, break后的位置, span.iRight, Parser._whiteSpaces);

            if (break后不是空白的位置 == -1)
            {
                throw new InnerCException("未结束的 continue 语句,缺少分号 \";\" 。", chars, span.iLeft);
            }

            c = chars[break后不是空白的位置];

            if (c != ';')
            {
                throw new InnerCException("无效的 continue 语句,无效的字符 \"" + c + "\" 。", chars, break后不是空白的位置);
            }

            语句结束位置 = break后不是空白的位置;

            return(new continue_语句());
        }
示例#5
0
文件: Util.cs 项目: qipa/InnerC
        public static bool Check_int(char[] chars, int beginIndex, int endIndex)
        {
            char c;

            for (int i = beginIndex; i <= endIndex; i++)
            {
                c = chars[i];

                if (!StrUtil.IsNumber(c))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#6
0
文件: Util.cs 项目: qipa/InnerC
        public static bool Check_是否_下划线字母数字_且以_下划线字母_开头(char[] chars, int beginIndex, int endIndex)
        {
            char c = chars[beginIndex];

            if (c != '_' && !StrUtil.IsLetter(c))
            {
                return(false);
            }

            for (int i = beginIndex + 1; i <= endIndex; i++)
            {
                c = chars[i];

                if (c != '_' && !StrUtil.IsLetter(c) && !StrUtil.IsNumber(c))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#7
0
文件: Util.cs 项目: qipa/InnerC
        public static bool Check_是否_下划线字母数字_且以_下划线字母_开头(string str)
        {
            char c = str[0];

            if (c != '_' && !StrUtil.IsLetter(c))
            {
                return(false);
            }

            for (int i = 1; i < str.Length; i++)
            {
                c = str[i];

                if (c != '_' && !StrUtil.IsLetter(c) && !StrUtil.IsNumber(c))
                {
                    return(false);
                }
            }

            return(true);
        }