当前位置: 首页>>代码示例>>C#>>正文


C# ParserContext.Pop方法代码示例

本文整理汇总了C#中ParserContext.Pop方法的典型用法代码示例。如果您正苦于以下问题:C# ParserContext.Pop方法的具体用法?C# ParserContext.Pop怎么用?C# ParserContext.Pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParserContext的用法示例。


在下文中一共展示了ParserContext.Pop方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

        public static Terminal_StringValue Parse(
            ParserContext context, 
            string regex)
        {
            context.Push("StringValue", regex);

            bool parsed = true;

            Terminal_StringValue stringValue = null;
            try
            {
                string value = context.text.Substring(context.index, regex.Length);

                if ((parsed = value.ToLower().Equals(regex.ToLower())))
                {
                    context.index += regex.Length;
                    stringValue = new Terminal_StringValue(value, null);
                }
            }
            catch (ArgumentOutOfRangeException) {parsed = false;}

            context.Pop("StringValue", parsed);

            return stringValue;
        }
开发者ID:p-kaczynski,项目名称:GeolocationUri,代码行数:25,代码来源:Terminal_StringValue.cs

示例2: Parse

        public static Terminal_NumericValue Parse(
            ParserContext context, 
            string spelling, 
            string regex, 
            int length)
        {
            context.Push("NumericValue", spelling + "," + regex);

            bool parsed = true;

            Terminal_NumericValue numericValue = null;
            try
            {
                string value = context.text.Substring(context.index, length);

                if ((parsed = Regex.IsMatch(value, regex)))
                {
                    context.index += length;
                    numericValue = new Terminal_NumericValue(value, null);
                }
            }
            catch (ArgumentOutOfRangeException) {parsed = false;}

            context.Pop("NumericValue", parsed);

            return numericValue;
        }
开发者ID:p-kaczynski,项目名称:GeolocationUri,代码行数:27,代码来源:Terminal_NumericValue.cs

示例3: Parse

        public static Rule_uncp Parse(ParserContext context)
        {
            context.Push("uncp");

            Rule rule;
            bool parsed = true;
            ParserAlternative b;
            int s0 = context.index;
            ParserAlternative a0 = new ParserAlternative(s0);

            List<ParserAlternative> as1 = new List<ParserAlternative>();
            parsed = false;
            {
                int s1 = context.index;
                ParserAlternative a1 = new ParserAlternative(s1);
                parsed = true;
                if (parsed)
                {
                    bool f1 = true;
                    int c1 = 0;
                    for (int i1 = 0; i1 < 1 && f1; i1++)
                    {
                        rule = Terminal_StringValue.Parse(context, ";u=");
                        if ((f1 = rule != null))
                        {
                            a1.Add(rule, context.index);
                            c1++;
                        }
                    }
                    parsed = c1 == 1;
                }
                if (parsed)
                {
                    bool f1 = true;
                    int c1 = 0;
                    for (int i1 = 0; i1 < 1 && f1; i1++)
                    {
                        rule = Rule_uval.Parse(context);
                        if ((f1 = rule != null))
                        {
                            a1.Add(rule, context.index);
                            c1++;
                        }
                    }
                    parsed = c1 == 1;
                }
                if (parsed)
                {
                    as1.Add(a1);
                }
                context.index = s1;
            }

            b = ParserAlternative.GetBest(as1);

            parsed = b != null;

            if (parsed)
            {
                a0.Add(b.rules, b.end);
                context.index = b.end;
            }

            rule = null;
            if (parsed)
            {
                rule = new Rule_uncp(context.text.Substring(a0.start, a0.end - a0.start), a0.rules);
            }
            else
            {
                context.index = s0;
            }

            context.Pop("uncp", parsed);

            return (Rule_uncp)rule;
        }
开发者ID:p-kaczynski,项目名称:GeolocationUri,代码行数:77,代码来源:Rule_uncp.cs

示例4: Parse


//.........这里部分代码省略.........
                    for (int i1 = 0; i1 < 1 && f1; i1++)
                    {
                        int g1 = context.index;
                        List<ParserAlternative> as2 = new List<ParserAlternative>();
                        parsed = false;
                        {
                            int s2 = context.index;
                            ParserAlternative a2 = new ParserAlternative(s2);
                            parsed = true;
                            if (parsed)
                            {
                                bool f2 = true;
                                int c2 = 0;
                                for (int i2 = 0; i2 < 1 && f2; i2++)
                                {
                                    rule = Terminal_StringValue.Parse(context, ".");
                                    if ((f2 = rule != null))
                                    {
                                        a2.Add(rule, context.index);
                                        c2++;
                                    }
                                }
                                parsed = c2 == 1;
                            }
                            if (parsed)
                            {
                                bool f2 = true;
                                int c2 = 0;
                                for (int i2 = 0; i2 < 1 && f2; i2++)
                                {
                                    rule = Rule_DIGIT.Parse(context);
                                    if ((f2 = rule != null))
                                    {
                                        a2.Add(rule, context.index);
                                        c2++;
                                    }
                                }
                                while (f2)
                                {
                                    rule = Rule_DIGIT.Parse(context);
                                    if ((f2 = rule != null))
                                    {
                                        a2.Add(rule, context.index);
                                        c2++;
                                    }
                                }
                                parsed = c2 >= 1;
                            }
                            if (parsed)
                            {
                                as2.Add(a2);
                            }
                            context.index = s2;
                        }

                        b = ParserAlternative.GetBest(as2);

                        parsed = b != null;

                        if (parsed)
                        {
                            a1.Add(b.rules, b.end);
                            context.index = b.end;
                        }
                        f1 = context.index > g1;
                        if (parsed) c1++;
                    }
                    parsed = true;
                }
                if (parsed)
                {
                    as1.Add(a1);
                }
                context.index = s1;
            }

            b = ParserAlternative.GetBest(as1);

            parsed = b != null;

            if (parsed)
            {
                a0.Add(b.rules, b.end);
                context.index = b.end;
            }

            rule = null;
            if (parsed)
            {
                rule = new Rule_pnum(context.text.Substring(a0.start, a0.end - a0.start), a0.rules);
            }
            else
            {
                context.index = s0;
            }

            context.Pop("pnum", parsed);

            return (Rule_pnum)rule;
        }
开发者ID:p-kaczynski,项目名称:GeolocationUri,代码行数:101,代码来源:Rule_pnum.cs

示例5: Parse

        public static Rule_ALPHA Parse(ParserContext context)
        {
            context.Push("ALPHA");

            Rule rule;
            bool parsed = true;
            ParserAlternative b;
            int s0 = context.index;
            ParserAlternative a0 = new ParserAlternative(s0);

            List<ParserAlternative> as1 = new List<ParserAlternative>();
            parsed = false;
            {
                int s1 = context.index;
                ParserAlternative a1 = new ParserAlternative(s1);
                parsed = true;
                if (parsed)
                {
                    bool f1 = true;
                    int c1 = 0;
                    for (int i1 = 0; i1 < 1 && f1; i1++)
                    {
                        rule = Terminal_NumericValue.Parse(context, "%x41-5A", "[\\x41-\\x5A]", 1);
                        if ((f1 = rule != null))
                        {
                            a1.Add(rule, context.index);
                            c1++;
                        }
                    }
                    parsed = c1 == 1;
                }
                if (parsed)
                {
                    as1.Add(a1);
                }
                context.index = s1;
            }
            {
                int s1 = context.index;
                ParserAlternative a1 = new ParserAlternative(s1);
                parsed = true;
                if (parsed)
                {
                    bool f1 = true;
                    int c1 = 0;
                    for (int i1 = 0; i1 < 1 && f1; i1++)
                    {
                        rule = Terminal_NumericValue.Parse(context, "%x61-7A", "[\\x61-\\x7A]", 1);
                        if ((f1 = rule != null))
                        {
                            a1.Add(rule, context.index);
                            c1++;
                        }
                    }
                    parsed = c1 == 1;
                }
                if (parsed)
                {
                    as1.Add(a1);
                }
                context.index = s1;
            }

            b = ParserAlternative.GetBest(as1);

            parsed = b != null;

            if (parsed)
            {
                a0.Add(b.rules, b.end);
                context.index = b.end;
            }

            rule = null;
            if (parsed)
            {
                rule = new Rule_ALPHA(context.text.Substring(a0.start, a0.end - a0.start), a0.rules);
            }
            else
            {
                context.index = s0;
            }

            context.Pop("ALPHA", parsed);

            return (Rule_ALPHA)rule;
        }
开发者ID:p-kaczynski,项目名称:GeolocationUri,代码行数:87,代码来源:Rule_ALPHA.cs


注:本文中的ParserContext.Pop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。