aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/tt_cursor.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-14 15:16:42 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-14 15:16:42 +0100
commit5d35f284f5ac70cde5d758e7c63a38eae0fb0b55 (patch)
tree4cde8df0f4a496bb1f38b3e3479ce462fc1f7426 /crates/ra_mbe/src/tt_cursor.rs
parentfcbd0269545f2b6687a64a868654c74f876b7851 (diff)
parent6646d49f238bb92d55fcb4900830f19faa2994a5 (diff)
Merge #1138
1138: Add L_DOLLAR and R_DOLLAR r=matklad a=edwin0cheng As discussion in issue https://github.com/rust-analyzer/rust-analyzer/issues/1132 and PR #1125 , this PR add 2 `Syntax::Kind` : `L_DOLLAR` and `R_DOLLAR` for representing `Delimiter::None` in mbe and proc_marco. By design, It should not affect the final syntax tree, and will be discard in `TreeSink`. My original idea is handling these 2 tokens case by case, but i found that they will appear in every place in the parser (imagine `tt` matcher). So this PR only handle it in `Parser::do_bump` and `Parser::start`, although It will not fix the `expr` matcher executing order problem in original idea. Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_mbe/src/tt_cursor.rs')
-rw-r--r--crates/ra_mbe/src/tt_cursor.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/tt_cursor.rs b/crates/ra_mbe/src/tt_cursor.rs
index d29faa77c..f6cefe087 100644
--- a/crates/ra_mbe/src/tt_cursor.rs
+++ b/crates/ra_mbe/src/tt_cursor.rs
@@ -84,6 +84,21 @@ impl<'a> TtCursor<'a> {
84 parser.parse_path() 84 parser.parse_path()
85 } 85 }
86 86
87 pub(crate) fn eat_expr(&mut self) -> Option<tt::TokenTree> {
88 let parser = Parser::new(&mut self.pos, self.subtree);
89 parser.parse_expr()
90 }
91
92 pub(crate) fn eat_ty(&mut self) -> Option<tt::TokenTree> {
93 let parser = Parser::new(&mut self.pos, self.subtree);
94 parser.parse_ty()
95 }
96
97 pub(crate) fn eat_pat(&mut self) -> Option<tt::TokenTree> {
98 let parser = Parser::new(&mut self.pos, self.subtree);
99 parser.parse_pat()
100 }
101
87 pub(crate) fn expect_char(&mut self, char: char) -> Result<(), ParseError> { 102 pub(crate) fn expect_char(&mut self, char: char) -> Result<(), ParseError> {
88 if self.at_char(char) { 103 if self.at_char(char) {
89 self.bump(); 104 self.bump();