cbc2c
This commit is contained in:
parent
cd81de9216
commit
3018020201
25
src/cb2c/cb2c.c
Normal file
25
src/cb2c/cb2c.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include "cb2c.h"
|
||||||
|
#include "../../../kerep/src/String/StringBuilder.h"
|
||||||
|
|
||||||
|
void namespaceToC(NamespaceContext* context, StringBuilder* b){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void functionToC(FunctionContext* context, StringBuilder* b){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void classToC(ClassContext* context, StringBuilder* b){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
char* contextToC(void* context){
|
||||||
|
StringBuilder* b=StringBuilder_create();
|
||||||
|
switch(((Context*)context)->type){
|
||||||
|
case CT_Namespace: namespaceToC(context, b); break;
|
||||||
|
case CT_Function: functionToC(context, b); break;
|
||||||
|
case CT_Class: classToC(context, b); break;
|
||||||
|
default: throw(ERR_WRONGTYPE);
|
||||||
|
}
|
||||||
|
return StringBuilder_build(b).ptr;
|
||||||
|
}
|
||||||
5
src/cb2c/cb2c.h
Normal file
5
src/cb2c/cb2c.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../lexer/lexer.h"
|
||||||
|
|
||||||
|
char* contextToC(void* context);
|
||||||
8
src/cb2c/main.c
Normal file
8
src/cb2c/main.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "cb2c.h"
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
init_keywordsSearchTree();
|
||||||
|
|
||||||
|
STNode_free(keywordsSearchTree);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
46
src/lexer/context.h
Normal file
46
src/lexer/context.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../../../kerep/src/base/base.h"
|
||||||
|
#include "tokens.h"
|
||||||
|
|
||||||
|
typedef struct ContextStruct Context;
|
||||||
|
|
||||||
|
typedef enum ContextType{
|
||||||
|
CT_Namespace,
|
||||||
|
CT_Function,
|
||||||
|
CT_Class
|
||||||
|
} __attribute__((__packed__)) ContextType;
|
||||||
|
|
||||||
|
struct ContextStruct {
|
||||||
|
char* name;
|
||||||
|
Context* parent;
|
||||||
|
Autoarr(Token)* tokens;
|
||||||
|
ContextType type;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct NamespaceContext{
|
||||||
|
union {
|
||||||
|
Context base;
|
||||||
|
Context;
|
||||||
|
};
|
||||||
|
} NamespaceContext;
|
||||||
|
|
||||||
|
typedef struct FunctionContext {
|
||||||
|
union {
|
||||||
|
Context base;
|
||||||
|
Context;
|
||||||
|
};
|
||||||
|
Autoarr(Token)* arguments;
|
||||||
|
Autoarr(Token)* attributes;
|
||||||
|
Token accessModifier;
|
||||||
|
Token returnType;
|
||||||
|
} FunctionContext;
|
||||||
|
|
||||||
|
typedef struct ClassContext {
|
||||||
|
union {
|
||||||
|
Context base;
|
||||||
|
Context;
|
||||||
|
};
|
||||||
|
Autoarr(Token)* attributes;
|
||||||
|
Token accessModifier;
|
||||||
|
} ClassContext;
|
||||||
@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "tokens.h"
|
#include "tokens.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "my_type_ext.h"
|
||||||
|
|
||||||
//Autoarr(Token)*
|
//Autoarr(Token)*
|
||||||
Maybe lexan(char* source, char* filename);
|
Maybe lexan(char* source, char* filename);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user