diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-19 09:56:39 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-19 09:56:39 +0100 |
commit | ab0a96586fd54858106cb6ac112d61eb657426f6 (patch) | |
tree | 86bbf2601069f6b0007dc181c824ef706d08c60d /crates/ra_parser/src/lib.rs | |
parent | d55f1136d6444b1f50b9092c36a976d0e1c26202 (diff) | |
parent | a6d51e09610989821aaf79871bcab0661c9b0f74 (diff) |
Merge #1148
1148: Add token_tree_to_xxx functions r=matklad a=edwin0cheng
<del>As discus in PR #1147 , this PR added a `mbe::MacroKind` .
Currently only 2 kind of macro are supported, `SourceFile` and `Block`.</del>
Added following functions for `tt::TokenTree` and `ast::Node` conversion:
* token_tree_to_expr
* token_tree_to_pat
* token_tree_to_ty
* token_tree_to_macro_stmts
* token_tree_to_macro_items
And added two new syntax kind:
* MACRO_ITEMS
* MACRO_STMTS
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/lib.rs')
-rw-r--r-- | crates/ra_parser/src/lib.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/ra_parser/src/lib.rs b/crates/ra_parser/src/lib.rs index 11b5b9a75..0ea942b6e 100644 --- a/crates/ra_parser/src/lib.rs +++ b/crates/ra_parser/src/lib.rs | |||
@@ -98,6 +98,14 @@ pub fn parse_item(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) | |||
98 | parse_from_tokens(token_source, tree_sink, grammar::item); | 98 | parse_from_tokens(token_source, tree_sink, grammar::item); |
99 | } | 99 | } |
100 | 100 | ||
101 | pub fn parse_macro_items(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) { | ||
102 | parse_from_tokens(token_source, tree_sink, grammar::macro_items); | ||
103 | } | ||
104 | |||
105 | pub fn parse_macro_stmts(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) { | ||
106 | parse_from_tokens(token_source, tree_sink, grammar::macro_stmts); | ||
107 | } | ||
108 | |||
101 | /// A parsing function for a specific braced-block. | 109 | /// A parsing function for a specific braced-block. |
102 | pub struct Reparser(fn(&mut parser::Parser)); | 110 | pub struct Reparser(fn(&mut parser::Parser)); |
103 | 111 | ||