示例#1
0
        static public ParserAlternative GetBest(List <ParserAlternative> alternatives)
        {
            ParserAlternative best = null;

            foreach (ParserAlternative alternative in alternatives)
            {
                if (best == null || alternative.end > best.end)
                {
                    best = alternative;
                }
            }

            return(best);
        }
示例#2
0
        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;
        }
示例#3
0
        public static Rule_coord_b Parse(ParserContext context)
        {
            context.Push("coord-b");

            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 = Rule_num.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_coord_b(context.text.Substring(a0.start, a0.end - a0.start), a0.rules);
            }
            else
            {
                context.index = s0;
            }

            context.Pop("coord-b", parsed);

            return((Rule_coord_b)rule);
        }
示例#4
0
        public static Rule_pnum Parse(ParserContext context)
        {
            context.Push("pnum");

            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 = Rule_DIGIT.Parse(context);
                        if ((f1 = rule != null))
                        {
                            a1.Add(rule, context.index);
                            c1++;
                        }
                    }
                    while (f1)
                    {
                        rule = Rule_DIGIT.Parse(context);
                        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++)
                    {
                        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;
        }
示例#5
0
        public static Rule_DIGIT Parse(ParserContext context)
        {
            context.Push("DIGIT");

            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, "%x30-39", "[\\x30-\\x39]", 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_DIGIT(context.text.Substring(a0.start, a0.end - a0.start), a0.rules);
            }
            else
            {
                context.index = s0;
            }

            context.Pop("DIGIT", parsed);

            return((Rule_DIGIT)rule);
        }
示例#6
0
        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;
        }
示例#7
0
        public static Rule_p_unreserved Parse(ParserContext context)
        {
            context.Push("p-unreserved");

            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, "[");
                        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_StringValue.Parse(context, "]");
                        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_StringValue.Parse(context, ":");
                        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_StringValue.Parse(context, "&");
                        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_StringValue.Parse(context, "+");
                        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_StringValue.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_p_unreserved(context.text.Substring(a0.start, a0.end - a0.start), a0.rules);
            }
            else
            {
                context.index = s0;
            }

            context.Pop("p-unreserved", parsed);

            return((Rule_p_unreserved)rule);
        }
示例#8
0
        public static Rule_coordinates Parse(ParserContext context)
        {
            context.Push("coordinates");

            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 = Rule_coord_a.Parse(context);
                        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 = Terminal_StringValue.Parse(context, ",");
                        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_coord_b.Parse(context);
                        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++)
                    {
                        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_coord_c.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_coordinates(context.text.Substring(a0.start, a0.end - a0.start), a0.rules);
            }
            else
            {
                context.index = s0;
            }

            context.Pop("coordinates", parsed);

            return((Rule_coordinates)rule);
        }