diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-02-13 15:33:11 +0100 |
---|---|---|
committer | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-03-30 13:52:29 +0200 |
commit | fc8a92c4874730b193fbd78140a4b5486ffce752 (patch) | |
tree | 2b246f3af85fe26608109ae359e865ea5a51ac9a | |
parent | e59c6f19aa7c4b6d7090d7af23fb407c2fc397ef (diff) | |
download | gcc-fc8a92c4874730b193fbd78140a4b5486ffce752.zip gcc-fc8a92c4874730b193fbd78140a4b5486ffce752.tar.gz gcc-fc8a92c4874730b193fbd78140a4b5486ffce752.tar.bz2 |
libproc_macro: Add TokenTree type interface
Add TokenTree rust type interface to libproc_macro.
ChangeLog:
* librust/proc_macro/rust/lib.rs: Add TokenTree type.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r-- | librust/proc_macro/rust/lib.rs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/librust/proc_macro/rust/lib.rs b/librust/proc_macro/rust/lib.rs index bdafacf..4b6272d 100644 --- a/librust/proc_macro/rust/lib.rs +++ b/librust/proc_macro/rust/lib.rs @@ -12,6 +12,67 @@ mod literal; mod punct; mod span; +/// A single token or a delimited sequence of token trees. +#[derive(Clone)] +pub enum TokenTree { + Group(Group), + Ident(Ident), + Punct(Punct), + Literal(Literal), +} + +impl TokenTree { + /// Get the [`Span`] for this TokenTree. + pub fn span(&self) -> Span { + todo!("Implement this function") + } + + /// Set the span for this TokenTree. + /// + /// # Arguments + /// + /// * `span` - The new span value. + pub fn set_span(&mut self, _span: Span) { + todo!("Implement this function") + } +} + +impl fmt::Debug for TokenTree { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { + todo!("Implement this function") + } +} + +impl fmt::Display for TokenTree { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { + todo!("Implement this function") + } +} + +impl From<Group> for TokenTree { + fn from(_g: Group) -> Self { + todo!("Implement this function") + } +} + +impl From<Ident> for TokenTree { + fn from(_i: Ident) -> Self { + todo!("Implement this function") + } +} + +impl From<Punct> for TokenTree { + fn from(_p: Punct) -> Self { + todo!("Implement this function") + } +} + +impl From<Literal> for TokenTree { + fn from(_l: Literal) -> Self { + todo!("Implement this function") + } +} + /// Error returned from `from_str` functions. #[derive(Debug)] pub struct LexError; |