Adds a ProcMacro form of syntax extension

This commit adds syntax extension forms matching the types for procedural macros 2.0 (RFC #1566), these still require the usual syntax extension boiler plate, but this is a first step towards proper implementation and should be useful for macros 1.1 stuff too.

Supports both attribute-like and function-like macros.
This commit is contained in:
Nick Cameron
2016-08-29 16:16:43 +12:00
parent c772948b68
commit 6a2d2c9495
9 changed files with 422 additions and 18 deletions

View File

@@ -33,6 +33,7 @@ use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
use parse::lexer;
use parse;
use parse::token::{self, Token, Lit, Nonterminal};
use print::pprust;
use std::fmt;
use std::iter::*;
@@ -781,6 +782,12 @@ impl TokenStream {
}
}
impl fmt::Display for TokenStream {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(&pprust::tts_to_string(&self.to_tts()))
}
}
// FIXME Reimplement this iterator to hold onto a slice iterator for a leaf, getting the
// next leaf's iterator when the current one is exhausted.
pub struct Iter<'a> {