diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-02-17 15:26:35 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-02-17 16:41:15 +0000 |
commit | 37415eec77438bba2fc61df3e9a396c1e2cbaca8 (patch) | |
tree | d8ed1ea0d957afd906556ae89e8622f79c4690f1 /gcc/rust/parse/rust-parse-impl.h | |
parent | 4c70d7ec770d226bf9ad59b4f03897f6fb10df15 (diff) | |
download | gcc-37415eec77438bba2fc61df3e9a396c1e2cbaca8.zip gcc-37415eec77438bba2fc61df3e9a396c1e2cbaca8.tar.gz gcc-37415eec77438bba2fc61df3e9a396c1e2cbaca8.tar.bz2 |
Semicolon based macro invocation
This allows for macro invocation at the toplevel or as statements. This
patched required us to propogate the delimited token tree fix to include
the delimiter tokens. The rest of the fix was straight forward to call
the apropriate visitors in names resolution and hir lowering.
Some thought will be needed to handle hir lowering for repeating items.
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 2ea42c7..784e6d1 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -1571,6 +1571,9 @@ Parser<ManagedTokenSource>::parse_macro_invocation_semi ( // parse actual token trees std::vector<std::unique_ptr<AST::TokenTree>> token_trees; + auto delim_open + = std::unique_ptr<AST::Token> (new AST::Token (std::move (t))); + token_trees.push_back (std::move (delim_open)); t = lexer.peek_token (); // parse token trees until the initial delimiter token is found again @@ -1593,6 +1596,9 @@ Parser<ManagedTokenSource>::parse_macro_invocation_semi ( t = lexer.peek_token (); } + auto delim_close + = std::unique_ptr<AST::Token> (new AST::Token (std::move (t))); + token_trees.push_back (std::move (delim_close)); AST::DelimTokenTree delim_tok_tree (delim_type, std::move (token_trees), tok_tree_locus); @@ -1611,6 +1617,7 @@ Parser<ManagedTokenSource>::parse_macro_invocation_semi ( if (!skip_token (SEMICOLON)) { // as this is the end, allow recovery (probably) - may change + return std::unique_ptr<AST::MacroInvocationSemi> ( new AST::MacroInvocationSemi (std::move (invoc_data), std::move (outer_attrs), @@ -11761,6 +11768,9 @@ Parser<ManagedTokenSource>::parse_path_based_stmt_or_expr ( // parse actual token trees std::vector<std::unique_ptr<AST::TokenTree>> token_trees; + auto delim_open + = std::unique_ptr<AST::Token> (new AST::Token (std::move (t3))); + token_trees.push_back (std::move (delim_open)); t3 = lexer.peek_token (); // parse token trees until the initial delimiter token is found again @@ -11785,6 +11795,10 @@ Parser<ManagedTokenSource>::parse_path_based_stmt_or_expr ( t3 = lexer.peek_token (); } + auto delim_close + = std::unique_ptr<AST::Token> (new AST::Token (std::move (t3))); + token_trees.push_back (std::move (delim_close)); + // parse end delimiters t3 = lexer.peek_token (); if (token_id_matches_delims (t3->get_id (), type)) @@ -12076,6 +12090,9 @@ Parser<ManagedTokenSource>::parse_macro_invocation_maybe_semi ( // parse actual token trees std::vector<std::unique_ptr<AST::TokenTree>> token_trees; + auto delim_open + = std::unique_ptr<AST::Token> (new AST::Token (std::move (t3))); + token_trees.push_back (std::move (delim_open)); t3 = lexer.peek_token (); // parse token trees until the initial delimiter token is found again @@ -12098,6 +12115,9 @@ Parser<ManagedTokenSource>::parse_macro_invocation_maybe_semi ( t3 = lexer.peek_token (); } + auto delim_close + = std::unique_ptr<AST::Token> (new AST::Token (std::move (t3))); + token_trees.push_back (std::move (delim_close)); // parse end delimiters t3 = lexer.peek_token (); |