diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-02-17 13:23:18 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-02-17 13:28:25 +0000 |
commit | 4c70d7ec770d226bf9ad59b4f03897f6fb10df15 (patch) | |
tree | 8b7516086e531504e04ad03420af4668be0b29ee /gcc/rust/parse/rust-parse-impl.h | |
parent | 19c5dde80f28c67f657775f770922783faff4b89 (diff) | |
download | gcc-4c70d7ec770d226bf9ad59b4f03897f6fb10df15.zip gcc-4c70d7ec770d226bf9ad59b4f03897f6fb10df15.tar.gz gcc-4c70d7ec770d226bf9ad59b4f03897f6fb10df15.tar.bz2 |
Support block expressions within macros
When we parse DelimTokenTree's the delimiter's are synthesised when we
ask for the token stream which results in tokens lacking location info.
This removes the hack by adding the actual tokens from the lexer into the
stream.
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 7483818..2ea42c7 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -905,6 +905,9 @@ Parser<ManagedTokenSource>::parse_delim_token_tree () // parse actual token tree vector - 0 or more std::vector<std::unique_ptr<AST::TokenTree>> token_trees_in_tree; + auto delim_open + = std::unique_ptr<AST::Token> (new AST::Token (std::move (t))); + token_trees_in_tree.push_back (std::move (delim_open)); // repeat loop until finding the matching delimiter t = lexer.peek_token (); @@ -929,6 +932,9 @@ Parser<ManagedTokenSource>::parse_delim_token_tree () // lexer.skip_token(); t = lexer.peek_token (); } + auto delim_close + = std::unique_ptr<AST::Token> (new AST::Token (std::move (t))); + token_trees_in_tree.push_back (std::move (delim_close)); AST::DelimTokenTree token_tree (delim_type, std::move (token_trees_in_tree), initial_loc); |