blob: 3cd85874343b3119c89af6942f9e051bc6a97944 [file] [log] [blame]
David Tolnayb79ee962016-09-04 09:39:20 -07001pub type Ident = String;
2
3#[derive(Debug, Clone, Eq, PartialEq)]
4pub enum Visibility {
5 Public,
6 Inherited,
7}
8
9fn ident_ch(ch: char) -> bool {
10 ch.is_alphanumeric() || ch == '_'
11}
12
13named!(pub word<&str, Ident>, preceded!(
14 opt!(call!(::nom::multispace)),
15 map!(take_while1_s!(ident_ch), String::from)
16));
17
18named!(pub visibility<&str, Visibility>, preceded!(
David Tolnay65e7f302016-09-04 10:19:25 -070019 opt!(call!(::nom::multispace)),
David Tolnayb79ee962016-09-04 09:39:20 -070020 alt!(
21 terminated!(tag_s!("pub"), call!(::nom::multispace)) => { |_| Visibility::Public }
22 |
23 epsilon!() => { |_| Visibility::Inherited }
24 )
25));