[gcc r14-7913] gccrs: Use MacroInvocLexerBase in ProcMacroInvocLexer

Arthur Cohen cohenarthur@gcc.gnu.org
Tue Jan 16 18:06:49 GMT 2024


https://gcc.gnu.org/g:ce40be7683b18f1162232a48f970946c891dd960

commit r14-7913-gce40be7683b18f1162232a48f970946c891dd960
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date:   Thu Jun 29 21:37:33 2023 -0400

    gccrs: Use MacroInvocLexerBase in ProcMacroInvocLexer
    
    gcc/rust/ChangeLog:
    
            * expand/rust-proc-macro-invoc-lexer.cc
            (ProcMacroInvocLexer::skip_token): Remove.
            * expand/rust-proc-macro-invoc-lexer.h:
            Include "rust-macro-invoc-lexer.h".
            (class ProcMacroInvocLexer):
            Extend MacroInvocLexerBase.
    
    Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>

Diff:
---
 gcc/rust/expand/rust-proc-macro-invoc-lexer.cc |  7 -------
 gcc/rust/expand/rust-proc-macro-invoc-lexer.h  | 24 +++---------------------
 2 files changed, 3 insertions(+), 28 deletions(-)

diff --git a/gcc/rust/expand/rust-proc-macro-invoc-lexer.cc b/gcc/rust/expand/rust-proc-macro-invoc-lexer.cc
index d9164179d30..5990dec4325 100644
--- a/gcc/rust/expand/rust-proc-macro-invoc-lexer.cc
+++ b/gcc/rust/expand/rust-proc-macro-invoc-lexer.cc
@@ -30,13 +30,6 @@ ProcMacroInvocLexer::peek_token (int n)
   return token_stream.at (offs + n);
 }
 
-// Advances current token to n + 1 tokens ahead of current position.
-void
-ProcMacroInvocLexer::skip_token (int n)
-{
-  offs += (n + 1);
-}
-
 void
 ProcMacroInvocLexer::split_current_token (TokenId new_left, TokenId new_right)
 {
diff --git a/gcc/rust/expand/rust-proc-macro-invoc-lexer.h b/gcc/rust/expand/rust-proc-macro-invoc-lexer.h
index b1bae3e3778..5a11a4c111c 100644
--- a/gcc/rust/expand/rust-proc-macro-invoc-lexer.h
+++ b/gcc/rust/expand/rust-proc-macro-invoc-lexer.h
@@ -20,13 +20,14 @@
 #define RUST_PROC_MACRO_INVOC_LEXER_H
 
 #include "rust-lex.h"
+#include "rust-macro-invoc-lexer.h"
 
 namespace Rust {
-class ProcMacroInvocLexer
+class ProcMacroInvocLexer : public MacroInvocLexerBase<const_TokenPtr>
 {
 public:
   ProcMacroInvocLexer (std::vector<const_TokenPtr> stream)
-    : offs (0), token_stream (std::move (stream))
+    : MacroInvocLexerBase (std::move (stream))
   {}
 
   // Returns token n tokens ahead of current position.
@@ -35,29 +36,10 @@ public:
   // Peeks the current token.
   const_TokenPtr peek_token () { return peek_token (0); }
 
-  // Advances current token to n + 1 tokens ahead of current position.
-  void skip_token (int n);
-
-  // Skips the current token.
-  void skip_token () { skip_token (0); }
-
   // Splits the current token into two. Intended for use with nested generics
   // closes (i.e. T<U<X>> where >> is wrongly lexed as one token). Note that
   // this will only work with "simple" tokens like punctuation.
   void split_current_token (TokenId new_left, TokenId new_right);
-
-  std::string get_filename () const
-  {
-    // FIXME
-    rust_unreachable ();
-    return "FIXME";
-  }
-
-  size_t get_offs () const { return offs; }
-
-private:
-  size_t offs;
-  std::vector<const_TokenPtr> token_stream;
 };
 } // namespace Rust


More information about the Gcc-cvs mailing list