From: Michael D. Lowis Date: Wed, 23 May 2018 20:41:55 +0000 (-0400) Subject: checkpoint commit X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=0773f054977f1a7f6a3045937bcdebd9bb51d296;p=proto%2Fsclpl.git checkpoint commit --- diff --git a/source/ast.c b/source/ast.c index 4917d2c..5299d72 100644 --- a/source/ast.c +++ b/source/ast.c @@ -113,20 +113,6 @@ char* ident_value(AST* val) return val->value.text; } -AST* Require(Tok* name) -{ - AST* node = ast(AST_REQ); - node->value.text = name->value.text; - return node; -} - -char* require_name(AST* req) -{ - assert(req != NULL); - assert(req->type == AST_REQ); - return req->value.text; -} - AST* Def(Tok* name, AST* value) { AST* node = ast(AST_DEF); @@ -241,39 +227,3 @@ void fnapp_add_arg(AST* fnapp, AST* arg) vec_push_back(&(fnapp->value.fnapp.args), arg); } -AST* Let(AST* temp, AST* val, AST* body) -{ - AST* node = ast(AST_LET); - node->value.let.temp = temp; - node->value.let.value = val; - node->value.let.body = body; - return node; -} - -AST* let_var(AST* let) -{ - return let->value.let.temp; -} - -AST* let_val(AST* let) -{ - return let->value.let.value; -} - -AST* let_body(AST* let) -{ - return let->value.let.body; -} - -void let_set_body(AST* let, AST* body) -{ - let->value.let.body = body; -} - -AST* TempVar(void) -{ - static intptr_t val = 0; - AST* node = ast(AST_TEMP); - node->value.integer = val++; - return node; -} diff --git a/source/sclpl.h b/source/sclpl.h index 5335413..b0eee89 100644 --- a/source/sclpl.h +++ b/source/sclpl.h @@ -63,7 +63,7 @@ typedef struct { *****************************************************************************/ typedef enum { AST_STRING, AST_SYMBOL, AST_CHAR, AST_INT, AST_FLOAT, AST_BOOL, AST_IDENT, - AST_REQ, AST_DEF, AST_IF, AST_FUNC, AST_FNAPP, AST_LET, AST_TEMP + AST_DEF, AST_IF, AST_FUNC, AST_FNAPP } ASTType; typedef struct AST { @@ -91,12 +91,6 @@ typedef struct AST { struct AST* fn; vec_t args; } fnapp; - /* Let Expression */ - struct { - struct AST* temp; - struct AST* value; - struct AST* body; - } let; /* String, Symbol, Identifier */ char* text; /* Character */ @@ -138,14 +132,6 @@ bool bool_value(AST* val); AST* Ident(Tok* val); char* ident_value(AST* val); -/* Temp Variable */ -AST* TempVar(void); -intptr_t temp_value(AST* val); - -/* Require */ -AST* Require(Tok* name); -char* require_name(AST* req); - /* Definition */ AST* Def(Tok* name, AST* value); char* def_name(AST* def); @@ -174,26 +160,6 @@ void fnapp_set_fn(AST* fnapp, AST* fn); vec_t* fnapp_args(AST* fnapp); void fnapp_add_arg(AST* func, AST* arg); -/* Let Expression */ -AST* Let(AST* temp, AST* val, AST* body); -AST* let_var(AST* let); -AST* let_val(AST* let); -AST* let_body(AST* let); -void let_set_body(AST* let, AST* body); - -/* Symbol Table - *****************************************************************************/ -typedef struct SymTable { - struct SymTable* next; - char* name; -} SymTable; - -SymTable* symbol_new(void); -SymTable* symbol_push(SymTable* top, SymTable* newtop); -SymTable* symbol_pop(SymTable* top); -SymTable* symbol_get(const char* name); -SymTable* symbol_map(SymTable* top, void (*apply)(SymTable*, void*), void* arg); - /* Pretty Printing *****************************************************************************/ void pprint_token_type(FILE* file, Tok* token);