aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-06-29 21:37:33 -0400
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2023-08-11 13:41:52 +0000
commit2691b544983d3729518b4f5c7b4fc9eac48ff21c (patch)
tree21e6e85a113f18c53f2f1f2ffcd62b6f6c6e1eb2
parent2b1d37ced31362a6212ebd8f04883d7e4cf28e05 (diff)
downloadgcc-2691b544983d3729518b4f5c7b4fc9eac48ff21c.zip
gcc-2691b544983d3729518b4f5c7b4fc9eac48ff21c.tar.gz
gcc-2691b544983d3729518b4f5c7b4fc9eac48ff21c.tar.bz2
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>
-rw-r--r--gcc/rust/expand/rust-proc-macro-invoc-lexer.cc7
-rw-r--r--gcc/rust/expand/rust-proc-macro-invoc-lexer.h24
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 d916417..5990dec 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 b1bae3e..5a11a4c 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