grammar RFC3987 rule IRI scheme ':' ihier_part ( '?' iquery )? ( '#' ifragment )? end rule ihier_part '//' iauthority ipath_abempty / ipath_absolute / ipath_rootless / ipath_empty end rule IRI_reference IRI / irelative_ref end rule absolute_IRI scheme ':' ihier_part ( '?' iquery )? end rule irelative_ref irelative_part ( '?' iquery )? ( '#' ifragment )? end rule irelative_part '//' iauthority ipath_abempty / ipath_absolute / ipath_noscheme / ipath_empty end rule iauthority ( iuserinfo '@' )? ihost ( ':' port )? end rule iuserinfo ( iunreserved / pct_encoded / sub_delims / ':' )* end rule ihost IP_literal / IPv4address / ireg_name end rule ireg_name ( iunreserved / pct_encoded / sub_delims )* end rule ipath ipath_abempty # begins with '/' or is empty / ipath_absolute # begins with '/' but not '//' / ipath_noscheme # begins with a non-colon segment / ipath_rootless # begins with a segment / ipath_empty # zero characters end rule ipath_abempty ( '/' isegment)* end rule ipath_absolute '/' ( isegment_nz ( '/' isegment )* )? end rule ipath_noscheme isegment_nz_nc ( '/' isegment)* end rule ipath_rootless isegment_nz ( '/' isegment )* end rule ipath_empty '' end rule isegment ( ipchar )* end rule isegment_nz ( ipchar )+ end rule isegment_nz_nc ( iunreserved / pct_encoded / sub_delims / '@' )+ # non-zero-length segment without any colon ':' end rule pct_encoded '%' HEXDIG HEXDIG end rule ipchar iunreserved / pct_encoded / sub_delims / ':' / '@' end rule iquery ( ipchar iprivate '/' '?' )* end rule ifragment ( ipchar '/' '?' )* end rule iunreserved ALPHA / DIGIT / '-' / '.' / '_' / '~' / ucschar end rule ucschar [\u000A0-\u0D7FF] / [\u0F900-\u0FDCF] / [\u0FDF0-\u0FFEF] / [\u10000-\u1FFFD] / [\u20000-\u2FFFD] / [\u30000-\u3FFFD] / [\u40000-\u4FFFD] / [\u50000-\u5FFFD] / [\u60000-\u6FFFD] / [\u70000-\u7FFFD] / [\u80000-\u8FFFD] / [\u90000-\u9FFFD] / [\uA0000-\uAFFFD] / [\uB0000-\uBFFFD] / [\uC0000-\uCFFFD] #/ [\uD0000-\uDFFFD] / [\uE1000-\uEFFFD] / [\uE1000-\uEFFFD] end rule iprivate [\uE000-\uF8FF] / [\uF0000-\uFFFFD] / [\u100000-\u10FFFD] end rule scheme ALPHA ( ALPHA / DIGIT / "+" / "-" / "." )* end rule port DIGIT* end rule IP_literal "[" ( IPv6address / IPvFuture ) "]" end rule IPvFuture "v" HEXDIG+ "." ( unreserved / sub_delims / ":" )+ end rule IPv6address ( h16 ":" ) 6..6 ls32 / "::" ( h16 ":" ) 5..5 ls32 / [ h16 ] "::" ( h16 ":" ) 4..4 ls32 / [ ( h16 ":" ) 1..1 h16 ] "::" ( h16 ":" ) 3..3 ls32 / [ ( h16 ":" ) 2..2 h16 ] "::" ( h16 ":" ) 2..2 ls32 / [ ( h16 ":" ) 3..3 h16 ] "::" h16 ":" ls32 / [ ( h16 ":" ) 4..4 h16 ] "::" ls32 / [ ( h16 ":" ) 5..5 h16 ] "::" h16 / [ ( h16 ":" ) 6..6 h16 ] "::" end rule h16 HEXDIG 4..4 end rule ls32 ( h16 ":" h16 ) / IPv4address end rule IPv4address dec_octet "." dec_octet "." dec_octet "." dec_octet end rule dec_octet DIGIT # 0-9 / ['0x30'-'0x39'] DIGIT # 10-99 / "1" DIGIT 2..2 # 100-199 / "2" ['0x30'-'0x34'] DIGIT # 200-249 / "25" ['0x30'-'0x35'] # 250-255 end rule pct_encoded "%" HEXDIG HEXDIG end rule unreserved ALPHA / DIGIT / "-" / "." / "_" / "~" end rule reserved gen_delims / sub_delims end rule gen_delims ":" / "/" / "?" / "#" / "[" / "]" / "@" end rule sub_delims '!' / '$' / '&' / "'" / '(' / ')' / '*' / '+' / ',' / ';' / '=' end rule ALPHA [a-zA-Z] end rule DIGIT [0-9] end rule HEXDIG [0-9A-F] end end