From b8f56f89c64f65b5a7d9c75f81597c28fba63b48 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 30 Jan 2019 23:02:27 +0300 Subject: start token tree module --- crates/ra_hir/src/macros.rs | 3 +++ crates/ra_hir/src/macros/token_tree.rs | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 crates/ra_hir/src/macros/token_tree.rs diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs index 7ca34d434..9aa706836 100644 --- a/crates/ra_hir/src/macros.rs +++ b/crates/ra_hir/src/macros.rs @@ -1,3 +1,6 @@ +#[allow(unused)] +mod token_tree; + /// Machinery for macro expansion. /// /// One of the more complicated things about macros is managing the source code diff --git a/crates/ra_hir/src/macros/token_tree.rs b/crates/ra_hir/src/macros/token_tree.rs new file mode 100644 index 000000000..7026ce3b3 --- /dev/null +++ b/crates/ra_hir/src/macros/token_tree.rs @@ -0,0 +1,36 @@ +use ra_syntax::SmolStr; + +enum TokenTree { + Leaf(Leaf), + Subtree(Subtree), +} + +enum Leaf { + Literal(Literal), + Punct(Punct), + Ident(Ident), +} + +struct Subtree { + delimiter: Delimiter, + token_trees: Vec, +} + +enum Delimiter { + Parenthesis, + Brace, + Bracket, + None, +} + +struct Literal { + text: SmolStr, +} + +struct Punct { + char: char, +} + +struct Ident { + text: SmolStr, +} -- cgit v1.2.3