From 2980508ad2a04364f943af72c2c05337e03f4f6c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 31 Jan 2019 11:09:19 +0300 Subject: debug impls --- crates/ra_hir/src/macros/mbe.rs | 16 ++++++++++++++-- crates/ra_hir/src/macros/tt.rs | 7 +++++++ 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir/src/macros') diff --git a/crates/ra_hir/src/macros/mbe.rs b/crates/ra_hir/src/macros/mbe.rs index 1408ed511..7af7066fb 100644 --- a/crates/ra_hir/src/macros/mbe.rs +++ b/crates/ra_hir/src/macros/mbe.rs @@ -2,21 +2,25 @@ use ra_syntax::SmolStr; use crate::macros::tt; -struct MacroRules { +#[derive(Debug)] +pub(crate) struct MacroRules { rules: Vec, } +#[derive(Debug)] struct Rule { lhs: TokenTree, rhs: TokenTree, } +#[derive(Debug)] enum TokenTree { Leaf(Leaf), Subtree(Subtree), Repeat(Repeat), } +#[derive(Debug)] enum Leaf { Literal(Literal), Punct(Punct), @@ -24,11 +28,13 @@ enum Leaf { Var(Var), } +#[derive(Debug)] struct Subtree { delimiter: Delimiter, token_trees: Vec, } +#[derive(Debug)] enum Delimiter { Parenthesis, Brace, @@ -36,33 +42,39 @@ enum Delimiter { None, } +#[derive(Debug)] struct Repeat { subtree: Subtree, kind: RepeatKind, } +#[derive(Debug)] enum RepeatKind { ZeroOrMore, OneOrMore, ZeroOrOne, } +#[derive(Debug)] struct Literal { text: SmolStr, } +#[derive(Debug)] struct Punct { char: char, } +#[derive(Debug)] struct Ident { text: SmolStr, } +#[derive(Debug)] struct Var { text: SmolStr, } -fn parse(tt: tt::TokenTree) -> MacroRules { +pub(crate) fn parse(tt: &tt::Subtree) -> MacroRules { MacroRules { rules: Vec::new() } } diff --git a/crates/ra_hir/src/macros/tt.rs b/crates/ra_hir/src/macros/tt.rs index 11b1089d3..02ff422b5 100644 --- a/crates/ra_hir/src/macros/tt.rs +++ b/crates/ra_hir/src/macros/tt.rs @@ -1,11 +1,13 @@ use ra_syntax::SmolStr; +#[derive(Debug)] pub(crate) enum TokenTree { Leaf(Leaf), Subtree(Subtree), } impl_froms!(TokenTree: Leaf, Subtree); +#[derive(Debug)] pub(crate) enum Leaf { Literal(Literal), Punct(Punct), @@ -13,11 +15,13 @@ pub(crate) enum Leaf { } impl_froms!(Leaf: Literal, Punct, Ident); +#[derive(Debug)] pub(crate) struct Subtree { pub(crate) delimiter: Delimiter, pub(crate) token_trees: Vec, } +#[derive(Debug)] pub(crate) enum Delimiter { Parenthesis, Brace, @@ -25,14 +29,17 @@ pub(crate) enum Delimiter { None, } +#[derive(Debug)] pub(crate) struct Literal { pub(crate) text: SmolStr, } +#[derive(Debug)] pub(crate) struct Punct { pub(crate) char: char, } +#[derive(Debug)] pub(crate) struct Ident { pub(crate) text: SmolStr, } -- cgit v1.2.3