initial commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.25.1)
|
||||
project(mdtex-compiler)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_FLAGS "-g -Wall -Wextra -Werror -pedantic -fsanitize=address")
|
||||
|
||||
file(GLOB SRC source/*.cpp)
|
||||
|
||||
add_executable(mdtex-compiler
|
||||
${SRC}
|
||||
main.cpp
|
||||
)
|
||||
|
||||
include_directories(
|
||||
./include/
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Node.h"
|
||||
#include "InlineNode.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
struct BlockNode : public Node {
|
||||
virtual ~BlockNode() = default;
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockNode.h"
|
||||
|
||||
struct CodeBlock : public BlockNode {
|
||||
std::string code;
|
||||
|
||||
NodeKind getKind() const {
|
||||
return NodeKind::CodeBlock;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockNode.h"
|
||||
|
||||
struct Header : public BlockNode {
|
||||
std::string headerText;
|
||||
std::vector<std::unique_ptr<InlineNode>> children;
|
||||
|
||||
NodeKind getKind() const {
|
||||
return NodeKind::Header;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockNode.h"
|
||||
#include "ListItem.h"
|
||||
|
||||
struct List : public BlockNode {
|
||||
std::vector<std::unique_ptr<ListItem>> children;
|
||||
|
||||
NodeKind getKind() const {
|
||||
return NodeKind::List;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockNode.h"
|
||||
|
||||
struct ListItem : public BlockNode {
|
||||
std::vector<std::unique_ptr<InlineNode>> children;
|
||||
|
||||
NodeKind getKind() const {
|
||||
return NodeKind::ListItem;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockNode.h"
|
||||
|
||||
struct Paragraph : public BlockNode {
|
||||
std::vector<std::unique_ptr<InlineNode>> children;
|
||||
|
||||
NodeKind getKind() const {
|
||||
return NodeKind::Paragraph;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "InlineNode.h"
|
||||
|
||||
struct Bold : public InlineNode {
|
||||
std::vector<std::unique_ptr<InlineNode>> children;
|
||||
|
||||
NodeKind getKind() const {
|
||||
return NodeKind::Bold;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "InlineNode.h"
|
||||
|
||||
struct InlineCode : public InlineNode {
|
||||
std::string inlineCodeString;
|
||||
|
||||
NodeKind getKind() const {
|
||||
return NodeKind::InlineCode;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Node.h"
|
||||
|
||||
struct InlineNode : public Node {
|
||||
virtual ~InlineNode() = default;
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "InlineNode.h"
|
||||
|
||||
struct Italic : public InlineNode {
|
||||
std::vector<std::unique_ptr<InlineNode>> children;
|
||||
|
||||
NodeKind getKind() const {
|
||||
return NodeKind::Italic;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "InlineNode.h"
|
||||
|
||||
struct Link : public InlineNode {
|
||||
std::string url;
|
||||
std::vector<std::unique_ptr<InlineNode>> children;
|
||||
|
||||
NodeKind getKind() const {
|
||||
return NodeKind::Link;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "InlineNode.h"
|
||||
|
||||
struct Text : public InlineNode {
|
||||
std::string text;
|
||||
|
||||
NodeKind getKind() const {
|
||||
return NodeKind::Text;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "NodeKind.h"
|
||||
|
||||
struct Node {
|
||||
virtual ~Node() = default;
|
||||
virtual NodeKind getKind() const = 0;
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
enum class NodeKind {
|
||||
CodeBlock,
|
||||
Header,
|
||||
List,
|
||||
ListItem,
|
||||
Paragraph,
|
||||
|
||||
Bold,
|
||||
InlineCode,
|
||||
Italic,
|
||||
Link,
|
||||
Text
|
||||
};
|
||||
Reference in New Issue
Block a user