diff options
| author | Jon French | 2018-04-23 13:31:18 +0100 |
|---|---|---|
| committer | Jon French | 2018-05-01 16:54:54 +0100 |
| commit | 319c6c6e922965cc02de969f1ce9e1e4fd0ac1d5 (patch) | |
| tree | d08f2483d7446165afa2c781fa2a4cd063392887 /src | |
| parent | be9f73fe3bdf3a269e9f3e1b53032ab62091b3d9 (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/lexer.mll | 1 | ||||
| -rw-r--r-- | src/parser.mly | 4 |
2 files changed, 4 insertions, 1 deletions
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> String Bin Hex Real %token <string> Amp At Caret Eq Gt Lt Plus Star EqGt Unit -%token <string> Colon ColonColon ExclEq +%token <string> Colon ColonColon TildeTilde ExclEq %token <string> GtEq %token <string> 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 |
