]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Use MacroInvocLexerBase in ProcMacroInvocLexer
authorOwen Avery <powerboat9.gamer@gmail.com>
Fri, 30 Jun 2023 01:37:33 +0000 (21:37 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:00:30 +0000 (19:00 +0100)
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>
gcc/rust/expand/rust-proc-macro-invoc-lexer.cc
gcc/rust/expand/rust-proc-macro-invoc-lexer.h

index d9164179d30bb6735af2fb6efd0c73313731a4cc..5990dec4325b7bac50c194c6d1d74136169bed33 100644 (file)
@@ -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)
 {
index b1bae3e3778dba22d6f2f730196fd997063246e1..5a11a4c111c198851097b208cd12c8bde40d6a94 100644 (file)
 #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