diff options
Diffstat (limited to 'gcc/rust/ast/rust-ast-fragment.h')
-rw-r--r-- | gcc/rust/ast/rust-ast-fragment.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/gcc/rust/ast/rust-ast-fragment.h b/gcc/rust/ast/rust-ast-fragment.h index 3ef4ba1..22e9909 100644 --- a/gcc/rust/ast/rust-ast-fragment.h +++ b/gcc/rust/ast/rust-ast-fragment.h @@ -28,11 +28,6 @@ namespace AST { enum class FragmentKind { /** - * If an AST Fragment still contains unexpanded tokens - this should only be - * used in the case of builtin macros which need to be expanded eagerly. - */ - Unexpanded, - /** * A completely expanded AST Fragment. This signifies that all * `SingleASTNode`s in the `nodes` vector are valid. * @@ -68,15 +63,18 @@ public: /** * Create a complete AST fragment */ - static Fragment complete (std::vector<AST::SingleASTNode> nodes); + Fragment (std::vector<AST::SingleASTNode> nodes, + std::vector<std::unique_ptr<AST::Token>> tokens); /** - * Create a fragment which contains unexpanded nodes + * Create a complete AST fragment made of a single token */ - static Fragment unexpanded (); + Fragment (std::vector<AST::SingleASTNode> nodes, + std::unique_ptr<AST::Token> tok); FragmentKind get_kind () const; std::vector<SingleASTNode> &get_nodes (); + std::vector<std::unique_ptr<AST::Token>> &get_tokens (); bool is_error () const; bool should_expand () const; @@ -90,7 +88,8 @@ public: void accept_vis (ASTVisitor &vis); private: - Fragment (FragmentKind kind, std::vector<SingleASTNode> nodes); + Fragment (FragmentKind kind, std::vector<SingleASTNode> nodes, + std::vector<std::unique_ptr<AST::Token>> tokens); FragmentKind kind; @@ -105,6 +104,12 @@ private: std::vector<SingleASTNode> nodes; /** + * The tokens associated with an AST fragment. This vector represents the + * actual tokens of the various nodes that are part of the fragment. + */ + std::vector<std::unique_ptr<AST::Token>> tokens; + + /** * We need to make a special case for Expression and Type fragments as only * one Node will be extracted from the `nodes` vector */ |