ast updated
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user