From: Owen Avery Date: Fri, 30 Jun 2023 01:37:33 +0000 (-0400) Subject: gccrs: Use MacroInvocLexerBase in ProcMacroInvocLexer X-Git-Tag: basepoints/gcc-15~2226 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce40be7683b18f1162232a48f970946c891dd960;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/rust/expand/rust-proc-macro-invoc-lexer.cc b/gcc/rust/expand/rust-proc-macro-invoc-lexer.cc index d9164179d30b..5990dec4325b 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 b1bae3e3778d..5a11a4c111c1 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 { public: ProcMacroInvocLexer (std::vector 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> 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 token_stream; }; } // namespace Rust