c语言gw,gwarf.c · SuperHuan/基于C的编程语言gwarf - Gitee.com

#include

#include

#include

#include "mem/mem.c"

#include "paser/paser.c"

#include "inter/branch.c"

#include "inter/cfunc.c"

#include "inter/parameter.c"

#include "inter/statement.c"

#include "inter/var.c"

#include "inter/tree.c"

#include "inter/interpreter.c"

extern FILE *debug, *status_log, *token_log, *token_info, *inter_info, *tree_info;

void do_exit(void);

void setup();

void setup(){

debug = fopen("./log/debug.log", "w"); // 设置debug的位置

status_log = fopen("./log/status.log", "w"); // 设置debug的位置

token_log = fopen("./log/token.log", "w"); // 设置debug的位置

token_info = fopen("./log/tokenINFO.log", "w"); // 设置debug的位置

inter_info = fopen("./log/interINFO.log", "w"); // 设置debug的位置

tree_info = fopen("./log/tree.log", "w");

}

void do_exit(void){

fclose(debug);

fclose(status_log);

fclose(token_log);

fclose(token_info);

fclose(inter_info);

fclose(tree_info);

}

int main(int argc, char *argv[]){

if(argc < 2){

printf("Don't get Enough Args");

exit(1);

}

char *file = argv[1];

atexit(*do_exit);

setup();

inter *global_inter = get_inter(); // 拿全局解释器[并声明全局变量]

var_list *the_var = make_var_base(global_inter->global_var);

the_var->tag = run_class;

login(the_var, global_inter);

parser(file, global_inter);

traverse_tree(global_inter->global_code, 0);

fprintf(inter_info, "----start run----\n");

traverse_global(global_inter->global_code, the_var, global_inter);

fprintf(inter_info, "code end...\n");

return 0;

}

void login(var_list *the_var, inter *global_inter){

login_official(the_var, official_func, global_inter); // 注册内置函数

class_object *tmp_object = object_login_official(the_var, object_official_func, global_inter); // 注册oobject

class_object *tmp_gobject = gobject_login_official(the_var, gobject_official_func, tmp_object->the_var, global_inter); // 注册goobject

int_login_official(the_var, int_official_func, tmp_gobject->the_var, global_inter); // 注册int

double_login_official(the_var, double_official_func, tmp_gobject->the_var, global_inter); // 注册double

str_login_official(the_var, str_official_func, tmp_gobject->the_var, global_inter); // 注册str

bool_login_official(the_var, bool_official_func, tmp_gobject->the_var, global_inter); // 注册bool

class_object *tmp_tuple = tuple_login_official(the_var, tuple_official_func, tmp_gobject->the_var, global_inter);

list_login_official(the_var, list_official_func, tmp_tuple->the_var, global_inter); // 注册list

dict_login_official(the_var, dict_official_func, tmp_tuple->the_var, global_inter); // 注册dict

// 注册错误类型

class_object *tmp_BaseException = BaseException_login_official(the_var, BaseException_official_func, tmp_object->the_var, global_inter);

class_object *tmp_Exception = Exception_login_official(the_var, tmp_BaseException->the_var, global_inter);

NameException_login_official(the_var, tmp_Exception->the_var, global_inter);

IterException_login_official(the_var, tmp_Exception->the_var, global_inter);

AssertException_login_official(the_var, tmp_Exception->the_var, global_inter);

AssignmentException_login_official(the_var, tmp_Exception->the_var, global_inter);

IndexException_login_official(the_var, tmp_Exception->the_var, global_inter);

KeyException_login_official(the_var, tmp_Exception->the_var, global_inter);

ImportException_login_official(the_var, tmp_Exception->the_var, global_inter);

IncludeException_login_official(the_var, tmp_Exception->the_var, global_inter);

DivZeroException_login_official(the_var, tmp_Exception->the_var, global_inter);

ValueException_login_official(the_var, tmp_Exception->the_var, global_inter);

TypeException_login_official(the_var, tmp_Exception->the_var, global_inter);

ArgsException_login_official(the_var, tmp_Exception->the_var, global_inter);

SystemctlException_login_official(the_var, tmp_Exception->the_var, global_inter);

VarException_login_official(the_var, tmp_Exception->the_var, global_inter);

}

// 合并编译:cd "/home/songzihuan/文档/CProject/gwarf/" && gcc gwarf.c -lm -o gwarf && "/home/songzihuan/文档/CProject/gwarf/"gwarf "/home/songzihuan/test.gwf"

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值