]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Create MacroInvocLexerBase
authorOwen Avery <powerboat9.gamer@gmail.com>
Fri, 30 Jun 2023 01:23:03 +0000 (21:23 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:49:32 +0000 (18:49 +0100)
gcc/rust/ChangeLog:

* expand/rust-macro-invoc-lexer.h
(class MacroInvocLexerBase): New.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/expand/rust-macro-invoc-lexer.h

index ba13385b486b8709a15efd09568dee6ab498346d..4ea31d7bdde32a0df0375ba013a786c1f704a17e 100644 (file)
 #include "rust-ast.h"
 
 namespace Rust {
+template <class T> class MacroInvocLexerBase
+{
+public:
+  MacroInvocLexerBase (std::vector<T> stream)
+    : offs (0), token_stream (std::move (stream))
+  {}
+
+  // Advances current token to n + 1 tokens ahead of current position.
+  void skip_token (int n) { offs += (n + 1); }
+
+  // Skips the current token.
+  void skip_token () { skip_token (0); }
+
+  std::string get_filename () const
+  {
+    // FIXME
+    gcc_unreachable ();
+    return "FIXME";
+  }
+
+  size_t get_offs () const { return offs; }
+
+protected:
+  size_t offs;
+  std::vector<T> token_stream;
+};
+
 class MacroInvocLexer
 {
 public: