aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-08 15:18:57 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-08 15:18:57 +0100
commitac6ab0758731d0555fbf1b1a918abd3e12c8169d (patch)
tree05f568cbd925dbbd578f9414fd9e4ea3634b68e4 /crates/ra_parser
parent1ca7a744eb512e6b900988cba871dcd3d90d447f (diff)
parent8ed710457875e6f580a0ddf6ab29c6b10d389a41 (diff)
Merge #1105
1105: [WIP] Implement ra_mbe meta variables support r=matklad a=edwin0cheng This PR implements the following meta variable support in `ra_mba` crate (issue #720): - [x] `path` - [ ] `expr` - [ ] `ty` - [ ] `pat` - [ ] `stmt` - [ ] `block` - [ ] `meta` - [ ] `item` *Implementation Details* In the macro expanding lhs phase, if we see a meta variable type, we try to create a `tt:TokenTree` from the remaining input. And then we use a special set of `ra_parser` to parse it to `SyntaxNode`. Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_parser')
-rw-r--r--crates/ra_parser/src/grammar.rs4
-rw-r--r--crates/ra_parser/src/lib.rs8
2 files changed, 12 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs
index b2ffeff8c..c5f510e6b 100644
--- a/crates/ra_parser/src/grammar.rs
+++ b/crates/ra_parser/src/grammar.rs
@@ -49,6 +49,10 @@ pub(crate) fn root(p: &mut Parser) {
49 m.complete(p, SOURCE_FILE); 49 m.complete(p, SOURCE_FILE);
50} 50}
51 51
52pub(crate) fn path(p: &mut Parser) {
53 paths::type_path(p);
54}
55
52pub(crate) fn reparser( 56pub(crate) fn reparser(
53 node: SyntaxKind, 57 node: SyntaxKind,
54 first_child: Option<SyntaxKind>, 58 first_child: Option<SyntaxKind>,
diff --git a/crates/ra_parser/src/lib.rs b/crates/ra_parser/src/lib.rs
index 30ba06aac..3ceeeebd7 100644
--- a/crates/ra_parser/src/lib.rs
+++ b/crates/ra_parser/src/lib.rs
@@ -61,6 +61,14 @@ pub fn parse(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) {
61 event::process(tree_sink, events); 61 event::process(tree_sink, events);
62} 62}
63 63
64/// Parse given tokens into the given sink as a path
65pub fn parse_path(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) {
66 let mut p = parser::Parser::new(token_source);
67 grammar::path(&mut p);
68 let events = p.finish();
69 event::process(tree_sink, events);
70}
71
64/// A parsing function for a specific braced-block. 72/// A parsing function for a specific braced-block.
65pub struct Reparser(fn(&mut parser::Parser)); 73pub struct Reparser(fn(&mut parser::Parser));
66 74