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
+2 -2
View File
@@ -1,7 +1,7 @@
#pragma once
#include "Node.h"
#include "InlineNode.h"
#include "ast/Node.h"
// #include "ast/InlineNode/InlineNode.h"
#include <vector>
#include <string>
+8 -2
View File
@@ -1,11 +1,17 @@
#pragma once
#include "BlockNode.h"
#include "ast/BlockNode/BlockNode.h"
#include "utils/shorten.hpp"
struct CodeBlock : public BlockNode {
std::string language;
std::string code;
NodeKind getKind() const {
NodeKind getKind() const override {
return NodeKind::CodeBlock;
}
void repr(std::ostream &os, int indent = 0) const override {
os << getIndent(indent) << toString(this->getKind()) << " lang: " << this->language << " code: " << shorten(this->code) << '\n';
}
};
+11 -3
View File
@@ -1,12 +1,20 @@
#pragma once
#include "BlockNode.h"
#include "ast/BlockNode/BlockNode.h"
#include "ast/InlineNode/InlineNode.h"
struct Header : public BlockNode {
std::string headerText;
int level = 1;
std::vector<std::unique_ptr<InlineNode>> children;
NodeKind getKind() const {
NodeKind getKind() const override {
return NodeKind::Header;
}
void repr(std::ostream &os, int indent = 0) const override {
os << getIndent(indent) << toString(this->getKind()) << " level: " << this->level << '\n';
for (const std::unique_ptr<InlineNode> &child : this->children) {
child->repr(os, indent + 1);
}
}
};
+10 -3
View File
@@ -1,12 +1,19 @@
#pragma once
#include "BlockNode.h"
#include "ListItem.h"
#include "ast/BlockNode/BlockNode.h"
#include "ast/BlockNode/ListItem.h"
struct List : public BlockNode {
std::vector<std::unique_ptr<ListItem>> children;
NodeKind getKind() const {
NodeKind getKind() const override {
return NodeKind::List;
}
void repr(std::ostream &os, int indent) const override {
os << getIndent(indent) << toString(getKind()) << '\n';
for (const std::unique_ptr<ListItem> &child : this->children) {
child->repr(os, indent + 1);
}
}
};
+10 -3
View File
@@ -1,11 +1,18 @@
#pragma once
#include "BlockNode.h"
#include "ast/BlockNode/BlockNode.h"
struct ListItem : public BlockNode {
std::vector<std::unique_ptr<InlineNode>> children;
std::vector<std::unique_ptr<BlockNode>> children;
NodeKind getKind() const {
NodeKind getKind() const override {
return NodeKind::ListItem;
}
void repr(std::ostream &os, int indent) const override {
os << getIndent(indent) << toString(getKind()) << '\n';
for (const std::unique_ptr<BlockNode> &child : this->children) {
child->repr(os, indent + 1);
}
}
};
+10 -2
View File
@@ -1,11 +1,19 @@
#pragma once
#include "BlockNode.h"
#include "ast/BlockNode/BlockNode.h"
#include "ast/InlineNode/InlineNode.h"
struct Paragraph : public BlockNode {
std::vector<std::unique_ptr<InlineNode>> children;
NodeKind getKind() const {
NodeKind getKind() const override {
return NodeKind::Paragraph;
}
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);
}
}
};