208 constexpr int minimum_indentation_level { 1 };
209 int indentation_level { minimum_indentation_level };
210 int indentation_width { 4 };
213 while (atom !=
nullptr) {
214 QString str = atom->string();
215 str.replace(
"\\",
"\\\\");
216 str.replace(
"\"",
"\\\"");
217 str.replace(
"\n",
"\\n");
218 static const QRegularExpression re(R"([^ -~])");
219 str.replace(re,
"?");
221 str =
" \"" + str + QLatin1Char(
'"');
223 QString atom_type = atom->typeString();
224 if (atom_type.contains(
"Right"))
225 indentation_level =
std::max(minimum_indentation_level, indentation_level - 1);
227 fprintf(stderr,
"%s%s%s\n",
228 QString(indentation_level * indentation_width,
' ').toLatin1().data(),
229 atom_type.toLatin1().data(), str.toLatin1().data());
231 if (atom_type.contains(
"Left"))
232 indentation_level += 1;
bool contains(const QString &str) const
Returns true if this Text contains the substring str.
static Text subText(const Atom *begin, const Atom *end=nullptr)
static Text sectionHeading(const Atom *sectionBegin)
void dump() const
Prints a human-readable version of the contained atoms to stderr.
const Atom * firstAtom() const
Text splitAtFirst(Atom::AtomType start)
Splits the current Text from start to end into a new Text object.
Text subText(Atom::AtomType left, Atom::AtomType right, const Atom *from=nullptr, bool inclusive=false) const
Text & operator=(const Text &text)
const Atom * lastAtom() const
QString toString() const
This function traverses the atom list of the Text object, extracting all the string parts.
static int compare(const Text &text1, const Text &text2)