diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-02-21 10:48:00 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-02-22 12:05:58 +0100 |
commit | 143aad62e16ea96e8c562b96857c2497f74ba7c7 (patch) | |
tree | 7ed8c0d23acc92be08d775ed9512b848f7f3149b /gcc/rust/expand/rust-macro-expand.h | |
parent | ae1f91a698022a5600a2d54e48fc90895ea834fd (diff) | |
download | gcc-143aad62e16ea96e8c562b96857c2497f74ba7c7.zip gcc-143aad62e16ea96e8c562b96857c2497f74ba7c7.tar.gz gcc-143aad62e16ea96e8c562b96857c2497f74ba7c7.tar.bz2 |
substitute_repetition: Add parsing of repetition pattern
Diffstat (limited to 'gcc/rust/expand/rust-macro-expand.h')
-rw-r--r-- | gcc/rust/expand/rust-macro-expand.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/gcc/rust/expand/rust-macro-expand.h b/gcc/rust/expand/rust-macro-expand.h index f77acc7..943115d 100644 --- a/gcc/rust/expand/rust-macro-expand.h +++ b/gcc/rust/expand/rust-macro-expand.h @@ -200,8 +200,23 @@ struct MacroExpander std::unique_ptr<AST::Token> &metavar); /** + * Substitute a macro repetition by its given fragments + * + * @param input Tokens given to the transcribing context + * @param fragments Fragments given to the macro substitution + * @param repetition Set of tokens to substitute and replace + * + * @return A vector containing the repeated pattern + */ + static std::vector<std::unique_ptr<AST::Token>> + substitute_repetition (std::vector<std::unique_ptr<AST::Token>> &input, + std::map<std::string, MatchedFragment> &fragments, + std::vector<std::unique_ptr<AST::Token>> &pattern); + + /** * Substitute a given token by its appropriate representation * + * @param macro Tokens used in the macro declaration * @param input Tokens given to the transcribing context * @param fragments Fragments given to the macro substitution * @param token Current token to try and substitute @@ -213,9 +228,10 @@ struct MacroExpander * ahead of the input to avoid mis-substitutions */ static std::pair<std::vector<std::unique_ptr<AST::Token>>, size_t> - substitute_token (std::vector<std::unique_ptr<AST::Token>> &input, + substitute_token (std::vector<std::unique_ptr<AST::Token>> ¯o, + std::vector<std::unique_ptr<AST::Token>> &input, std::map<std::string, MatchedFragment> &fragments, - std::unique_ptr<AST::Token> &token); + size_t token_idx); static std::vector<std::unique_ptr<AST::Token>> substitute_tokens (std::vector<std::unique_ptr<AST::Token>> &input, |