Loading...
Searching...
No Matches
stelaWriter.hpp
Go to the documentation of this file.
1
2#pragma once
3
5
6namespace by {
7
35 class _nout stelaWriter: public stelaVisitor {
37
38 public:
42 std::string write(stela& root);
47 nbool writeFile(stela& root, const std::string& path);
48 nbool writeFile(stela& root, const nchar* path) BY_SIDE_FUNC(path, writeFile(root, std::string(path)), false);
49
50 protected:
51 nbool onVisit(const stelaVisitInfo& i, rootStela& it) override;
52 nbool onVisit(const stelaVisitInfo& i, defStela& it) override;
53 nbool onVisit(const stelaVisitInfo& i, valStela& it) override;
54 nbool onVisit(const stelaVisitInfo& i, strStela& it) override;
55 nbool onVisit(const stelaVisitInfo& i, arrStela& it) override;
56 void onLeave(const stelaVisitInfo& i, arrStela& it) override;
57
58 private:
59 std::string _indent(nint depth);
60 std::stringstream& _open(const stelaVisitInfo& i, stela& it);
61 void _close(const stelaVisitInfo& i, stela& it);
62 void _writePrefix(const stelaVisitInfo& i, stela& it);
63 void _writePostfix(stela& it);
64 void _writeElemPrefix(stela& it);
65
66 private:
67 std::stringstream _ss;
68 };
69} // namespace by
Ordered list of elements.
Definition arrStela.hpp:26
Named block of children — the def form of stela source.
Definition defStela.hpp:24
The compilation unit — the one node with no source form of its own.
Definition rootStela.hpp:22
Definition stela.hpp:63
Traversal context handed to every stelaVisitor callback.
Definition stelaVisitInfo.hpp:17
Preorder visitor for the stela AST.
Definition stelaVisitor.hpp:30
Serializes a stela tree back to stela source text.
Definition stelaWriter.hpp:35
std::string write(stela &root)
Serializes root and its subtree to a string.
nbool writeFile(stela &root, const std::string &path)
Serializes root and writes the result to path (LF, UTF-8, non-atomic).
String-value marker over valStela.
Definition strStela.hpp:15
Scalar value — the abstract base of every leaf form.
Definition valStela.hpp:21
Rich logging support with polymorphic type conversion.
Definition richLog.hpp:34