mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Split parse and expand errors
This commit is contained in:
parent
dffe318701
commit
725805dc79
4 changed files with 76 additions and 74 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue