blob: b24e9ee024cacb9eb5c4ef188277ad10c275b834 [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
David Tolnay86eca752016-09-04 11:26:41 -07009#[cfg(feature = "parsing")]
David Tolnayb79ee962016-09-04 09:39:20 -070010fn ident_ch(ch: char) -> bool {
11 ch.is_alphanumeric() || ch == '_'
12}
13
David Tolnay86eca752016-09-04 11:26:41 -070014#[cfg(feature = "parsing")]
David Tolnayb79ee962016-09-04 09:39:20 -070015named!(pub word<&str, Ident>, preceded!(
16 opt!(call!(::nom::multispace)),
17 map!(take_while1_s!(ident_ch), String::from)
18));
19
David Tolnay86eca752016-09-04 11:26:41 -070020#[cfg(feature = "parsing")]
David Tolnayb79ee962016-09-04 09:39:20 -070021named!(pub visibility<&str, Visibility>, preceded!(
David Tolnay65e7f302016-09-04 10:19:25 -070022 opt!(call!(::nom::multispace)),
David Tolnayb79ee962016-09-04 09:39:20 -070023 alt!(
24 terminated!(tag_s!("pub"), call!(::nom::multispace)) => { |_| Visibility::Public }
25 |
26 epsilon!() => { |_| Visibility::Inherited }
27 )
28));