public static Rule_reserved Parse(ParserContext context) { context.Push("reserved"); 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_gen_delims.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 = Rule_sub_delims.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_reserved(context.text.Substring(a0.start, a0.end - a0.start), a0.rules); } else { context.index = s0; } context.Pop("reserved", parsed); return((Rule_reserved)rule); }
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); }