xref: /llvm-project/flang/lib/Parser/char-set.cpp (revision b98ad941a40c96c841bceb171725c925500fce6c)
1 //===-- lib/Parser/char-set.cpp -------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "flang/Parser/char-set.h"
10 
11 namespace Fortran::parser {
12 
ToString() const13 std::string SetOfChars::ToString() const {
14   std::string result;
15   SetOfChars set{*this};
16   for (char ch{' '}; !set.empty(); ++ch) {
17     if (set.Has(ch)) {
18       set = set.Difference(ch);
19       result += ch;
20     }
21   }
22   return result;
23 }
24 } // namespace Fortran::parser
25