blob: a5173d7c890eca69d5772f0a49294ae5e8fcc17d [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 Tolnay9d8f1972016-09-04 11:58:48 -070010pub mod parsing {
11 use super::*;
12
13 fn ident_ch(ch: char) -> bool {
14 ch.is_alphanumeric() || ch == '_'
15 }
16
17 named!(pub word<&str, Ident>, preceded!(
18 opt!(call!(::nom::multispace)),
19 map!(take_while1_s!(ident_ch), String::from)
20 ));
21
22 named!(pub visibility<&str, Visibility>, preceded!(
23 opt!(call!(::nom::multispace)),
24 alt!(
25 terminated!(tag_s!("pub"), call!(::nom::multispace)) => { |_| Visibility::Public }
26 |
27 epsilon!() => { |_| Visibility::Inherited }
28 )
29 ));
David Tolnayb79ee962016-09-04 09:39:20 -070030}