From: Michael D. Lowis Date: Mon, 19 Jul 2021 20:55:16 +0000 (-0400) Subject: started modifying parser to generate ssa directly X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=1a6b152c23343c5041adc390b4732013c684d332;p=proto%2Fobnc.git started modifying parser to generate ssa directly --- diff --git a/cerise/TODO.md b/cerise/TODO.md index d793b78..2011e9d 100644 --- a/cerise/TODO.md +++ b/cerise/TODO.md @@ -29,5 +29,7 @@ * Implement borrowed pointers * Implement biased refcounting for borrowed pointers +# Improvements or Notes +* Uninited local idents and constants will have version==0 diff --git a/cerise/src/grammar.c b/cerise/src/grammar.c index e7295b6..14300cb 100644 --- a/cerise/src/grammar.c +++ b/cerise/src/grammar.c @@ -482,6 +482,10 @@ static void const_decl(Parser* p) export = accept(p, '*'); sym = symbol_new(p, 0, name, SYM_CONST, export); expect(p, '='); +// AstNode* block = ast_block(); +// expression(p, block); +// sym->value = ast_lastval(block); +// check_const(sym->value); sym->value = expression(p); sym->type = sym->value->hdr.type; } @@ -619,9 +623,19 @@ static void module(Parser* p) if (accept(p, BEGIN)) { - AstNode* block = statement_seq(p); - ast_print(p, block); - (void)block; +// p->curr_join = ast_block(); +// if (!matches(p, END)) +// { +// AstNode* block = ast_block(); +// statement_seq(p, block); +// ast_print(p, block); +// } + if (!matches(p, END)) + { + AstNode* block = statement_seq(p); + ast_print(p, block); + (void)block; + } expect(p, END); } diff --git a/cerise/tests/Module.m b/cerise/tests/Module.m index 58698a5..8749095 100644 --- a/cerise/tests/Module.m +++ b/cerise/tests/Module.m @@ -54,22 +54,22 @@ var # return z1; #end -procedure Bar*(a : Int) : Int -begin - return a; -end - -procedure Baz*(a : Int) -begin - if (1 > 2) then - 42; - else - 24; - end -end +#procedure Bar*(a : Int) : Int +#begin +# return a; +#end +# +#procedure Baz*(a : Int) +#begin +# if (1 > 2) then +# 42; +# else +# 24; +# end +#end begin - h[1].i = 42; +# h[1].i = 42; # a = true; # a = A; # b = 24; @@ -80,7 +80,7 @@ begin # b = -b; # # # Arithmetic ops - c = b + 1; +# c = b + 1; # c = b - 1; # c = b * 1; # c = b / 1; @@ -152,7 +152,7 @@ begin # c = 42; # c = 24; - Bar(Foo.testint); - Bar(Bar2.testint); - Bar(Bar3.testint); +# Bar(Foo.testint); +# Bar(Bar2.testint); +# Bar(Bar3.testint); end