From 319c6c6e922965cc02de969f1ce9e1e4fd0ac1d5 Mon Sep 17 00:00:00 2001 From: Jon French Date: Mon, 23 Apr 2018 13:31:18 +0100 Subject: add { ~~fieldname } sugar to record patterns, expanding to { fieldname = fieldname }\n\nCan't use ~ for this to be exactly like OCaml, as is used for 'not' and explicitly allowed as an identifier --- src/lexer.mll | 1 + src/parser.mly | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lexer.mll b/src/lexer.mll index 0b756d84..1fe2a849 100644 --- a/src/lexer.mll +++ b/src/lexer.mll @@ -215,6 +215,7 @@ rule token = parse | "2" ws "^" { TwoCaret } | "^" { (Caret(r"^")) } | "::" { ColonColon(r "::") } + | "~~" { TildeTilde(r "~~") } | ":" { Colon(r ":") } | "," { Comma } | ".." { DotDot } diff --git a/src/parser.mly b/src/parser.mly index c0559719..d126e253 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -177,7 +177,7 @@ let rec desugar_rchain chain s e = %token String Bin Hex Real %token Amp At Caret Eq Gt Lt Plus Star EqGt Unit -%token Colon ColonColon ExclEq +%token Colon ColonColon TildeTilde ExclEq %token GtEq %token LtEq @@ -1046,6 +1046,8 @@ atomic_exp: fexp_exp: | atomic_exp Eq exp { mk_exp (E_app_infix ($1, mk_id (Id "=") $startpos($2) $endpos($2), $3)) $startpos $endpos } + | TildeTilde id + { mk_exp (E_app_infix (mk_exp (E_id $2) $startpos($2) $endpos($2), mk_id (Id "=") $startpos $endpos, mk_exp (E_id $2) $startpos($2) $endpos($2))) $startpos $endpos } fexp_exp_list: | fexp_exp -- cgit v1.2.3