diff --git a/include/frontend/checker/common_types.h b/include/frontend/checker/common_types.h new file mode 100644 index 0000000..a71fc9f --- /dev/null +++ b/include/frontend/checker/common_types.h @@ -0,0 +1,12 @@ +#ifndef COMMON_TYPES_H +#define COMMON_TYPES_H +#include + +#define ISTYPE(typedf, tname) (strcmp(typedf->name, tname) == 0) + +#define ISINT(typedf) ISTYPE(typedf, "int") +#define ISFLOAT(typedf) ISTYPE(typedf, "decimal") +#define ISSTRING(typedf) ISTYPE(typedf, "string") + + +#endif //COMMON_TYPES_H diff --git a/include/frontend/checker/core.h b/include/frontend/checker/core.h index 69e64dc..503f5be 100644 --- a/include/frontend/checker/core.h +++ b/include/frontend/checker/core.h @@ -1,17 +1,17 @@ #ifndef CHECKER_CORE_H #define CHECKER_CORE_H #include -#include "../ast/definitions.h" +#include "frontend/ast/definitions.h" -struct TypeDef { +struct Typedef { char* name; int id; Typedef** entries; } struct Namespace { - map* space; - int varcountn + map* space; + int varcountn; } struct Checker { AstNode* ast; @@ -20,5 +20,10 @@ struct Checker { Namespace* typedefs; } -//TODO: add methods +Checker* init(AstNode* ast); +void push_scope() +void push_variable(Checker* checker, char* name, Typedef* type); +void push_type(Checker* checker, char* tname, Typedef** templates); +TypeDef* check_node(Checker* checker, AstMode* node); +void freeChecker(Checker* checker); #endif //CHECKER_CORE_H diff --git a/src/frontend/checker/checker.c b/src/frontend/checker/checker.c new file mode 100644 index 0000000..87031a3 --- /dev/null +++ b/src/frontend/checker/checker.c @@ -0,0 +1,10 @@ +#include +#extern "C" { +#include "frontend/checker/core.h" +#include "frontend/checker/common_types.h" +#include "utils.h" +} + +Checker* init(AstNode* ast) { + +}