Split parse and expand errors
This commit is contained in:
@@ -25,14 +25,17 @@ use ra_syntax::SmolStr;
|
||||
pub use tt::{Delimiter, Punct};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum MacroRulesError {
|
||||
NoMatchingRule,
|
||||
UnexpectedToken,
|
||||
BindingError(String),
|
||||
pub enum ParseError {
|
||||
ParseError,
|
||||
}
|
||||
|
||||
pub type Result<T> = ::std::result::Result<T, MacroRulesError>;
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum ExpandError {
|
||||
NoMatchingRule,
|
||||
UnexpectedToken,
|
||||
BindingError(String),
|
||||
}
|
||||
|
||||
pub use crate::syntax_bridge::{ast_to_token_tree, token_tree_to_ast_item_list};
|
||||
|
||||
/// This struct contains AST for a single `macro_rules` definition. What might
|
||||
@@ -45,10 +48,10 @@ pub struct MacroRules {
|
||||
}
|
||||
|
||||
impl MacroRules {
|
||||
pub fn parse(tt: &tt::Subtree) -> Result<MacroRules> {
|
||||
pub fn parse(tt: &tt::Subtree) -> Result<MacroRules, ParseError> {
|
||||
mbe_parser::parse(tt)
|
||||
}
|
||||
pub fn expand(&self, tt: &tt::Subtree) -> Result<tt::Subtree> {
|
||||
pub fn expand(&self, tt: &tt::Subtree) -> Result<tt::Subtree, ExpandError> {
|
||||
mbe_expander::expand(self, tt)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user