aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-02-13 14:15:38 +0100
committerPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-03-30 13:52:29 +0200
commit44a0fd574f00070d5dd1ec3f5cfbd39c0791ca57 (patch)
tree0a053ed487aed942cd586434311d4a59bc4d8888
parent5640374631e9e9ee315e98aeb20b18818285e8ec (diff)
downloadgcc-44a0fd574f00070d5dd1ec3f5cfbd39c0791ca57.zip
gcc-44a0fd574f00070d5dd1ec3f5cfbd39c0791ca57.tar.gz
gcc-44a0fd574f00070d5dd1ec3f5cfbd39c0791ca57.tar.bz2
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>
-rw-r--r--librust/proc_macro/rust/group.rs76
-rw-r--r--librust/proc_macro/rust/lib.rs4
2 files changed, 79 insertions, 1 deletions
diff --git a/librust/proc_macro/rust/group.rs b/librust/proc_macro/rust/group.rs
new file mode 100644
index 0000000..0434d6c
--- /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 f270b79..26011f8 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,