mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
make macro-rules eq
This commit is contained in:
parent
af62fde57f
commit
e7b370226c
2 changed files with 11 additions and 11 deletions
|
@ -30,7 +30,7 @@ pub use crate::syntax_bridge::ast_to_token_tree;
|
|||
/// be very confusing is that AST has almost exactly the same shape as
|
||||
/// `tt::TokenTree`, but there's a crucial difference: in macro rules, `$ident`
|
||||
/// and `$()*` have special meaning (see `Var` and `Repeat` data structures)
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct MacroRules {
|
||||
pub(crate) rules: Vec<Rule>,
|
||||
}
|
||||
|
@ -44,13 +44,13 @@ impl MacroRules {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(crate) struct Rule {
|
||||
pub(crate) lhs: Subtree,
|
||||
pub(crate) rhs: Subtree,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(crate) enum TokenTree {
|
||||
Leaf(Leaf),
|
||||
Subtree(Subtree),
|
||||
|
@ -58,7 +58,7 @@ pub(crate) enum TokenTree {
|
|||
}
|
||||
impl_froms!(TokenTree: Leaf, Subtree, Repeat);
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(crate) enum Leaf {
|
||||
Literal(Literal),
|
||||
Punct(Punct),
|
||||
|
@ -67,37 +67,37 @@ pub(crate) enum Leaf {
|
|||
}
|
||||
impl_froms!(Leaf: Literal, Punct, Ident, Var);
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(crate) struct Subtree {
|
||||
pub(crate) delimiter: Delimiter,
|
||||
pub(crate) token_trees: Vec<TokenTree>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(crate) struct Repeat {
|
||||
pub(crate) subtree: Subtree,
|
||||
pub(crate) kind: RepeatKind,
|
||||
pub(crate) separator: Option<char>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(crate) enum RepeatKind {
|
||||
ZeroOrMore,
|
||||
OneOrMore,
|
||||
ZeroOrOne,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(crate) struct Literal {
|
||||
pub(crate) text: SmolStr,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(crate) struct Ident {
|
||||
pub(crate) text: SmolStr,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(crate) struct Var {
|
||||
pub(crate) text: SmolStr,
|
||||
pub(crate) kind: Option<SmolStr>,
|
||||
|
|
|
@ -39,7 +39,7 @@ pub struct Subtree {
|
|||
pub token_trees: Vec<TokenTree>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Delimiter {
|
||||
Parenthesis,
|
||||
Brace,
|
||||
|
|
Loading…
Reference in a new issue