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 <edwin0cheng@gmail.com>
This commit is contained in:
bors[bot] 2019-04-08 14:18:57 +00:00
commit ac6ab07587
8 changed files with 683 additions and 231 deletions

View file

@ -49,6 +49,10 @@ pub(crate) fn root(p: &mut Parser) {
m.complete(p, SOURCE_FILE);
}
pub(crate) fn path(p: &mut Parser) {
paths::type_path(p);
}
pub(crate) fn reparser(
node: SyntaxKind,
first_child: Option<SyntaxKind>,

View file

@ -61,6 +61,14 @@ pub fn parse(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) {
event::process(tree_sink, events);
}
/// Parse given tokens into the given sink as a path
pub fn parse_path(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) {
let mut p = parser::Parser::new(token_source);
grammar::path(&mut p);
let events = p.finish();
event::process(tree_sink, events);
}
/// A parsing function for a specific braced-block.
pub struct Reparser(fn(&mut parser::Parser));