1 use std::collections::HashMap; 2 3 use grammar::parse_tree::TypeRef; 4 use string_cache::DefaultAtom as Atom; 5 6 #[cfg(test)] 7 mod test; 8 9 pub struct TokenDefinition { 10 // if the enum type is `foo::bar::baz<X,Y>` then: 11 enum_type: TypeRef, 12 13 // map from a custom string, like `"("` to a variant name like LPAREN 14 token_map: HashMap<Atom, Atom>, 15 } 16 17 impl TokenDefinition { new(enum_type: TypeRef, token_map: Vec<(Atom, Atom)>) -> TokenDefinition18 pub fn new(enum_type: TypeRef, token_map: Vec<(Atom, Atom)>) -> TokenDefinition { 19 TokenDefinition { 20 enum_type: enum_type, 21 token_map: token_map.into_iter().collect(), 22 } 23 } 24 enum_type(&self) -> &TypeRef25 pub fn enum_type(&self) -> &TypeRef { 26 &self.enum_type 27 } 28 } 29