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>
tokens.push_back (Rust::Token::make (right_brace, Location ()));
}
+void
+TokenStream::trailing_comma ()
+{
+ if (output_trailing_commas)
+ {
+ tokens.push_back (Rust::Token::make (COMMA, Location ()));
+ }
+}
+
void
TokenStream::visit (FunctionParam ¶m)
{
{
public:
TokenStream (std::vector<TokenPtr> &container);
+ bool output_trailing_commas = false;
void go (AST::Crate &crate);
void go (AST::Item &item);
TokenId left_brace = LEFT_CURLY,
TokenId right_brace = RIGHT_CURLY);
+ void trailing_comma ();
/**
* Visit common items of functions: Parameters, return type, block
*/