]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
minor refactoring
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 23 May 2018 00:49:57 +0000 (20:49 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 23 May 2018 00:49:57 +0000 (20:49 -0400)
source/lexer.l
source/parser.c
source/pprint.c
source/sclpl.h

index c69e6bf17247ee168654b626847600125b0e8905..4747beaf828b353def9665aa03fa79df668817f9 100644 (file)
@@ -106,7 +106,7 @@ false {
 }
 
 "require" { return T_REQUIRE; }
-"def"     { return T_DEF;     }
+"let"     { return T_LET;     }
 "if"      { return T_IF;      }
 "fn"      { return T_FN;      }
 "then"    { return T_THEN;    }
index 205a5f0262563e6b87878cadcb6f73cf998743e0..64705a9203fb84f0ed60cfc93fb6d52f6f1ddc0d 100644 (file)
@@ -64,7 +64,7 @@ static Tok* expect_val(Parser* parser, TokType type) {
 AST* toplevel(Parser* p) {
     AST* ret = NULL;
     if (!match(p, T_END_FILE)) {
-        if (accept(p, T_DEF))
+        if (accept(p, T_LET))
             ret = const_definition(p);
         else
             error(p, "only definitions are allowed at the toplevel");
@@ -184,7 +184,7 @@ static AST* expr_block(Parser* p) {
     vec_init(&exprs);
     /* Build all expressions into let forms with no bodies */
     do {
-        if (accept(p, T_DEF)) {
+        if (accept(p, T_LET)) {
             AST* def = definition(p);
             Tok name = { .value.text = def_name(def) };
             vec_push_back(&exprs, Let(Ident(&name), def_value(def), NULL));
index f8bb6514c7ae3c3c309a145bef38b97aae661db0..7a273c606265dd9a8f738afd3e808717298d1a37 100644 (file)
@@ -130,7 +130,7 @@ void pprint_tree(FILE* file, AST* tree, int depth)
             break;
 
         case AST_DEF:
-            printf("(def %s ", def_name(tree));
+            printf("(let %s ", def_name(tree));
             pprint_tree(file, def_value(tree), depth);
             printf(")");
             break;
index b734428fcca1345180251d7114cb29250e37be04..cfb803c5cee2b0c5bb983efc0ce47e4d22f5fe2c 100644 (file)
@@ -42,7 +42,7 @@ void vec_set(vec_t* vec, size_t index, void* data);
 typedef enum {
     T_NONE, T_ID, T_CHAR, T_INT, T_FLOAT, T_BOOL, T_STRING, T_LBRACE, T_RBRACE,
     T_LBRACK, T_RBRACK, T_LPAR, T_RPAR, T_COMMA, T_SQUOTE, T_DQUOTE, T_END,
-    T_COLON, T_AMP, T_REQUIRE, T_DEF, T_IF, T_FN, T_THEN, T_ELSE, T_END_FILE
+    T_COLON, T_AMP, T_REQUIRE, T_LET, T_IF, T_FN, T_THEN, T_ELSE, T_END_FILE
 } TokType;
 
 typedef struct {
@@ -208,13 +208,7 @@ typedef struct {
     Tok tok;
 } Parser;
 
-// Lexer routines
 void gettoken(Parser* ctx, Tok* tok);
-
-// Parser routines
-Parser* parser_new(char* p_prompt, FILE* input);
-
-// Grammar Routines
 AST* toplevel(Parser* p);
 
 /* Option Parsing