ast updated

This commit is contained in:
2026-05-17 16:30:49 +03:00
parent 208d34864e
commit 24750ddcbe
20 changed files with 194 additions and 38 deletions
+9 -2
View File
@@ -1,11 +1,18 @@
#pragma once
#include "InlineNode.h"
#include "ast/InlineNode/InlineNode.h"
struct Bold : public InlineNode {
std::vector<std::unique_ptr<InlineNode>> children;
NodeKind getKind() const {
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);
}
}
};
+6 -2
View File
@@ -1,11 +1,15 @@
#pragma once
#include "InlineNode.h"
#include "ast/InlineNode/InlineNode.h"
struct InlineCode : public InlineNode {
std::string inlineCodeString;
NodeKind getKind() const {
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';
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
#pragma once
#include "Node.h"
#include "ast/Node.h"
struct InlineNode : public Node {
virtual ~InlineNode() = default;
+9 -2
View File
@@ -1,11 +1,18 @@
#pragma once
#include "InlineNode.h"
#include "ast/InlineNode/InlineNode.h"
struct Italic : public InlineNode {
std::vector<std::unique_ptr<InlineNode>> children;
NodeKind getKind() const {
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);
}
}
};
+10 -2
View File
@@ -1,12 +1,20 @@
#pragma once
#include "InlineNode.h"
#include "ast/InlineNode/InlineNode.h"
#include "utils/shorten.hpp"
struct Link : public InlineNode {
std::string url;
std::vector<std::unique_ptr<InlineNode>> children;
NodeKind getKind() const {
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);
}
}
};
+7 -2
View File
@@ -1,11 +1,16 @@
#pragma once
#include "InlineNode.h"
#include "ast/InlineNode/InlineNode.h"
#include "utils/shorten.hpp"
struct Text : public InlineNode {
std::string text;
NodeKind getKind() const {
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';
}
};