diff options
Diffstat (limited to 'crates/ra_mbe/src/lib.rs')
-rw-r--r-- | crates/ra_mbe/src/lib.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index 907402f5f..8a2d6ff63 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs | |||
@@ -24,6 +24,15 @@ use ra_syntax::SmolStr; | |||
24 | 24 | ||
25 | pub use tt::{Delimiter, Punct}; | 25 | pub use tt::{Delimiter, Punct}; |
26 | 26 | ||
27 | #[derive(Debug, PartialEq, Eq)] | ||
28 | pub enum MacroRulesError { | ||
29 | NoMatchingRule, | ||
30 | UnexpectedToken, | ||
31 | BindingError(String), | ||
32 | ParseError, | ||
33 | } | ||
34 | |||
35 | pub type Result<T> = ::std::result::Result<T, MacroRulesError>; | ||
27 | pub use crate::syntax_bridge::{ast_to_token_tree, token_tree_to_ast_item_list}; | 36 | pub use crate::syntax_bridge::{ast_to_token_tree, token_tree_to_ast_item_list}; |
28 | 37 | ||
29 | /// This struct contains AST for a single `macro_rules` definition. What might | 38 | /// This struct contains AST for a single `macro_rules` definition. What might |
@@ -36,11 +45,11 @@ pub struct MacroRules { | |||
36 | } | 45 | } |
37 | 46 | ||
38 | impl MacroRules { | 47 | impl MacroRules { |
39 | pub fn parse(tt: &tt::Subtree) -> Option<MacroRules> { | 48 | pub fn parse(tt: &tt::Subtree) -> Result<MacroRules> { |
40 | mbe_parser::parse(tt) | 49 | mbe_parser::parse(tt) |
41 | } | 50 | } |
42 | pub fn expand(&self, tt: &tt::Subtree) -> Option<tt::Subtree> { | 51 | pub fn expand(&self, tt: &tt::Subtree) -> Result<tt::Subtree> { |
43 | mbe_expander::exapnd(self, tt) | 52 | mbe_expander::expand(self, tt) |
44 | } | 53 | } |
45 | } | 54 | } |
46 | 55 | ||