aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/lib.rs
diff options
context:
space:
mode:
authorWilco Kusee <[email protected]>2019-03-03 09:40:03 +0000
committerWilco Kusee <[email protected]>2019-03-03 09:40:03 +0000
commit725805dc795159399c90a5c9b6f11ffeadec2e0f (patch)
treeddc799a626c1b46d67bb274c87b4cfdaa22cd1ec /crates/ra_mbe/src/lib.rs
parentdffe318701dcbd7da2b241cd8f623be9d4744ee3 (diff)
Split parse and expand errors
Diffstat (limited to 'crates/ra_mbe/src/lib.rs')
-rw-r--r--crates/ra_mbe/src/lib.rs13
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;
25pub use tt::{Delimiter, Punct}; 25pub use tt::{Delimiter, Punct};
26 26
27#[derive(Debug, PartialEq, Eq)] 27#[derive(Debug, PartialEq, Eq)]
28pub enum MacroRulesError { 28pub enum ParseError {
29 ParseError,
30}
31
32#[derive(Debug, PartialEq, Eq)]
33pub enum ExpandError {
29 NoMatchingRule, 34 NoMatchingRule,
30 UnexpectedToken, 35 UnexpectedToken,
31 BindingError(String), 36 BindingError(String),
32 ParseError,
33} 37}
34 38
35pub type Result<T> = ::std::result::Result<T, MacroRulesError>;
36pub use crate::syntax_bridge::{ast_to_token_tree, token_tree_to_ast_item_list}; 39pub 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
47impl MacroRules { 50impl 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}