From ba319a7bc3a324875d64c8008d7775b59a4db2a9 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 18 Jun 2018 23:26:02 -0700 Subject: [PATCH] Finally figured out unified condition syntax --- TODO.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 1b5ccec..1409b42 100644 --- a/TODO.md +++ b/TODO.md @@ -24,9 +24,22 @@ pattern matching w/ if-let: `if \n then \n then else ` -and rest-exprs (or "targets") can have 'is' for pattern-matching, actually so can a full cond-expr -Grammar: +UNIFIED IF EXPRESSIONS FINAL WORK: + +basic syntax: + +`if_expr := if discriminator '{' (guard_expr)* '}'` +`guard_expr := pattern 'then' block_or_expr'` +`pattern := rhs | is_pattern` +`is_pattern := 'is' ???` +`rhs := expression | ???` + + +if the only two guard patterns are true and false, then the abbreviated syntax: +`'if' discriminator 'then' block_or_expr 'else' block_or_expr` +can replace `'if' discriminator '{' 'true' 'then' block_or_expr; 'false' 'then' block_or_expr '}'` + -conditional := 'if' discriminator - Next priorities: - get ADTs working, get matches working