47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "Lexer.hpp"
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <variant>
|
|
#include <vector>
|
|
|
|
namespace ztl{
|
|
struct AST{
|
|
struct Literal{
|
|
using LiteralType = std::variant<int64_t>;
|
|
LiteralType value;
|
|
};
|
|
struct Identifier{
|
|
std::string name;
|
|
};
|
|
struct BinaryExpression{
|
|
enum OperatorType{
|
|
One,
|
|
Add
|
|
};
|
|
OperatorType Operator;
|
|
using LRType = std::variant<
|
|
Identifier,
|
|
std::unique_ptr<BinaryExpression>
|
|
>;
|
|
LRType left;
|
|
LRType right;
|
|
};
|
|
struct VariableDeclaration{
|
|
Identifier id;
|
|
BinaryExpression init;
|
|
};
|
|
struct BlockStatement{
|
|
using BodyType = std::vector<std::variant<VariableDeclaration>>;
|
|
BodyType body;
|
|
};
|
|
AST(const std::vector<Token> &tokens){
|
|
for(size_t i=0;i<tokens.size();i++){
|
|
|
|
}
|
|
}
|
|
};
|
|
} |