Exemplo n.º 1
0
 public Object Visit(Rule_h16 rule)
 {
     if (!terminal)
     {
         System.Console.WriteLine();
     }
     Console.Write("<h16>");
     terminal = false;
     VisitRules(rule.rules);
     if (!terminal)
     {
         System.Console.WriteLine();
     }
     Console.Write("</h16>");
     terminal = false;
     return(null);
 }
Exemplo n.º 2
0
    public static Rule_ls32 Parse(ParserContext context)
    {
        context.Push("ls32");

        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++)
                {
                    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 = Rule_h16.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 = 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_h16.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 = 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 = Rule_IPv4address.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_ls32(context.text.Substring(a0.start, a0.end - a0.start), a0.rules);
        }
        else
        {
            context.index = s0;
        }

        context.Pop("ls32", parsed);

        return((Rule_ls32)rule);
    }
Exemplo n.º 3
0
 public Object Visit(Rule_h16 rule)
 {
     return(VisitRules(rule.rules));
 }
Exemplo n.º 4
0
    static private Rule Parse(String rulename, String text, bool trace)
    {
        if (rulename == null)
        {
            throw new ArgumentNullException("null rulename");
        }
        if (text == null)
        {
            throw new ArgumentException("null string");
        }

        ParserContext context = new ParserContext(text, trace);

        Rule rule = null;

        if (rulename.ToLower().Equals("did".ToLower()))
        {
            rule = Rule_did.Parse(context);
        }
        else if (rulename.ToLower().Equals("did-method".ToLower()))
        {
            rule = Rule_did_method.Parse(context);
        }
        else if (rulename.ToLower().Equals("did-root".ToLower()))
        {
            rule = Rule_did_root.Parse(context);
        }
        else if (rulename.ToLower().Equals("method".ToLower()))
        {
            rule = Rule_method.Parse(context);
        }
        else if (rulename.ToLower().Equals("methodchar".ToLower()))
        {
            rule = Rule_methodchar.Parse(context);
        }
        else if (rulename.ToLower().Equals("method-specific-idstring".ToLower()))
        {
            rule = Rule_method_specific_idstring.Parse(context);
        }
        else if (rulename.ToLower().Equals("idstring".ToLower()))
        {
            rule = Rule_idstring.Parse(context);
        }
        else if (rulename.ToLower().Equals("idchar".ToLower()))
        {
            rule = Rule_idchar.Parse(context);
        }
        else if (rulename.ToLower().Equals("did-uri".ToLower()))
        {
            rule = Rule_did_uri.Parse(context);
        }
        else if (rulename.ToLower().Equals("did-optional-transform".ToLower()))
        {
            rule = Rule_did_optional_transform.Parse(context);
        }
        else if (rulename.ToLower().Equals("did-method-transform".ToLower()))
        {
            rule = Rule_did_method_transform.Parse(context);
        }
        else if (rulename.ToLower().Equals("did-root-transform".ToLower()))
        {
            rule = Rule_did_root_transform.Parse(context);
        }
        else if (rulename.ToLower().Equals("transform".ToLower()))
        {
            rule = Rule_transform.Parse(context);
        }
        else if (rulename.ToLower().Equals("transformer".ToLower()))
        {
            rule = Rule_transformer.Parse(context);
        }
        else if (rulename.ToLower().Equals("transformer-namedvalue".ToLower()))
        {
            rule = Rule_transformer_namedvalue.Parse(context);
        }
        else if (rulename.ToLower().Equals("transformer-option".ToLower()))
        {
            rule = Rule_transformer_option.Parse(context);
        }
        else if (rulename.ToLower().Equals("transformer-value".ToLower()))
        {
            rule = Rule_transformer_value.Parse(context);
        }
        else if (rulename.ToLower().Equals("transformer-char".ToLower()))
        {
            rule = Rule_transformer_char.Parse(context);
        }
        else if (rulename.ToLower().Equals("TRANSFORM".ToLower()))
        {
            rule = Rule_TRANSFORM.Parse(context);
        }
        else if (rulename.ToLower().Equals("generic-option".ToLower()))
        {
            rule = Rule_generic_option.Parse(context);
        }
        else if (rulename.ToLower().Equals("transformer-options".ToLower()))
        {
            rule = Rule_transformer_options.Parse(context);
        }
        else if (rulename.ToLower().Equals("URI".ToLower()))
        {
            rule = Rule_URI.Parse(context);
        }
        else if (rulename.ToLower().Equals("hier-part".ToLower()))
        {
            rule = Rule_hier_part.Parse(context);
        }
        else if (rulename.ToLower().Equals("scheme".ToLower()))
        {
            rule = Rule_scheme.Parse(context);
        }
        else if (rulename.ToLower().Equals("authority".ToLower()))
        {
            rule = Rule_authority.Parse(context);
        }
        else if (rulename.ToLower().Equals("userinfo".ToLower()))
        {
            rule = Rule_userinfo.Parse(context);
        }
        else if (rulename.ToLower().Equals("host".ToLower()))
        {
            rule = Rule_host.Parse(context);
        }
        else if (rulename.ToLower().Equals("port".ToLower()))
        {
            rule = Rule_port.Parse(context);
        }
        else if (rulename.ToLower().Equals("IP-literal".ToLower()))
        {
            rule = Rule_IP_literal.Parse(context);
        }
        else if (rulename.ToLower().Equals("IPvFuture".ToLower()))
        {
            rule = Rule_IPvFuture.Parse(context);
        }
        else if (rulename.ToLower().Equals("IPv6address".ToLower()))
        {
            rule = Rule_IPv6address.Parse(context);
        }
        else if (rulename.ToLower().Equals("h16".ToLower()))
        {
            rule = Rule_h16.Parse(context);
        }
        else if (rulename.ToLower().Equals("ls32".ToLower()))
        {
            rule = Rule_ls32.Parse(context);
        }
        else if (rulename.ToLower().Equals("IPv4address".ToLower()))
        {
            rule = Rule_IPv4address.Parse(context);
        }
        else if (rulename.ToLower().Equals("dec-octet".ToLower()))
        {
            rule = Rule_dec_octet.Parse(context);
        }
        else if (rulename.ToLower().Equals("reg-name".ToLower()))
        {
            rule = Rule_reg_name.Parse(context);
        }
        else if (rulename.ToLower().Equals("path-abempty".ToLower()))
        {
            rule = Rule_path_abempty.Parse(context);
        }
        else if (rulename.ToLower().Equals("path-absolute".ToLower()))
        {
            rule = Rule_path_absolute.Parse(context);
        }
        else if (rulename.ToLower().Equals("path-rootless".ToLower()))
        {
            rule = Rule_path_rootless.Parse(context);
        }
        else if (rulename.ToLower().Equals("segment".ToLower()))
        {
            rule = Rule_segment.Parse(context);
        }
        else if (rulename.ToLower().Equals("segment-nz".ToLower()))
        {
            rule = Rule_segment_nz.Parse(context);
        }
        else if (rulename.ToLower().Equals("pchar".ToLower()))
        {
            rule = Rule_pchar.Parse(context);
        }
        else if (rulename.ToLower().Equals("query".ToLower()))
        {
            rule = Rule_query.Parse(context);
        }
        else if (rulename.ToLower().Equals("fragment".ToLower()))
        {
            rule = Rule_fragment.Parse(context);
        }
        else if (rulename.ToLower().Equals("pct-encoded".ToLower()))
        {
            rule = Rule_pct_encoded.Parse(context);
        }
        else if (rulename.ToLower().Equals("unreserved".ToLower()))
        {
            rule = Rule_unreserved.Parse(context);
        }
        else if (rulename.ToLower().Equals("sub-delims".ToLower()))
        {
            rule = Rule_sub_delims.Parse(context);
        }
        else if (rulename.ToLower().Equals("other-delims".ToLower()))
        {
            rule = Rule_other_delims.Parse(context);
        }
        else if (rulename.ToLower().Equals("pchar-no-SQUOTE".ToLower()))
        {
            rule = Rule_pchar_no_SQUOTE.Parse(context);
        }
        else if (rulename.ToLower().Equals("pct-encoded-no-SQUOTE".ToLower()))
        {
            rule = Rule_pct_encoded_no_SQUOTE.Parse(context);
        }
        else if (rulename.ToLower().Equals("qchar-no-AMP".ToLower()))
        {
            rule = Rule_qchar_no_AMP.Parse(context);
        }
        else if (rulename.ToLower().Equals("qchar-no-AMP-EQ".ToLower()))
        {
            rule = Rule_qchar_no_AMP_EQ.Parse(context);
        }
        else if (rulename.ToLower().Equals("qchar-no-AMP-EQ-AT-DOLLAR".ToLower()))
        {
            rule = Rule_qchar_no_AMP_EQ_AT_DOLLAR.Parse(context);
        }
        else if (rulename.ToLower().Equals("ALPHA".ToLower()))
        {
            rule = Rule_ALPHA.Parse(context);
        }
        else if (rulename.ToLower().Equals("DIGIT".ToLower()))
        {
            rule = Rule_DIGIT.Parse(context);
        }
        else if (rulename.ToLower().Equals("HEXDIG".ToLower()))
        {
            rule = Rule_HEXDIG.Parse(context);
        }
        else if (rulename.ToLower().Equals("A-to-F".ToLower()))
        {
            rule = Rule_A_to_F.Parse(context);
        }
        else if (rulename.ToLower().Equals("DQUOTE".ToLower()))
        {
            rule = Rule_DQUOTE.Parse(context);
        }
        else if (rulename.ToLower().Equals("SP".ToLower()))
        {
            rule = Rule_SP.Parse(context);
        }
        else if (rulename.ToLower().Equals("HTAB".ToLower()))
        {
            rule = Rule_HTAB.Parse(context);
        }
        else if (rulename.ToLower().Equals("VCHAR".ToLower()))
        {
            rule = Rule_VCHAR.Parse(context);
        }
        else
        {
            throw new ArgumentException("unknown rule");
        }

        if (rule == null)
        {
            throw new ParserException(
                      "rule \"" + (String)context.GetErrorStack().Peek() + "\" failed",
                      context.text,
                      context.GetErrorIndex(),
                      context.GetErrorStack());
        }

        if (context.text.Length > context.index)
        {
            ParserException primaryError =
                new ParserException(
                    "extra data found",
                    context.text,
                    context.index,
                    new Stack <String>());

            if (context.GetErrorIndex() > context.index)
            {
                ParserException secondaryError =
                    new ParserException(
                        "rule \"" + (String)context.GetErrorStack().Peek() + "\" failed",
                        context.text,
                        context.GetErrorIndex(),
                        context.GetErrorStack());

                primaryError.SetCause(secondaryError);
            }

            throw primaryError;
        }

        return(rule);
    }
Exemplo n.º 5
0
    public static Rule_h16 Parse(ParserContext context)
    {
        context.Push("h16");

        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_HEXDIG.Parse(context);
                    if ((f1 = rule != null))
                    {
                        a1.Add(rule, context.index);
                        c1++;
                    }
                }
                for (int i1 = 1; i1 < 4 && f1; i1++)
                {
                    rule = Rule_HEXDIG.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_h16(context.text.Substring(a0.start, a0.end - a0.start), a0.rules);
        }
        else
        {
            context.index = s0;
        }

        context.Pop("h16", parsed);

        return((Rule_h16)rule);
    }
Exemplo n.º 6
0
    static private Rule Parse(String rulename, String text, bool trace)
    {
        if (rulename == null)
        {
            throw new ArgumentNullException("null rulename");
        }
        if (text == null)
        {
            throw new ArgumentException("null string");
        }

        ParserContext context = new ParserContext(text, trace);

        Rule rule = null;

        if (rulename.ToLower().Equals("sign-in-with-ethereum".ToLower()))
        {
            rule = Rule_sign_in_with_ethereum.Parse(context);
        }
        else if (rulename.ToLower().Equals("domain".ToLower()))
        {
            rule = Rule_domain.Parse(context);
        }
        else if (rulename.ToLower().Equals("address".ToLower()))
        {
            rule = Rule_address.Parse(context);
        }
        else if (rulename.ToLower().Equals("statement".ToLower()))
        {
            rule = Rule_statement.Parse(context);
        }
        else if (rulename.ToLower().Equals("version".ToLower()))
        {
            rule = Rule_version.Parse(context);
        }
        else if (rulename.ToLower().Equals("nonce".ToLower()))
        {
            rule = Rule_nonce.Parse(context);
        }
        else if (rulename.ToLower().Equals("issued-at".ToLower()))
        {
            rule = Rule_issued_at.Parse(context);
        }
        else if (rulename.ToLower().Equals("expiration-time".ToLower()))
        {
            rule = Rule_expiration_time.Parse(context);
        }
        else if (rulename.ToLower().Equals("not-before".ToLower()))
        {
            rule = Rule_not_before.Parse(context);
        }
        else if (rulename.ToLower().Equals("request-id".ToLower()))
        {
            rule = Rule_request_id.Parse(context);
        }
        else if (rulename.ToLower().Equals("chain-id".ToLower()))
        {
            rule = Rule_chain_id.Parse(context);
        }
        else if (rulename.ToLower().Equals("resources".ToLower()))
        {
            rule = Rule_resources.Parse(context);
        }
        else if (rulename.ToLower().Equals("resource".ToLower()))
        {
            rule = Rule_resource.Parse(context);
        }
        else if (rulename.ToLower().Equals("URI".ToLower()))
        {
            rule = Rule_URI.Parse(context);
        }
        else if (rulename.ToLower().Equals("hier-part".ToLower()))
        {
            rule = Rule_hier_part.Parse(context);
        }
        else if (rulename.ToLower().Equals("scheme".ToLower()))
        {
            rule = Rule_scheme.Parse(context);
        }
        else if (rulename.ToLower().Equals("authority".ToLower()))
        {
            rule = Rule_authority.Parse(context);
        }
        else if (rulename.ToLower().Equals("userinfo".ToLower()))
        {
            rule = Rule_userinfo.Parse(context);
        }
        else if (rulename.ToLower().Equals("host".ToLower()))
        {
            rule = Rule_host.Parse(context);
        }
        else if (rulename.ToLower().Equals("port".ToLower()))
        {
            rule = Rule_port.Parse(context);
        }
        else if (rulename.ToLower().Equals("IP-literal".ToLower()))
        {
            rule = Rule_IP_literal.Parse(context);
        }
        else if (rulename.ToLower().Equals("IPvFuture".ToLower()))
        {
            rule = Rule_IPvFuture.Parse(context);
        }
        else if (rulename.ToLower().Equals("IPv6address".ToLower()))
        {
            rule = Rule_IPv6address.Parse(context);
        }
        else if (rulename.ToLower().Equals("h16".ToLower()))
        {
            rule = Rule_h16.Parse(context);
        }
        else if (rulename.ToLower().Equals("ls32".ToLower()))
        {
            rule = Rule_ls32.Parse(context);
        }
        else if (rulename.ToLower().Equals("IPv4address".ToLower()))
        {
            rule = Rule_IPv4address.Parse(context);
        }
        else if (rulename.ToLower().Equals("dec-octet".ToLower()))
        {
            rule = Rule_dec_octet.Parse(context);
        }
        else if (rulename.ToLower().Equals("reg-name".ToLower()))
        {
            rule = Rule_reg_name.Parse(context);
        }
        else if (rulename.ToLower().Equals("path-abempty".ToLower()))
        {
            rule = Rule_path_abempty.Parse(context);
        }
        else if (rulename.ToLower().Equals("path-absolute".ToLower()))
        {
            rule = Rule_path_absolute.Parse(context);
        }
        else if (rulename.ToLower().Equals("path-rootless".ToLower()))
        {
            rule = Rule_path_rootless.Parse(context);
        }
        else if (rulename.ToLower().Equals("path-empty".ToLower()))
        {
            rule = Rule_path_empty.Parse(context);
        }
        else if (rulename.ToLower().Equals("segment".ToLower()))
        {
            rule = Rule_segment.Parse(context);
        }
        else if (rulename.ToLower().Equals("segment-nz".ToLower()))
        {
            rule = Rule_segment_nz.Parse(context);
        }
        else if (rulename.ToLower().Equals("pchar".ToLower()))
        {
            rule = Rule_pchar.Parse(context);
        }
        else if (rulename.ToLower().Equals("query".ToLower()))
        {
            rule = Rule_query.Parse(context);
        }
        else if (rulename.ToLower().Equals("fragment".ToLower()))
        {
            rule = Rule_fragment.Parse(context);
        }
        else if (rulename.ToLower().Equals("pct-encoded".ToLower()))
        {
            rule = Rule_pct_encoded.Parse(context);
        }
        else if (rulename.ToLower().Equals("unreserved".ToLower()))
        {
            rule = Rule_unreserved.Parse(context);
        }
        else if (rulename.ToLower().Equals("reserved".ToLower()))
        {
            rule = Rule_reserved.Parse(context);
        }
        else if (rulename.ToLower().Equals("gen-delims".ToLower()))
        {
            rule = Rule_gen_delims.Parse(context);
        }
        else if (rulename.ToLower().Equals("sub-delims".ToLower()))
        {
            rule = Rule_sub_delims.Parse(context);
        }
        else if (rulename.ToLower().Equals("date-fullyear".ToLower()))
        {
            rule = Rule_date_fullyear.Parse(context);
        }
        else if (rulename.ToLower().Equals("date-month".ToLower()))
        {
            rule = Rule_date_month.Parse(context);
        }
        else if (rulename.ToLower().Equals("date-mday".ToLower()))
        {
            rule = Rule_date_mday.Parse(context);
        }
        else if (rulename.ToLower().Equals("time-hour".ToLower()))
        {
            rule = Rule_time_hour.Parse(context);
        }
        else if (rulename.ToLower().Equals("time-minute".ToLower()))
        {
            rule = Rule_time_minute.Parse(context);
        }
        else if (rulename.ToLower().Equals("time-second".ToLower()))
        {
            rule = Rule_time_second.Parse(context);
        }
        else if (rulename.ToLower().Equals("time-secfrac".ToLower()))
        {
            rule = Rule_time_secfrac.Parse(context);
        }
        else if (rulename.ToLower().Equals("time-numoffset".ToLower()))
        {
            rule = Rule_time_numoffset.Parse(context);
        }
        else if (rulename.ToLower().Equals("time-offset".ToLower()))
        {
            rule = Rule_time_offset.Parse(context);
        }
        else if (rulename.ToLower().Equals("partial-time".ToLower()))
        {
            rule = Rule_partial_time.Parse(context);
        }
        else if (rulename.ToLower().Equals("full-date".ToLower()))
        {
            rule = Rule_full_date.Parse(context);
        }
        else if (rulename.ToLower().Equals("full-time".ToLower()))
        {
            rule = Rule_full_time.Parse(context);
        }
        else if (rulename.ToLower().Equals("date-time".ToLower()))
        {
            rule = Rule_date_time.Parse(context);
        }
        else if (rulename.ToLower().Equals("ALPHA".ToLower()))
        {
            rule = Rule_ALPHA.Parse(context);
        }
        else if (rulename.ToLower().Equals("LF".ToLower()))
        {
            rule = Rule_LF.Parse(context);
        }
        else if (rulename.ToLower().Equals("DIGIT".ToLower()))
        {
            rule = Rule_DIGIT.Parse(context);
        }
        else if (rulename.ToLower().Equals("HEXDIG".ToLower()))
        {
            rule = Rule_HEXDIG.Parse(context);
        }
        else
        {
            throw new ArgumentException("unknown rule");
        }

        if (rule == null)
        {
            throw new ParserException(
                      "rule \"" + (String)context.GetErrorStack().Peek() + "\" failed",
                      context.text,
                      context.GetErrorIndex(),
                      context.GetErrorStack());
        }

        if (context.text.Length > context.index)
        {
            ParserException primaryError =
                new ParserException(
                    "extra data found",
                    context.text,
                    context.index,
                    new Stack <String>());

            if (context.GetErrorIndex() > context.index)
            {
                ParserException secondaryError =
                    new ParserException(
                        "rule \"" + (String)context.GetErrorStack().Peek() + "\" failed",
                        context.text,
                        context.GetErrorIndex(),
                        context.GetErrorStack());

                primaryError.SetCause(secondaryError);
            }

            throw primaryError;
        }

        return(rule);
    }