ready to merge docs

This commit is contained in:
2024-08-11 08:37:17 +00:00
parent 9900d5aaf3
commit 22d18436fa
10 changed files with 346 additions and 38 deletions

61
include/tools.h Normal file
View File

@ -0,0 +1,61 @@
#pragma once
#include <stdexcept>
enum class ASTNodeType {
// Expression nodes
NewArrayExpr,
NewConstructExpr,
NewExpr,
MemberVariableAccessExpr,
MemberFunctionAccessExpr,
IndexExpr,
SuffixExpr,
PrefixExpr,
OppositeExpr,
LNotExpr,
BNotExpr,
MDMExpr,
PMExpr,
RLExpr,
GGLLExpr,
NEExpr,
BAndExpr,
BXorExpr,
BOrExpr,
LAndExpr,
LOrExpr,
TernaryExpr,
AssignExpr,
ThisExpr,
ParenExpr,
IDExpr,
FunctionCallExpr,
FormattedStringExpr,
ConstantExpr,
// Statement nodes
EmptyStatement,
DefinitionStatement,
ExprStatement,
IfStatement,
WhileStatement,
ForStatement,
JmpStatement,
SuiteStatement,
// Structural nodes
FuncDef,
Constructor,
ClassVariable,
ClassDef,
Program
};
class SemanticError : public std::exception {
std::string msg;
int error_code;
public:
SemanticError(const std::string &msg, int error_code) : msg(msg), error_code(error_code) {}
const char *what() const noexcept override { return msg.c_str(); }
int GetErrorCode() const { return error_code; }
};