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