diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-03-22 14:39:34 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-03-30 16:48:26 +0200 |
commit | 439c05ae3a8563a49cdf292f1ca0a84c0b43eb58 (patch) | |
tree | 653f391677ed67579eeaaa6cbbc1f85f917ae833 /gcc/rust/ast/rust-ast-tokenstream.cc | |
parent | f0ed95a8b9758e172e5e3e945a393b6295037507 (diff) | |
download | gcc-439c05ae3a8563a49cdf292f1ca0a84c0b43eb58.zip gcc-439c05ae3a8563a49cdf292f1ca0a84c0b43eb58.tar.gz gcc-439c05ae3a8563a49cdf292f1ca0a84c0b43eb58.tar.bz2 |
ast: Add trailing comma formatting option
Add an option to output trailing commas depending on the configuration
of the TokenStream.
gcc/rust/ChangeLog:
* ast/rust-ast-tokenstream.cc (TokenStream::trailing_comma):
Output a trailing comma to the token stream according to the
configuration.
* ast/rust-ast-tokenstream.h: Add function prototype.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/ast/rust-ast-tokenstream.cc')
-rw-r--r-- | gcc/rust/ast/rust-ast-tokenstream.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast-tokenstream.cc b/gcc/rust/ast/rust-ast-tokenstream.cc index a7fee13..d68c19a 100644 --- a/gcc/rust/ast/rust-ast-tokenstream.cc +++ b/gcc/rust/ast/rust-ast-tokenstream.cc @@ -93,6 +93,15 @@ TokenStream::visit_items_as_block (T &collection, } void +TokenStream::trailing_comma () +{ + if (output_trailing_commas) + { + tokens.push_back (Rust::Token::make (COMMA, Location ())); + } +} + +void TokenStream::visit (FunctionParam ¶m) { visit (param.get_pattern ()); |