Skip to content

Instantly share code, notes, and snippets.

@Noxivs
Last active August 29, 2015 14:10
Show Gist options
  • Save Noxivs/94d758b3cffb641c950a to your computer and use it in GitHub Desktop.
Save Noxivs/94d758b3cffb641c950a to your computer and use it in GitHub Desktop.
#![feature(macro_rules)]
macro_rules! grammar(
($name:expr,$x:expr) => ( /* parser + generate function */)
)
grammar!("url", "
rule TOP {
<protocol>'://'<address>
}
token protocol {
'http'|'https'|'ftp'|'file'
}
rule address {
<subdomain>'.'<domain>'.'<tld>
}
")
fn main() {
let res = match url("http://www.oker.fr") {
Ok(res) => res,
Err(err) => panic!("{}", err)
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment