diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-03-23 16:45:35 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-03-30 16:48:27 +0200 |
commit | c34e05d01cfb3ffd5f2adb51eb6ab4d40aa3330f (patch) | |
tree | a45b716419600b27a3c4e8d2433f7ec5a945e00a | |
parent | 2ca2aaeae07d8187f297008fe19e6306919d39fc (diff) | |
download | gcc-c34e05d01cfb3ffd5f2adb51eb6ab4d40aa3330f.zip gcc-c34e05d01cfb3ffd5f2adb51eb6ab4d40aa3330f.tar.gz gcc-c34e05d01cfb3ffd5f2adb51eb6ab4d40aa3330f.tar.bz2 |
ast: Add ExternCrate TokenStream visitor
Add a visitor implementation for ExternCrate declarations.
gcc/rust/ChangeLog:
* ast/rust-ast-tokenstream.cc (TokenStream::visit): Add visitor.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r-- | gcc/rust/ast/rust-ast-tokenstream.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/gcc/rust/ast/rust-ast-tokenstream.cc b/gcc/rust/ast/rust-ast-tokenstream.cc index 8dae3e5..f5d0445 100644 --- a/gcc/rust/ast/rust-ast-tokenstream.cc +++ b/gcc/rust/ast/rust-ast-tokenstream.cc @@ -1568,8 +1568,22 @@ TokenStream::visit (Module &module) } void -TokenStream::visit (ExternCrate &) -{} +TokenStream::visit (ExternCrate &crate) +{ + tokens.push_back (Rust::Token::make (EXTERN_TOK, crate.get_locus ())); + tokens.push_back (Rust::Token::make (CRATE, Location ())); + auto ref = crate.get_referenced_crate (); + tokens.push_back ( + Rust::Token::make_identifier (Location (), std::move (ref))); + if (crate.has_as_clause ()) + { + auto as_clause = crate.get_as_clause (); + tokens.push_back (Rust::Token::make (AS, Location ())); + tokens.push_back ( + Rust::Token::make_identifier (Location (), std::move (as_clause))); + } + tokens.push_back (Rust::Token::make (SEMICOLON, Location ())); +} void TokenStream::visit (UseTreeGlob &) |