3 ms·
> something along the lines of what Perl 6 is trying to do (if only someone could implement it) What, like, perl6? grammar URL { rule TOP { <proto> '://'
by lelf 13y ago
> something along the lines of what Perl 6 is trying to do (if only someone could implement it)
What, like, perl6?
grammar URL {
rule TOP { <proto> '://' <domain> '/' }
token proto { 'http' 's'? }
token subdom { \w+ }
rule domain { <.subdom> [ '.' <.domain> ]? }
}
say URL.parse('http://lelf.lu/');
Betty:hacks lelf$ perl6 gr.p6
「http://lelf.lu/」
proto => 「http」
domain => 「lelf.lu」
- draegtun 13y agoAnd for those interested a full RFC 3986 (URI) in Perl6 grammar can be found here - https://github.com/ihrd/uri https://github.com/ihrd/uri Here is direct link to grammar module - https://github.com/ihrd/uri/blob/master/lib/IETF/RFC_Grammar/URI.pm https://github.com/ihrd/uri/blob/master/lib/IETF/RFC_Grammar...