diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-02-13 12:45:44 +0100 |
---|---|---|
committer | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-03-30 13:52:29 +0200 |
commit | 5640374631e9e9ee315e98aeb20b18818285e8ec (patch) | |
tree | ea8ae6941f11689b473e79c937a1ec628062cfdb | |
parent | a4b7fca1ec1d2a1b9f416cbefc7a2dcd6f3935f3 (diff) | |
download | gcc-5640374631e9e9ee315e98aeb20b18818285e8ec.zip gcc-5640374631e9e9ee315e98aeb20b18818285e8ec.tar.gz gcc-5640374631e9e9ee315e98aeb20b18818285e8ec.tar.bz2 |
libproc_macro: Add TokenStream type interface
Add the TokenStream rust type interface to libproc_macro. Note that the
token_stream module containing the iterator operations implemented on
the TokenStream type is missing.
ChangeLog:
* librust/proc_macro/rust/lib.rs: Add TokenStream type.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r-- | librust/proc_macro/rust/lib.rs | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/librust/proc_macro/rust/lib.rs b/librust/proc_macro/rust/lib.rs index fa1160e..f270b79 100644 --- a/librust/proc_macro/rust/lib.rs +++ b/librust/proc_macro/rust/lib.rs @@ -3,7 +3,7 @@ pub use literal::Literal; pub use punct::{Punct, Spacing}; pub use span::Span; use std::error; -use std::fmt; +use std::{fmt, str::FromStr}; mod ident; mod literal; @@ -34,3 +34,47 @@ impl fmt::Display for LexError { } impl error::Error for LexError {} + +/// An abstract sequence of token trees. +/// +/// This type provides interfaces for iterating over those token trees. This +/// is both the input and the output of `#[proc_macro]`, +/// `#[proc_macro_attribute]` and `#[proc_macro_derive]` definitions. +#[derive(Clone)] +pub struct TokenStream { + // Internal implementation details +} + +impl TokenStream { + // TODO: Add experimental API functions for this type + + /// Creates an empty `TokenStream` containing no token trees. + pub fn new() -> Self { + todo!("Implement this function") + } + + /// Checks if this `TokenStream` is empty. + pub fn is_empty(&self) -> bool { + todo!("Implement this function") + } +} + +impl fmt::Display for TokenStream { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { + todo!("Implement this function") + } +} + +impl fmt::Debug for TokenStream { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { + todo!("Implement this function") + } +} + +impl FromStr for TokenStream { + type Err = LexError; + + fn from_str(_src: &str) -> Result<Self, LexError> { + todo!("Implement this function") + } +} |