diff --git a/include/AST.hpp b/include/AST.hpp new file mode 100644 index 0000000..6ac3829 --- /dev/null +++ b/include/AST.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include "Lexer.hpp" +#include +#include +#include +#include +#include +#include + +namespace ztl{ + struct AST{ + struct Literal{ + using LiteralType = std::variant; + LiteralType value; + }; + struct Identifier{ + std::string name; + }; + struct BinaryExpression{ + enum OperatorType{ + One, + Add + }; + OperatorType Operator; + using LRType = std::variant< + Identifier, + std::unique_ptr + >; + LRType left; + LRType right; + }; + struct VariableDeclaration{ + Identifier id; + BinaryExpression init; + }; + struct BlockStatement{ + using BodyType = std::vector>; + BodyType body; + }; + AST(const std::vector &tokens){ + for(size_t i=0;i keywords = {"int","print"}; + const static std::vector keywords = {"int"}; bool isKeywords = false; for(const std::string&k:keywords){ if(nstr==k){ diff --git a/tests/test.cpp b/tests/test.cpp index 295ac66..d4dc5dd 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -3,5 +3,6 @@ int main(int argc,char *argv[]){ + ztl::isDebug=true; ztl::runCodeFromPath("/root/dev/cpp/TudorLang/tests/main.ztl"); } \ No newline at end of file