blob: c7a2609f727b1fd476dc292e306d1f32003c313b [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!(
19 opt!(call!(::nom::space)),
20 alt!(
21 terminated!(tag_s!("pub"), call!(::nom::multispace)) => { |_| Visibility::Public }
22 |
23 epsilon!() => { |_| Visibility::Inherited }
24 )
25));