diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-02-21 17:23:48 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-02-21 17:27:56 +0100 |
commit | 4e19c2f792e14c2a047a53c913a73d79f91ff277 (patch) | |
tree | 4d5320a427a276b1588b296ae0aeb42d071cc6bb /gcc/rust/expand/rust-macro-expand.h | |
parent | 796465596faa9fa69ffede1c16d944e6a6e24458 (diff) | |
download | gcc-4e19c2f792e14c2a047a53c913a73d79f91ff277.zip gcc-4e19c2f792e14c2a047a53c913a73d79f91ff277.tar.gz gcc-4e19c2f792e14c2a047a53c913a73d79f91ff277.tar.bz2 |
macro-invoc-lexer: Split implementation in its own file
Diffstat (limited to 'gcc/rust/expand/rust-macro-expand.h')
-rw-r--r-- | gcc/rust/expand/rust-macro-expand.h | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/gcc/rust/expand/rust-macro-expand.h b/gcc/rust/expand/rust-macro-expand.h index d49c775..64bb0b4 100644 --- a/gcc/rust/expand/rust-macro-expand.h +++ b/gcc/rust/expand/rust-macro-expand.h @@ -26,6 +26,7 @@ #include "rust-macro.h" #include "rust-hir-map.h" #include "rust-name-resolver.h" +#include "rust-macro-invoc-lexer.h" // Provides objects and method prototypes for macro expansion @@ -48,52 +49,6 @@ struct ExpansionCfg std::string crate_name = ""; }; -class MacroInvocLexer -{ -public: - MacroInvocLexer (std::vector<std::unique_ptr<AST::Token>> stream) - : offs (0), token_stream (std::move (stream)) - {} - - // Returns token n tokens ahead of current position. - const_TokenPtr peek_token (int n) - { - if ((offs + n) >= token_stream.size ()) - return Token::make (END_OF_FILE, Location ()); - - return token_stream.at (offs + n)->get_tok_ptr (); - } - // 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) { offs += (n + 1); } - - // 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*/) - { - // FIXME - gcc_unreachable (); - } - - std::string get_filename () const - { - gcc_unreachable (); - return "FIXME"; - } - - size_t get_offs () const { return offs; } - -private: - size_t offs; - std::vector<std::unique_ptr<AST::Token>> token_stream; -}; - struct MatchedFragment { std::string fragment_ident; |