]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
refactored
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 20 May 2018 01:07:06 +0000 (21:07 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 20 May 2018 01:07:06 +0000 (21:07 -0400)
source/parser.c

index a579a92e7ffea636c4c85578b803a72adad77845..5b036ebb5ba7568ab630d51cd8361c5e35c2fd52 100644 (file)
@@ -45,15 +45,14 @@ AST* toplevel(Parser* p)
             ret = definition(p);
         else
             error(p, "expressions are not allowed at the toplevel");
-            //ret = expression(p);
     }
     return ret;
 }
 
 static AST* definition(Parser* p)
 {
-    Tok* id = expect(p, T_ID);
     AST* expr;
+    Tok* id = expect(p, T_ID);
     if (peek(p)->type == T_LPAR) {
         expr = function(p);
     } else {
@@ -87,9 +86,8 @@ static AST* expression(Parser* p)
         expr = literal(p);
     }
     /* Check if this is a function application */
-    if (peek(p)->type == T_LPAR) {
+    if (peek(p)->type == T_LPAR)
         expr = func_app(p, expr);
-    }
     return expr;
 }