コード例 #1
0
        private static bool DoAsterisk(ref StateContext context)
        {
            if (context.IsWhitespace())
            {
                return(true);
            }

            switch (context.Character)
            {
            case ',':
                context.Include("*");
                context.State = State.None;
                return(true);

            case '}':
                context.Include("*");
                context.Pop();
                context.State = State.None;
                return(true);

            default:
                context.OnError($"SyntaxError: Contains the illegal character '{context.Character}' in the data schema.");
                return(false);
            }
        }
コード例 #2
0
        private static bool DoNone(ref StateContext context)
        {
            if (context.IsWhitespace())
            {
                return(true);
            }

            switch (context.Character)
            {
            case '*':
                context.State = State.Asterisk;
                return(true);

            case '!':
                context.State = State.Exclude;
                return(true);

            case '}':
                return(context.Pop() != null);

            case ',':
                return(true);

            default:
                if (context.IsLetterOrUnderscore())
                {
                    context.Accept();
                    context.State = State.Include;
                    return(true);
                }

                context.OnError($"SyntaxError: Contains the illegal character '{context.Character}' in the data schema.");
                return(false);
            }
        }
コード例 #3
0
        private static bool DoInclude(ref StateContext context)
        {
            switch (context.Character)
            {
            case ',':
                context.Include();
                context.State = State.None;
                break;

            case ':':
                context.Include();
                context.State = State.PagingCount;
                break;

            case '(':
                context.Include();
                context.State = State.SortingField;
                break;

            case '{':
                context.Include();
                context.Push();
                context.State = State.None;
                break;

            case '}':
                context.Include();
                context.Pop();
                context.State = State.None;
                break;

            default:
                if (context.IsLetterOrDigitOrUnderscore())
                {
                    //判断标识中间是否含有空白字符
                    if (context.Flags.HasWhitespace())
                    {
                        context.OnError("SyntaxError: The identifier of the data schema contains whitespace characters.");
                        return(false);
                    }

                    context.Accept();
                }
                else if (!context.IsWhitespace())
                {
                    context.OnError($"SyntaxError: The identifier of the data schema contains '{context.Character}' illegal character.");
                    return(false);
                }

                break;
            }

            //重置是否含有空格的标记
            context.Flags.HasWhitespace(context.IsWhitespace());

            return(true);
        }
コード例 #4
0
        private static bool DoExclude(ref StateContext context)
        {
            switch (context.Character)
            {
            case ',':
                context.Exclude();
                context.State = State.None;
                break;

            case '}':
                context.Exclude();
                context.Pop();
                context.State = State.None;
                break;

            default:
                if (context.IsLetterOrDigitOrUnderscore())
                {
                    //如果首字符是数字,则激发错误
                    if (char.IsDigit(context.Character) && !context.HasBuffer())
                    {
                        context.OnError("SyntaxError: The identifier of the data schema cannot start with a digit.");
                        return(false);
                    }

                    //判断标识中间是否含有空白字符
                    if (context.Flags.HasWhitespace())
                    {
                        context.OnError("SyntaxError: The identifier of the data schema contains whitespace characters.");
                        return(false);
                    }

                    context.Accept();
                }
                else if (!context.IsWhitespace())
                {
                    context.OnError($"SyntaxError: The identifier of the data schema contains '{context.Character}' illegal character.");
                    return(false);
                }

                break;
            }

            //重置是否含有空格的标记
            context.Flags.HasWhitespace(context.IsWhitespace());

            return(true);
        }
コード例 #5
0
        private static bool DoExclude(ref StateContext context)
        {
            switch (context.Character)
            {
            case ',':
                context.Exclude();
                context.State = State.None;
                break;

            case '}':
                context.Exclude();
                context.Pop();
                context.State = State.None;
                break;

            default:
                if (context.IsLetterOrDigitOrUnderscore())
                {
                    //如果首字符是数字,则激发错误
                    if (char.IsDigit(context.Character) && !context.HasBuffer())
                    {
                        context.OnError("");
                        return(false);
                    }

                    //判断标识中间是否含有空白字符
                    if (context.Flags.HasWhitespace())
                    {
                        context.OnError("");
                        return(false);
                    }

                    context.Accept();
                }
                else if (!context.IsWhitespace())
                {
                    context.OnError("");
                    return(false);
                }

                break;
            }

            //重置是否含有空格的标记
            context.Flags.HasWhitespace(context.IsWhitespace());

            return(true);
        }
コード例 #6
0
        private static bool DoNone(ref StateContext context)
        {
            if (context.IsWhitespace())
            {
                return(true);
            }

            switch (context.Character)
            {
            case '*':
                //context.Accept();
                context.State = State.Asterisk;
                return(true);

            case '!':
                context.State = State.Exclude;
                return(true);

            case '}':
                return(context.Pop() != null);

            case ',':
                return(true);

            default:
                if (context.IsLetterOrUnderscore())
                {
                    context.Accept();
                    context.State = State.Include;
                    return(true);
                }

                context.OnError("");
                return(false);
            }
        }