1 #ifndef MYPARSER_AST_HPP
2 #define MYPARSER_AST_HPP
8 using Input = std::string::const_iterator;
14 inline Node() =
delete;
22 virtual inline void free() {
26 virtual bool empty()
const = 0;
32 virtual size_t getLen()
const = 0;
34 virtual void getFullText(std::ostream &out)
const = 0;
37 std::ostringstream result;
67 template <
class TX =
void>
96 if (!child->empty()) {
117 result += child->getLen();
125 child->getFullText(out);
129 virtual size_t getIndex()
const = 0;
149 template <
class TX =
void>
156 const Input &input, std::string &&value
157 ):
Node(input),
text(std::move(value)) {}
186 const Input &input, std::string &&value
187 ):
NodeText(input, std::move(value)) {}
213 template <
class N,
class T,
size_t I = 0>
228 template <
class N,
class T>
234 template <
class NT,
size_t I>
240 template <
class NT,
class E>
const std::vector< Node * > & getChildren() const
Definition: myparser_ast.hpp:131
Node(const Input &input)
Definition: myparser_ast.hpp:17
static MYPARSER_INLINE void call(PassBase *pass, const size_t target, const T *node)
Definition: myparser_pass.hpp:48
virtual size_t getIndex() const =0
const std::string getFullText() const
Definition: myparser_ast.hpp:36
Definition: myparser_ast.hpp:229
virtual void getFullText(std::ostream &out) const
Definition: myparser_ast.hpp:123
size_t getId()
Definition: myparser_pass.hpp:18
virtual size_t getLen() const =0
virtual bool empty() const
Definition: myparser_ast.hpp:165
virtual bool empty() const
Definition: myparser_ast.hpp:94
virtual void free()
Definition: myparser_ast.hpp:86
Definition: myparser_ast.hpp:10
const Input pos
Definition: myparser_ast.hpp:12
virtual bool empty() const
Definition: myparser_ast.hpp:199
void bind(NodeList<> *target, const size_t pos)
Definition: myparser_ast.hpp:104
virtual ~NodeList()
Definition: myparser_ast.hpp:80
Definition: myparser_ast.hpp:183
const Input & getPos() const
Definition: myparser_ast.hpp:44
const std::string text
Definition: myparser_ast.hpp:152
virtual void getFullText(std::ostream &out) const
Definition: myparser_ast.hpp:173
virtual bool accepted() const
Definition: myparser_ast.hpp:161
Node * challengeLonger(Node *target)
Definition: myparser_ast.hpp:52
virtual void free()
Definition: myparser_ast.hpp:22
Definition: myparser_pass.hpp:8
const Input getTail() const
Definition: myparser_ast.hpp:48
void putChild(Node *value)
Definition: myparser_ast.hpp:109
NodeText(const Input &input, std::string &&value)
Definition: myparser_ast.hpp:155
virtual void runPass(PassBase *pass) const =0
virtual bool empty() const =0
virtual const std::string & getRuleName() const
Definition: myparser_ast.hpp:222
Definition: myparser_ast.hpp:137
Definition: myparser_ast.hpp:192
virtual size_t getLen() const
Definition: myparser_ast.hpp:203
NodeList(const Input &input)
Definition: myparser_ast.hpp:76
NodeTextOrError(const Input &input, std::string &&value)
Definition: myparser_ast.hpp:185
virtual size_t getLen() const
Definition: myparser_ast.hpp:169
virtual void runPass(PassBase *pass) const
Definition: myparser_ast.hpp:218
NodeListIndexed(const Input &input)
Definition: myparser_ast.hpp:139
std::vector< Node * > children
Definition: myparser_ast.hpp:70
virtual size_t getLen() const
Definition: myparser_ast.hpp:113
Definition: myparser_ast.hpp:150
virtual ~Node()
Definition: myparser_ast.hpp:20
virtual void getFullText(std::ostream &out) const
Definition: myparser_ast.hpp:207
std::string::const_iterator Input
Definition: myparser_ast.hpp:8
Definition: myparser_ast.hpp:214
const std::string & getText() const
Definition: myparser_ast.hpp:177
size_t basepos
Definition: myparser_ast.hpp:72
NodeList * brother
Definition: myparser_ast.hpp:73
virtual const std::string & getRuleName() const =0
virtual size_t getIndex() const
Definition: myparser_ast.hpp:144
NodeError(const Input &input)
Definition: myparser_ast.hpp:194
Definition: myparser_ast.hpp:68