diff options
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/expand/rust-macro-invoc-lexer.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/rust/expand/rust-macro-invoc-lexer.cc b/gcc/rust/expand/rust-macro-invoc-lexer.cc index 321f0f9..66a3a69 100644 --- a/gcc/rust/expand/rust-macro-invoc-lexer.cc +++ b/gcc/rust/expand/rust-macro-invoc-lexer.cc @@ -1,4 +1,5 @@ #include "rust-macro-invoc-lexer.h" +#include "rust-token.h" namespace Rust { @@ -19,12 +20,22 @@ MacroInvocLexer::skip_token (int n) } void -MacroInvocLexer::split_current_token (TokenId new_left __attribute__ ((unused)), - TokenId new_right - __attribute__ ((unused))) +MacroInvocLexer::split_current_token (TokenId new_left, TokenId new_right) { - // FIXME - gcc_unreachable (); + auto ¤t_token = token_stream.at (offs); + auto current_pos = token_stream.begin () + offs; + + auto l_tok = Token::make (new_left, current_token->get_locus ()); + auto r_tok = Token::make (new_right, current_token->get_locus ()); + + token_stream.erase (current_pos); + + // `insert` inserts before the specified position, so we insert the right one + // then the left + token_stream.insert (current_pos, + std::unique_ptr<AST::Token> (new AST::Token (r_tok))); + token_stream.insert (current_pos, + std::unique_ptr<AST::Token> (new AST::Token (l_tok))); } std::vector<std::unique_ptr<AST::Token>> |