public static Rule_time_second Parse(ParserContext context) { context.Push("time-second"); 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 < 2 && f1; i1++) { rule = Rule_DIGIT.Parse(context); if ((f1 = rule != null)) { a1.Add(rule, context.index); c1++; } } parsed = c1 == 2; } 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_time_second(context.text.Substring(a0.start, a0.end - a0.start), a0.rules); } else { context.index = s0; } context.Pop("time-second", parsed); return((Rule_time_second)rule); }
public static Rule_partial_time Parse(ParserContext context) { context.Push("partial-time"); 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_time_hour.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_time_minute.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_time_second.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 = Rule_time_secfrac.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_partial_time(context.text.Substring(a0.start, a0.end - a0.start), a0.rules); } else { context.index = s0; } context.Pop("partial-time", parsed); return((Rule_partial_time)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); }
public Object Visit(Rule_time_second rule) { return(VisitRules(rule.rules)); }