public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] libproc_macro: Add Group type interface
@ 2023-04-06 21:30 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-04-06 21:30 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:44a0fd574f00070d5dd1ec3f5cfbd39c0791ca57
commit 44a0fd574f00070d5dd1ec3f5cfbd39c0791ca57
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Mon Feb 13 14:15:38 2023 +0100
libproc_macro: Add Group type interface
Add the Group rust type interface to libproc_macro.
ChangeLog:
* librust/proc_macro/rust/lib.rs: Add group module.
* librust/proc_macro/rust/group.rs: Add rust Group type.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diff:
---
librust/proc_macro/rust/group.rs | 76 ++++++++++++++++++++++++++++++++++++++++
librust/proc_macro/rust/lib.rs | 4 ++-
2 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/librust/proc_macro/rust/group.rs b/librust/proc_macro/rust/group.rs
new file mode 100644
index 00000000000..0434d6c1206
--- /dev/null
+++ b/librust/proc_macro/rust/group.rs
@@ -0,0 +1,76 @@
+use std::fmt;
+use Delimiter;
+use Span;
+use TokenStream;
+
+/// A delimited token stream.
+#[derive(Clone)]
+pub struct Group {
+ // Internal implementation details
+}
+
+impl Group {
+ /// Creates a new `Group`.
+ ///
+ /// # Arguments
+ ///
+ /// * `delimiter` - The delimiter surrounding the inner [`TokenStream`].
+ /// * `stream` - The tokenstream for this `Group`.
+ pub fn new(_delimiter: Delimiter, _stream: TokenStream) -> Self {
+ todo!("Implement this function")
+ }
+
+ /// Get the delimiter of the `Group`.
+ pub fn delimiter(&self) -> Delimiter {
+ todo!("Implement this function")
+ }
+
+ /// Get the stream of the `Group`.
+ ///
+ /// # Note
+ ///
+ /// The returned stream does not include the delimiters of this group.
+ pub fn stream(&self) -> TokenStream {
+ todo!("Implement this function")
+ }
+
+ /// Get the span for the delimiters of this token stream, spanning the
+ /// entire group.
+ pub fn span(&self) -> Span {
+ todo!("Implement this function")
+ }
+
+ /// Get the span pointing to the opening delimiter of this `Group`.
+ pub fn span_open(&self) -> Span {
+ todo!("Implement this function")
+ }
+
+ /// Get the span pointing to the closing delimiter of this `Group`.
+ pub fn span_close(&self) -> Span {
+ todo!("Implement this function")
+ }
+
+ /// Change the span for this `Group`'s delimiters, but not its internal
+ /// tokens.
+ ///
+ /// # Note
+ ///
+ /// This method will **not** set the span of all the internal tokens spanned
+ /// by this group, but rather it will only set the span of the delimiter
+ /// tokens at the level of the `Group`.
+ pub fn set_span(&mut self, _span: Span) {
+ todo!("Implement this function")
+ }
+}
+
+impl fmt::Display for Group {
+ fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ todo!("Implement this function")
+ }
+}
+
+impl fmt::Debug for Group {
+ fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ todo!("Implement this function")
+ }
+}
diff --git a/librust/proc_macro/rust/lib.rs b/librust/proc_macro/rust/lib.rs
index f270b79c9dc..26011f8a724 100644
--- a/librust/proc_macro/rust/lib.rs
+++ b/librust/proc_macro/rust/lib.rs
@@ -1,3 +1,4 @@
+pub use group::Group;
pub use ident::Ident;
pub use literal::Literal;
pub use punct::{Punct, Spacing};
@@ -5,6 +6,7 @@ pub use span::Span;
use std::error;
use std::{fmt, str::FromStr};
+mod group;
mod ident;
mod literal;
mod punct;
@@ -13,7 +15,7 @@ mod span;
/// Describes how a sequence of token trees is delimited.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Delimiter {
- /// The sequence is delimited by a parentheses `(...)`.
+ /// The sequence is delimited by a parenthesis `(...)`.
Parenthesis,
/// The sequence is delimited by a brace `{...}`.
Brace,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-06 21:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 21:30 [gcc/devel/rust/master] libproc_macro: Add Group type interface Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).