commit 208d34864e17d448d8ed03bb9f46eafd9b2d113b Author: German Mikheev Date: Thu May 14 01:49:48 2026 +0300 initial commit diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..126acc5 --- /dev/null +++ b/CMakeLists.txt @@ -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/ +) \ No newline at end of file diff --git a/include/ast/BlockNode/BlockNode.h b/include/ast/BlockNode/BlockNode.h new file mode 100644 index 0000000..38a3b5b --- /dev/null +++ b/include/ast/BlockNode/BlockNode.h @@ -0,0 +1,10 @@ +#pragma once + +#include "Node.h" +#include "InlineNode.h" +#include +#include + +struct BlockNode : public Node { + virtual ~BlockNode() = default; +}; \ No newline at end of file diff --git a/include/ast/BlockNode/CodeBlock.h b/include/ast/BlockNode/CodeBlock.h new file mode 100644 index 0000000..3848dcb --- /dev/null +++ b/include/ast/BlockNode/CodeBlock.h @@ -0,0 +1,11 @@ +#pragma once + +#include "BlockNode.h" + +struct CodeBlock : public BlockNode { + std::string code; + + NodeKind getKind() const { + return NodeKind::CodeBlock; + } +}; \ No newline at end of file diff --git a/include/ast/BlockNode/Header.h b/include/ast/BlockNode/Header.h new file mode 100644 index 0000000..1f055d7 --- /dev/null +++ b/include/ast/BlockNode/Header.h @@ -0,0 +1,12 @@ +#pragma once + +#include "BlockNode.h" + +struct Header : public BlockNode { + std::string headerText; + std::vector> children; + + NodeKind getKind() const { + return NodeKind::Header; + } +}; \ No newline at end of file diff --git a/include/ast/BlockNode/List.h b/include/ast/BlockNode/List.h new file mode 100644 index 0000000..1200c5f --- /dev/null +++ b/include/ast/BlockNode/List.h @@ -0,0 +1,12 @@ +#pragma once + +#include "BlockNode.h" +#include "ListItem.h" + +struct List : public BlockNode { + std::vector> children; + + NodeKind getKind() const { + return NodeKind::List; + } +}; \ No newline at end of file diff --git a/include/ast/BlockNode/ListItem.h b/include/ast/BlockNode/ListItem.h new file mode 100644 index 0000000..9779d34 --- /dev/null +++ b/include/ast/BlockNode/ListItem.h @@ -0,0 +1,11 @@ +#pragma once + +#include "BlockNode.h" + +struct ListItem : public BlockNode { + std::vector> children; + + NodeKind getKind() const { + return NodeKind::ListItem; + } +}; \ No newline at end of file diff --git a/include/ast/BlockNode/Paragraph.h b/include/ast/BlockNode/Paragraph.h new file mode 100644 index 0000000..868a127 --- /dev/null +++ b/include/ast/BlockNode/Paragraph.h @@ -0,0 +1,11 @@ +#pragma once + +#include "BlockNode.h" + +struct Paragraph : public BlockNode { + std::vector> children; + + NodeKind getKind() const { + return NodeKind::Paragraph; + } +}; \ No newline at end of file diff --git a/include/ast/InlineNode/Bold.h b/include/ast/InlineNode/Bold.h new file mode 100644 index 0000000..45d6d74 --- /dev/null +++ b/include/ast/InlineNode/Bold.h @@ -0,0 +1,11 @@ +#pragma once + +#include "InlineNode.h" + +struct Bold : public InlineNode { + std::vector> children; + + NodeKind getKind() const { + return NodeKind::Bold; + } +}; \ No newline at end of file diff --git a/include/ast/InlineNode/InlineCode.h b/include/ast/InlineNode/InlineCode.h new file mode 100644 index 0000000..1f7568e --- /dev/null +++ b/include/ast/InlineNode/InlineCode.h @@ -0,0 +1,11 @@ +#pragma once + +#include "InlineNode.h" + +struct InlineCode : public InlineNode { + std::string inlineCodeString; + + NodeKind getKind() const { + return NodeKind::InlineCode; + } +}; \ No newline at end of file diff --git a/include/ast/InlineNode/InlineNode.h b/include/ast/InlineNode/InlineNode.h new file mode 100644 index 0000000..abe86f3 --- /dev/null +++ b/include/ast/InlineNode/InlineNode.h @@ -0,0 +1,7 @@ +#pragma once + +#include "Node.h" + +struct InlineNode : public Node { + virtual ~InlineNode() = default; +}; \ No newline at end of file diff --git a/include/ast/InlineNode/Italic.h b/include/ast/InlineNode/Italic.h new file mode 100644 index 0000000..7dbc762 --- /dev/null +++ b/include/ast/InlineNode/Italic.h @@ -0,0 +1,11 @@ +#pragma once + +#include "InlineNode.h" + +struct Italic : public InlineNode { + std::vector> children; + + NodeKind getKind() const { + return NodeKind::Italic; + } +}; \ No newline at end of file diff --git a/include/ast/InlineNode/Link.h b/include/ast/InlineNode/Link.h new file mode 100644 index 0000000..8ef3943 --- /dev/null +++ b/include/ast/InlineNode/Link.h @@ -0,0 +1,12 @@ +#pragma once + +#include "InlineNode.h" + +struct Link : public InlineNode { + std::string url; + std::vector> children; + + NodeKind getKind() const { + return NodeKind::Link; + } +}; \ No newline at end of file diff --git a/include/ast/InlineNode/Text.h b/include/ast/InlineNode/Text.h new file mode 100644 index 0000000..b1c6342 --- /dev/null +++ b/include/ast/InlineNode/Text.h @@ -0,0 +1,11 @@ +#pragma once + +#include "InlineNode.h" + +struct Text : public InlineNode { + std::string text; + + NodeKind getKind() const { + return NodeKind::Text; + } +}; \ No newline at end of file diff --git a/include/ast/Node.h b/include/ast/Node.h new file mode 100644 index 0000000..1bc30c5 --- /dev/null +++ b/include/ast/Node.h @@ -0,0 +1,10 @@ +#pragma once + +#include +#include +#include "NodeKind.h" + +struct Node { + virtual ~Node() = default; + virtual NodeKind getKind() const = 0; +}; \ No newline at end of file diff --git a/include/ast/NodeKind.h b/include/ast/NodeKind.h new file mode 100644 index 0000000..e57c9fe --- /dev/null +++ b/include/ast/NodeKind.h @@ -0,0 +1,15 @@ +#pragma once + +enum class NodeKind { + CodeBlock, + Header, + List, + ListItem, + Paragraph, + + Bold, + InlineCode, + Italic, + Link, + Text +}; \ No newline at end of file