diff --git a/grammar.txt b/grammar.txt index 73af91c..962dfe0 100644 --- a/grammar.txt +++ b/grammar.txt @@ -3,7 +3,7 @@ expression -> // | apply | unary | binary -// | let + | let | compound | control | field @@ -17,16 +17,19 @@ binary -> expression operator expression ; operator -> | "==" | "!=" | "<" | "<=" | ">" | ">=" | "+" | "-" | "*" | "/" -// | "|>" | "<|" | ">>" | "<<" + | "|>" | "<|" | ">>" | "<<" | "++" ; +pattern -> "_" | record_pattern | variant_pattern | identifier ; +record_pattern -> "{" ( identifier ( "=" pattern )? ( "," identifier ( "=" pattern )? )* ) ( "|" identifier ) "}" +variant_pattern -> "`" identifier ( "(" ( "_" | compound_pattern | identifier ) ")" )? ; +let -> "let" pattern "=" expression ( "and" pattern "=" expression )* "in" expression ; control -> | if | when if -> "if" expression "then" expression "else" expression ; -variant_pattern -> "`" identifier ( "(" ( ( "_" | identifier ) ( "," ( "_" | identifier )* )? ) ")" )? ; -when -> "when" expression "is" ( variant_pattern "=>" expression )+ ; +when -> "when" expression "is" ( pattern "=>" expression )+ ; compound -> variant | record | list ; -variant -> "`" identifier ( "(" ( expression ( "," expression)* )? ")" )? ; +variant -> "`" identifier ( "(" expression ")" )? ; base_record -> expression ( "with" identifier "=" expression ( "," "with" identifier "=" expression )* )? record -> "{" ( identifier ("=" expression)? ( "," identifier ("=" expression)? )* )? ( "|" base_record )* "}" ;