]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: ast: Add TokenStream collect function
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Fri, 24 Mar 2023 11:39:48 +0000 (12:39 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:28:41 +0000 (18:28 +0100)
Add a function to TokenStream to collect in a single vector all tokens.

gcc/rust/ChangeLog:

* ast/rust-ast-tokenstream.cc (TokenStream::collect_tokens): Add
getter.
(TokenStream::go): Rename function.
(TokenStream::visit): Likewise.
* ast/rust-ast-tokenstream.h: Add collect prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-ast-tokenstream.cc
gcc/rust/ast/rust-ast-tokenstream.h

index bbc01a274eef12729f69cd5132b6a96cfd31d650..95ded2481ae3e20cd796559fb56b8b13375bb5ea 100644 (file)
 
 namespace Rust {
 namespace AST {
+
+std::vector<TokenPtr>
+TokenStream::collect_tokens () const
+{
+  return tokens;
+}
+
 void
-TokenStream::go (AST::Crate &crate)
+TokenStream::visit (AST::Crate &crate)
 {
   visit_items_as_lines (crate.items);
 }
 
 void
-TokenStream::go (AST::Item &item)
+TokenStream::visit (AST::Item &item)
 {
   item.accept_vis (*this);
 }
index 29be91eb1d94be677413ac6877821a097876a3f2..e5803350bba9bbb0e3c35132ec626ee8e7ff8376 100644 (file)
@@ -33,8 +33,10 @@ public:
   TokenStream (std::vector<TokenPtr> &container);
   bool output_trailing_commas = false;
 
-  void go (AST::Crate &crate);
-  void go (AST::Item &item);
+  void visit (AST::Crate &crate);
+  void visit (AST::Item &item);
+
+  std::vector<TokenPtr> collect_tokens () const;
 
 private:
   std::vector<TokenPtr> &tokens;