refactored ast, started lexer
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#include "ast/BlockNode/CodeBlock.h"
|
||||
|
||||
namespace ast {
|
||||
NodeKind CodeBlock::getKind() const {
|
||||
return NodeKind::CodeBlock;
|
||||
}
|
||||
|
||||
void CodeBlock::repr(std::ostream &os, int indent = 0) const {
|
||||
os << getIndent(indent) << toString(this->getKind()) << " lang: " << this->language << " code: " << shorten(this->code) << '\n';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "ast/BlockNode/Header.h"
|
||||
|
||||
namespace ast {
|
||||
NodeKind Header::getKind() const {
|
||||
return NodeKind::Header;
|
||||
}
|
||||
|
||||
void Header::repr(std::ostream &os, int indent = 0) const {
|
||||
os << getIndent(indent) << toString(this->getKind()) << " level: " << this->level << '\n';
|
||||
for (const std::unique_ptr<InlineNode> &child : this->children) {
|
||||
child->repr(os, indent + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "ast/BlockNode/List.h"
|
||||
|
||||
namespace ast {
|
||||
NodeKind List::getKind() const {
|
||||
return NodeKind::List;
|
||||
}
|
||||
|
||||
void List::repr(std::ostream &os, int indent) const {
|
||||
os << getIndent(indent) << toString(getKind()) << '\n';
|
||||
for (const std::unique_ptr<ListItem> &child : this->children) {
|
||||
child->repr(os, indent + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "ast/BlockNode/ListItem.h"
|
||||
|
||||
namespace ast {
|
||||
NodeKind ListItem::getKind() const {
|
||||
return NodeKind::ListItem;
|
||||
}
|
||||
|
||||
void ListItem::repr(std::ostream &os, int indent) const {
|
||||
os << getIndent(indent) << toString(getKind()) << '\n';
|
||||
for (const std::unique_ptr<BlockNode> &child : this->children) {
|
||||
child->repr(os, indent + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "ast/BlockNode/Paragraph.h"
|
||||
|
||||
namespace ast {
|
||||
NodeKind Paragraph::getKind() const {
|
||||
return NodeKind::Paragraph;
|
||||
}
|
||||
|
||||
void Paragraph::repr(std::ostream &os, int indent) const {
|
||||
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