public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] ast: Add TokenStream collect function
@ 2023-04-06 21:35 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-04-06 21:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1bc503fe37d24aab6cab0df0a427cb1793c084e8
commit 1bc503fe37d24aab6cab0df0a427cb1793c084e8
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Fri Mar 24 12:39:48 2023 +0100
ast: Add TokenStream collect function
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>
Diff:
---
gcc/rust/ast/rust-ast-tokenstream.cc | 11 +++++++++--
gcc/rust/ast/rust-ast-tokenstream.h | 6 ++++--
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/gcc/rust/ast/rust-ast-tokenstream.cc b/gcc/rust/ast/rust-ast-tokenstream.cc
index bbc01a274ee..95ded2481ae 100644
--- a/gcc/rust/ast/rust-ast-tokenstream.cc
+++ b/gcc/rust/ast/rust-ast-tokenstream.cc
@@ -19,14 +19,21 @@
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);
}
diff --git a/gcc/rust/ast/rust-ast-tokenstream.h b/gcc/rust/ast/rust-ast-tokenstream.h
index 29be91eb1d9..e5803350bba 100644
--- a/gcc/rust/ast/rust-ast-tokenstream.h
+++ b/gcc/rust/ast/rust-ast-tokenstream.h
@@ -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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-06 21:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 21:35 [gcc/devel/rust/master] ast: Add TokenStream collect function Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).