diff options
| author | czjstmax <jstmaxlol@disroot.org> | 2025-12-19 23:09:12 +0100 |
|---|---|---|
| committer | czjstmax <jstmaxlol@disroot.org> | 2025-12-19 23:09:12 +0100 |
| commit | fe0479de0c0305eafb1d3aa1456850af9e3b4fca (patch) | |
| tree | 6fb8cf53d09f3d2dfa95f6878f4c8c5e8354219a /rbc.c | |
| parent | bfc14c6903a0d082286d02ec2f99856da1bfb719 (diff) | |
Development started, cumulative commit #1
Diffstat (limited to 'rbc.c')
| -rw-r--r-- | rbc.c | 63 |
1 files changed, 60 insertions, 3 deletions
@@ -51,11 +51,68 @@ #include <string.h> // git@github.com:jstmaxlol/kat -#include "kat.h" +#include "headers/kat.h" + +// CReborn headers (CReborn APIs) +#include "headers/codegen.h" +#include "headers/abstract.h" +#include "headers/freeast.h" + +// ASTs in abstract.h +// + +// Functions (fwd. declars. and externs) +// +// headers/abstract.h +// headers/freeast.h +// headers/codegen.h +// +// local / helpers +static inline int Eval(int x); + +// main +int main(int argc, char **argv) { + printf(":> Checking for arguments...\n"); + if (argc >= 2) { + for (int i = 1; i < argc; i++) { + printf("argv[%d] = %s\n", i, argv[i]); + } + } else { + printf(":> No arguments were found. (%d)\n\n", argc-1); + } + + const char *ident_buff = "number"; + const char *type_buff = "int"; + + int value_buff = 2; + + if (argc == 3) { + if (strlen(argv[1]) >= 1) + ident_buff = argv[1]; + //if (strlen(argv[2]) >= 1) + // type_buff = argv[2]; + if (strlen(argv[2]) >= 1) + value_buff = atoi(argv[2]); + } + + Expr *e = ExprIntLiteral(value_buff); + Decl *decl = DeclareVariable(ident_buff, type_buff, e); + + if (decl->kind == DECL_VAR) { + DeclVar *v = decl->as; + printf("v->ident=%s, v->type=%s\nlet %s: %s = %d;", v->ident, v->type, v->ident, v->type, value_buff); + } + + FreeExpr(e); + FreeDecl(decl); -int main(/*int argc, char **argv*/) { - printf(":> [work-in-progress]\n"); return 0; } +// Functions (definitions) +// +static inline int Eval(int x) { + return x; +} + #endif |