Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Modify grammar to use IETF grammars rather than IETF regex.

  • Loading branch information...
commit ed931e969515c3256a1af498729356bb65af0762 1 parent 121810d
U-ron-PC\ron authored
Showing with 22 additions and 19 deletions.
  1. +22 −19 lib/URI/Grammar.pm
View
41 lib/URI/Grammar.pm
@@ -1,25 +1,28 @@
use v6;
-grammar URI::Grammar {
- token TOP { ^ [<scheme> ':']? [ '//' <authority>]? <path> ['?' <query>]? ['#' <fragment>]? $ };
- token scheme { <-[:/&?#]>+ };
+
+use IETF::RFC_Grammar::URI;
+
+grammar URI::Grammar is IETF::RFC_Grammar::URI {
+
+ token TOP {
+ ^ [<scheme> ':']?
+ [ '//' <authority>]? <path> ['?' <query>]?
+ [ '#' <fragment> ]? $
+ };
+
token authority { <host> [':' <port>]? };
- token host { <-[/&?#:]>* };
- token port { \d+ };
- token path { <slash>? [ <chunk> '/'?]* }; # * mb wrong, because that allow '' URI
+ token path { <slash>? [ <chunk>** '/'?]* };
token slash { '/' };
- token chunk { <-[/?#:]>+ };
- token query { <-[#]>* };
- token fragment { .* };
-}
-# Official regexp (p5):
-# my($scheme, $authority, $path, $query, $fragment) =
-# $uri =~ m/
-# (?:([^:/?#]+):)?
-# (?://([^/?#]*))?
-# ([^?#]*)
-# (?:\?([^#]*))?
-# (?:#(.*))?
-# /x;
+#
+# following hangs rakudo (RT #37745 afaik)
+# token chunk { <[a..z]>* }; say 'ok' if 'index/' ~~ /[ <chunk> '/'?]*/
+#
+# so can't just use rfc segment but use small hack of requiring
+# at least one char. Use of ** seperator above makes behavior
+# consistent with rfc.
+#
+ token chunk { <.pchar> <.segment> }
+}
# vim:ft=perl6
Please sign in to comment.
Something went wrong with that request. Please try again.