diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-11-03 10:44:25 +0000 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-11-03 23:48:24 +0000 |
| commit | 7ae083383d1a88f1d76e51297a88c2a423aaa3d1 (patch) | |
| tree | 8fd511c7f7531dc1c2bf4fcdb12b33689ffb1f7e /src/libsyntax/parse/parser.rs | |
| parent | e2b3fec778453d06be6a07494eeaa66da57e4f82 (diff) | |
| download | rust-7ae083383d1a88f1d76e51297a88c2a423aaa3d1.tar.gz rust-7ae083383d1a88f1d76e51297a88c2a423aaa3d1.zip | |
Move doc comment desugaring into the parser.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 93ab09c89ab..e5bbeb3c648 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -211,6 +211,7 @@ pub struct Parser<'a> { pub root_module_name: Option<String>, pub expected_tokens: Vec<TokenType>, pub tts: Vec<(TokenTree, usize)>, + pub desugar_doc_comments: bool, } #[derive(PartialEq, Eq, Clone)] @@ -275,6 +276,11 @@ impl From<P<Expr>> for LhsExpr { impl<'a> Parser<'a> { pub fn new(sess: &'a ParseSess, rdr: Box<Reader+'a>) -> Self { + Parser::new_with_doc_flag(sess, rdr, false) + } + + pub fn new_with_doc_flag(sess: &'a ParseSess, rdr: Box<Reader+'a>, desugar_doc_comments: bool) + -> Self { let mut parser = Parser { reader: rdr, sess: sess, @@ -294,6 +300,7 @@ impl<'a> Parser<'a> { root_module_name: None, expected_tokens: Vec::new(), tts: Vec::new(), + desugar_doc_comments: desugar_doc_comments, }; let tok = parser.next_tok(); @@ -326,6 +333,10 @@ impl<'a> Parser<'a> { loop { let nt = match tok.tok { token::Interpolated(ref nt) => nt.clone(), + token::DocComment(name) if self.desugar_doc_comments => { + self.tts.push((TokenTree::Token(tok.sp, token::DocComment(name)), 0)); + continue 'outer + } _ => return tok, }; match *nt { |
