Skip to content

Commit

Permalink
feat(semantical): added methods. (sorry by broken code, my working de…
Browse files Browse the repository at this point in the history
…vice isnt mine)
  • Loading branch information
IfLostart2per5 committed Dec 17, 2024
1 parent 4787189 commit 90422de
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
12 changes: 12 additions & 0 deletions include/frontend/checker/common_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef COMMON_TYPES_H
#define COMMON_TYPES_H
#include <string.h>

#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
15 changes: 10 additions & 5 deletions include/frontend/checker/core.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#ifndef CHECKER_CORE_H
#define CHECKER_CORE_H
#include <map>
#include "../ast/definitions.h"
#include "frontend/ast/definitions.h"

struct TypeDef {
struct Typedef {
char* name;
int id;
Typedef** entries;
}

struct Namespace {
map<char*, TypeDef>* space;
int varcountn
map<char*, Typedef>* space;
int varcountn;
}
struct Checker {
AstNode* ast;
Expand All @@ -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
10 changes: 10 additions & 0 deletions src/frontend/checker/checker.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <iostream>
#extern "C" {
#include "frontend/checker/core.h"
#include "frontend/checker/common_types.h"
#include "utils.h"
}

Checker* init(AstNode* ast) {

}

0 comments on commit 90422de

Please sign in to comment.