ready to merge docs
This commit is contained in:
61
include/tools.h
Normal file
61
include/tools.h
Normal 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; }
|
||||
};
|
Reference in New Issue
Block a user