aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-06-29 21:28:23 -0400
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:56:04 +0100
commitc016d443b814a49fa1f91a08bed12577885f40d9 (patch)
tree2e50ce786d1a02d345067bd3a2010eb8b7403cb5 /gcc
parent58b49a65a3f91f0f6643dc973f46911363148c16 (diff)
downloadgcc-c016d443b814a49fa1f91a08bed12577885f40d9.zip
gcc-c016d443b814a49fa1f91a08bed12577885f40d9.tar.gz
gcc-c016d443b814a49fa1f91a08bed12577885f40d9.tar.bz2
gccrs: Use MacroInvocLexerBase in MacroInvocLexer
gcc/rust/ChangeLog: * expand/rust-macro-invoc-lexer.cc (MacroInvocLexer::skip_token): Remove. * expand/rust-macro-invoc-lexer.h (class MacroInvocLexer): Extend MacroInvocLexerBase. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/expand/rust-macro-invoc-lexer.cc7
-rw-r--r--gcc/rust/expand/rust-macro-invoc-lexer.h23
2 files changed, 2 insertions, 28 deletions
diff --git a/gcc/rust/expand/rust-macro-invoc-lexer.cc b/gcc/rust/expand/rust-macro-invoc-lexer.cc
index db1471e..aa1e1ff 100644
--- a/gcc/rust/expand/rust-macro-invoc-lexer.cc
+++ b/gcc/rust/expand/rust-macro-invoc-lexer.cc
@@ -30,13 +30,6 @@ MacroInvocLexer::peek_token (int n)
return token_stream.at (offs + n)->get_tok_ptr ();
}
-// Advances current token to n + 1 tokens ahead of current position.
-void
-MacroInvocLexer::skip_token (int n)
-{
- offs += (n + 1);
-}
-
void
MacroInvocLexer::split_current_token (TokenId new_left, TokenId new_right)
{
diff --git a/gcc/rust/expand/rust-macro-invoc-lexer.h b/gcc/rust/expand/rust-macro-invoc-lexer.h
index c8db892..a65816b 100644
--- a/gcc/rust/expand/rust-macro-invoc-lexer.h
+++ b/gcc/rust/expand/rust-macro-invoc-lexer.h
@@ -49,11 +49,11 @@ protected:
std::vector<T> token_stream;
};
-class MacroInvocLexer
+class MacroInvocLexer : public MacroInvocLexerBase<std::unique_ptr<AST::Token>>
{
public:
MacroInvocLexer (std::vector<std::unique_ptr<AST::Token>> stream)
- : offs (0), token_stream (std::move (stream))
+ : MacroInvocLexerBase (std::move (stream))
{}
// Returns token n tokens ahead of current position.
@@ -62,32 +62,13 @@ 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; }
-
std::vector<std::unique_ptr<AST::Token>>
get_token_slice (size_t start_idx, size_t end_idx) const;
-
-private:
- size_t offs;
- std::vector<std::unique_ptr<AST::Token>> token_stream;
};
} // namespace Rust