From b6daa01cc3f75203ca036616d0055a9ed786a1ab Mon Sep 17 00:00:00 2001 From: Mike Lowis Date: Fri, 20 Nov 2015 08:45:52 -0500 Subject: [PATCH] Tweaked expression grammar rule --- source/grammar.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) mode change 100644 => 100755 source/grammar.c diff --git a/source/grammar.c b/source/grammar.c old mode 100644 new mode 100755 index 1025e59..38d35a6 --- a/source/grammar.c +++ b/source/grammar.c @@ -55,8 +55,15 @@ static AST* require(Parser* p) static AST* expression(Parser* p) { - if (accept_str(p, T_ID, "if")) { + + if (accept(p, T_LPAR)) { + AST* expr = expression(p); + expect(p, T_RPAR); + return expr; + } else if (accept_str(p, T_ID, "if")) { return if_stmnt(p); + //} else if (accept_str(p, T_ID, "fn")) { + // return fn_stmnt(p); } else if (match(p, T_ID)) { return Ident(expect(p,T_ID)); //if (peek(p)->type == T_LPAR) { @@ -66,18 +73,6 @@ static AST* expression(Parser* p) return literal(p); } - //if (accept(p, T_LPAR)) { - // //size_t mrk = mark(p); - // expression(p); - // expect(p, T_RPAR); - // //reduce(p, mrk); - //} else if (accept_str(p, T_ID, "fn")) { - // fn_stmnt(p); - //} else if (peek(p)->type == T_ID) { - // expect(p, T_ID); - // if (peek(p)->type == T_LPAR) { - // arglist(p); - // } } static AST* if_stmnt(Parser* p) -- 2.52.0