1 #ifndef MYPARSER_PASS_REPR_HPP
2 #define MYPARSER_PASS_REPR_HPP
18 virtual void putName(
const std::string &name) {
26 virtual void putText(
const std::string &text) {
30 virtual void putError(
const std::string &error) {
48 virtual void putLn(
const bool first) {
55 const bool verbose,
const bool compact
58 optionV(verbose), optionC(compact),
59 out(target), indent(0) {}
69 std::vector<Node *> children1;
73 if (!child->empty()) {
74 children1.push_back(child);
79 const std::vector<Node *> &children =
82 if (optionC && children.size() == 1) {
84 children[0]->runPass(
this);
93 for (
const Node *child: children) {
128 putError(E::getStr());
142 putError(E::getStr());
149 template <
class TX =
void>
152 virtual void putText(
const std::string &text) {
164 template <
class TX =
void>
167 virtual void putText(
const std::string &text) {
179 virtual void putLn(
const bool first) {
183 for (
size_t i = 0; i <
indent; ++i) {
190 std::ostream &target,
191 const bool verbose =
false,
const bool compact =
true
197 template <
class TX =
void>
200 virtual void putName(
const std::string &name) {
210 virtual void putText(
const std::string &text) {
222 virtual void putLn(
const bool first) {
226 for (
size_t i = 0; i <
indent; ++i) {
233 std::ostream &target,
234 const bool verbose =
false,
const bool compact =
true
240 template <
class TX =
void>
244 for (
const char c: str) {
279 if (
'\0' <= c && c <
'\x10') {
280 out <<
"\\x0" << (
"0123456789ABCDEF"[c & 0xF]);
281 }
else if (
'\x10' <= c && c <
'\x20') {
282 out <<
"\\x1" << (
"0123456789ABCDEF"[c & 0xF]);
291 virtual void putName(
const std::string &name) {
293 out <<
"\"rulename\": \"" << name <<
"\",";
298 out <<
"\"ruleindex\": \"" << index <<
"\",";
301 virtual void putText(
const std::string &text) {
303 out <<
"\"text\": \"";
310 out <<
"\"error\": \"";
328 out <<
"\"children\": [";
337 virtual void putLn(
const bool first) {
346 for (
size_t i = 0; i <
indent; ++i) {
353 std::ostream &target,
const bool verbose =
false
const std::vector< Node * > & getChildren() const
Definition: myparser_ast.hpp:131
virtual void putMainBegin()
Definition: myparser_pass_repr.hpp:315
virtual size_t getIndex() const =0
Definition: myparser_common.hpp:82
void run(const NodeList<> *node)
Definition: myparser_pass_repr.hpp:63
Definition: myparser_pass_repr.hpp:241
const bool optionV
Definition: myparser_pass_repr.hpp:11
void putStrEscaped(const std::string &str)
Definition: myparser_pass_repr.hpp:243
PassReprFull(std::ostream &target, const bool verbose=false, const bool compact=true)
Definition: myparser_pass_repr.hpp:232
Definition: myparser_pass_repr.hpp:198
Definition: myparser_pass_repr.hpp:150
Definition: myparser_ast.hpp:10
const bool optionC
Definition: myparser_pass_repr.hpp:12
const auto style_keyword
Definition: myparser_common.hpp:67
virtual void putPlaceHolder()
Definition: myparser_pass_repr.hpp:175
virtual void putName(const std::string &name)
Definition: myparser_pass_repr.hpp:291
const auto style_error
Definition: myparser_common.hpp:68
Definition: myparser_ast.hpp:183
virtual void putError(const std::string &error)
Definition: myparser_pass_repr.hpp:171
virtual bool accepted() const
Definition: myparser_ast.hpp:161
PassReprJSON(std::ostream &target, const bool verbose=false)
Definition: myparser_pass_repr.hpp:352
virtual void putMainEnd()
Definition: myparser_pass_repr.hpp:36
const auto style_normal
Definition: myparser_common.hpp:71
virtual void putBegin()
Definition: myparser_pass_repr.hpp:40
virtual void putLn(const bool first)
Definition: myparser_pass_repr.hpp:222
virtual void putLnBegin()
Definition: myparser_pass_repr.hpp:44
virtual void putError(const std::string &error)
Definition: myparser_pass_repr.hpp:308
virtual void putIndex(const size_t index)
Definition: myparser_pass_repr.hpp:22
Definition: myparser_pass.hpp:24
virtual void putName(const std::string &name)
Definition: myparser_pass_repr.hpp:200
Definition: myparser_common.hpp:92
Definition: myparser_ast.hpp:192
std::ostream & out
Definition: myparser_pass_repr.hpp:15
virtual void putMainEnd()
Definition: myparser_pass_repr.hpp:320
void run(const NodeTextOrError< E > *node)
Definition: myparser_pass_repr.hpp:119
virtual void putLn(const bool first)
Definition: myparser_pass_repr.hpp:48
const auto style_faint
Definition: myparser_common.hpp:70
const auto style_index
Definition: myparser_common.hpp:66
void putLn1()
Definition: myparser_pass_repr.hpp:344
PassReprSimple(std::ostream &target, const bool verbose=false, const bool compact=true)
Definition: myparser_pass_repr.hpp:189
PassReprText(std::ostream &target)
Definition: myparser_pass_repr.hpp:157
virtual void putText(const std::string &text)
Definition: myparser_pass_repr.hpp:152
virtual void putText(const std::string &text)
Definition: myparser_pass_repr.hpp:301
virtual void putIndex(const size_t index)
Definition: myparser_pass_repr.hpp:204
virtual void putText(const std::string &text)
Definition: myparser_pass_repr.hpp:210
virtual void putName(const std::string &name)
Definition: myparser_pass_repr.hpp:18
virtual void putPlaceHolder()
Definition: myparser_pass_repr.hpp:38
virtual void putText(const std::string &text)
Definition: myparser_pass_repr.hpp:167
virtual void putIndex(const size_t index)
Definition: myparser_pass_repr.hpp:296
Pass(std::ostream &target, const bool verbose, const bool compact)
Definition: myparser_pass_repr.hpp:53
virtual void putBegin()
Definition: myparser_pass_repr.hpp:218
virtual void putMainBegin()
Definition: myparser_pass_repr.hpp:34
virtual void putLnEnd()
Definition: myparser_pass_repr.hpp:46
virtual void putText(const std::string &text)
Definition: myparser_pass_repr.hpp:26
virtual void putLnBegin()
Definition: myparser_pass_repr.hpp:326
Definition: myparser_pass_repr.hpp:165
void run(const NodeText<> *node)
Definition: myparser_pass_repr.hpp:106
size_t indent
Definition: myparser_pass_repr.hpp:16
virtual void putLn(const bool first)
Definition: myparser_pass_repr.hpp:179
virtual void putError(const std::string &error)
Definition: myparser_pass_repr.hpp:214
const std::string & getText() const
Definition: myparser_ast.hpp:177
virtual void putEnd()
Definition: myparser_pass_repr.hpp:42
void run(const NodeError< E > *node)
Definition: myparser_pass_repr.hpp:136
virtual const std::string & getRuleName() const =0
virtual void putLnEnd()
Definition: myparser_pass_repr.hpp:332
virtual void putLn(const bool first)
Definition: myparser_pass_repr.hpp:337
virtual void putError(const std::string &error)
Definition: myparser_pass_repr.hpp:30