aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-02-13 10:01:44 +0100
committerPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-03-30 13:52:28 +0200
commitf7152d606c82e2c0b9c57d6c2e8f30ab90214553 (patch)
treec978cc1473927b33d92b4cd3cfc2fb94a5f3e2d5
parent570094e524d9b9205eefc42ab3cbffa52b9653c7 (diff)
downloadgcc-f7152d606c82e2c0b9c57d6c2e8f30ab90214553.zip
gcc-f7152d606c82e2c0b9c57d6c2e8f30ab90214553.tar.gz
gcc-f7152d606c82e2c0b9c57d6c2e8f30ab90214553.tar.bz2
libproc_macro: Add punct type interface
Add the Punct rust type interface for the libproc_macro. ChangeLog: * librust/proc_macro/rust/lib.rs: Add punct module. * librust/proc_macro/rust/punct.rs: Add Punct type. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--librust/proc_macro/rust/lib.rs2
-rw-r--r--librust/proc_macro/rust/punct.rs75
2 files changed, 77 insertions, 0 deletions
diff --git a/librust/proc_macro/rust/lib.rs b/librust/proc_macro/rust/lib.rs
index 8e7e077..1bb8e247 100644
--- a/librust/proc_macro/rust/lib.rs
+++ b/librust/proc_macro/rust/lib.rs
@@ -1,11 +1,13 @@
pub use ident::Ident;
pub use literal::Literal;
+pub use punct::Punct;
pub use span::Span;
use std::error;
use std::fmt;
mod ident;
mod literal;
+mod punct;
mod span;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
diff --git a/librust/proc_macro/rust/punct.rs b/librust/proc_macro/rust/punct.rs
new file mode 100644
index 0000000..1389122
--- /dev/null
+++ b/librust/proc_macro/rust/punct.rs
@@ -0,0 +1,75 @@
+use std::fmt;
+use Spacing;
+use Span;
+
+#[derive(Clone)]
+pub struct Punct {
+ // Internal implementation details.
+}
+
+impl Punct {
+ /// Creates a new [Punct] from a given character and spacing.
+ ///
+ /// # Arguments
+ ///
+ /// * `ch` - The punctuation character.
+ /// * `spacing` - The link between this character and the next one.
+ ///
+ /// # Panics
+ ///
+ /// This function will panic if the `ch` argument is not a valid
+ /// punctuation character allowed by the language.
+ pub fn new(_ch: char, _spacing: Spacing) -> Self {
+ todo!("Implement this function")
+ }
+
+ /// Get the value for this punctuation character as `char`.
+ pub fn as_char(&self) -> char {
+ todo!("Implement this function")
+ }
+
+ /// Get the [`Spacing`] of this punctuation character, indicating whether
+ /// the following character can be combined into a multi-character operator
+ /// or not.
+ pub fn spacing(&self) -> Spacing {
+ todo!("Implement this function")
+ }
+
+ /// Get the [`Span`] for this punctuation character.
+ pub fn span(&self) -> Span {
+ todo!("Implement this function")
+ }
+
+ /// Set the span for this punctuation character.
+ ///
+ /// # Arguments
+ ///
+ /// * `span` - The new span value.
+ pub fn set_span(&mut self, _span: Span) {
+ todo!("Implement this function")
+ }
+}
+
+impl fmt::Display for Punct {
+ fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ todo!("Implement this function")
+ }
+}
+
+impl fmt::Debug for Punct {
+ fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ todo!("Implement this function")
+ }
+}
+
+impl PartialEq<char> for Punct {
+ fn eq(&self, _rhs: &char) -> bool {
+ todo!("Implement this function")
+ }
+}
+
+impl PartialEq<Punct> for char {
+ fn eq(&self, _rhs: &Punct) -> bool {
+ todo!("Implement this function")
+ }
+}