refactored ast, started lexer

This commit is contained in:
2026-05-18 20:19:17 +03:00
parent 24750ddcbe
commit eb85acf224
29 changed files with 315 additions and 181 deletions
+7 -13
View File
@@ -2,17 +2,11 @@
#include "ast/InlineNode/InlineNode.h"
struct Bold : public InlineNode {
std::vector<std::unique_ptr<InlineNode>> children;
namespace ast {
struct Bold : public InlineNode {
std::vector<std::unique_ptr<InlineNode>> children;
NodeKind getKind() const override {
return NodeKind::Bold;
}
void repr(std::ostream &os, int indent) const override {
os << getIndent(indent) << toString(getKind()) << '\n';
for (const std::unique_ptr<InlineNode> &child : children) {
child->repr(os, indent + 1);
}
}
};
NodeKind getKind() const override;
void repr(std::ostream &os, int indent) const override;
};
}
+7 -10
View File
@@ -2,14 +2,11 @@
#include "ast/InlineNode/InlineNode.h"
struct InlineCode : public InlineNode {
std::string inlineCodeString;
namespace ast {
struct InlineCode : public InlineNode {
std::string inlineCodeString;
NodeKind getKind() const override {
return NodeKind::InlineCode;
}
void repr(std::ostream &os, int indent) const override {
os << getIndent(indent) << toString(getKind()) << " inline code: " << this->inlineCodeString << '\n';
}
};
NodeKind getKind() const override;
void repr(std::ostream &os, int indent) const override;
};
}
+5 -3
View File
@@ -2,6 +2,8 @@
#include "ast/Node.h"
struct InlineNode : public Node {
virtual ~InlineNode() = default;
};
namespace ast {
struct InlineNode : public Node {
virtual ~InlineNode() = default;
};
}
+8 -14
View File
@@ -2,17 +2,11 @@
#include "ast/InlineNode/InlineNode.h"
struct Italic : public InlineNode {
std::vector<std::unique_ptr<InlineNode>> children;
NodeKind getKind() const override {
return NodeKind::Italic;
}
void repr(std::ostream &os, int indent) const override {
os << getIndent(indent) << toString(this->getKind()) << '\n';
for (const std::unique_ptr<InlineNode> &child : this->children) {
child->repr(os, indent + 1);
}
}
};
namespace ast {
struct Italic : public InlineNode {
std::vector<std::unique_ptr<InlineNode>> children;
NodeKind getKind() const override;
void repr(std::ostream &os, int indent) const override;
};
}
+8 -14
View File
@@ -3,18 +3,12 @@
#include "ast/InlineNode/InlineNode.h"
#include "utils/shorten.hpp"
struct Link : public InlineNode {
std::string url;
std::vector<std::unique_ptr<InlineNode>> children;
namespace ast {
struct Link : public InlineNode {
std::string url;
std::vector<std::unique_ptr<InlineNode>> children;
NodeKind getKind() const override {
return NodeKind::Link;
}
void repr(std::ostream &os, int indent) const override {
os << getIndent(indent) << toString(this->getKind()) << " link: " << shorten(this->url) << '\n';
for (const std::unique_ptr<InlineNode> &child : this->children) {
child->repr(os, indent + 1);
}
}
};
NodeKind getKind() const override;
void repr(std::ostream &os, int indent) const override;
};
}
+7 -10
View File
@@ -3,14 +3,11 @@
#include "ast/InlineNode/InlineNode.h"
#include "utils/shorten.hpp"
struct Text : public InlineNode {
std::string text;
namespace ast {
struct Text : public InlineNode {
std::string text;
NodeKind getKind() const override {
return NodeKind::Text;
}
void repr(std::ostream &os, int indent) const override {
os << getIndent(indent) << toString(this->getKind()) << " text: " << shorten(this->text) << '\n';
}
};
NodeKind getKind() const override;
void repr(std::ostream &os, int indent) const override;
};
}