summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2016-12-31 14:27:55 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2016-12-31 14:27:55 -0500
commit245eb671d45ceda8715b8850c7a5c4540da685fa (patch)
tree12f8e72a97048b4ddb531d615eb045e4f573b8a2
parentd5ae848de34109b66d2ec45fd6c0ac5a06149a68 (diff)
Allow qualified variable references in record literals
-rw-r--r--src/urweb.grm20
-rw-r--r--tests/qualrecord.ur7
2 files changed, 19 insertions, 8 deletions
diff --git a/src/urweb.grm b/src/urweb.grm
index 40101056..c1ee74f2 100644
--- a/src/urweb.grm
+++ b/src/urweb.grm
@@ -475,6 +475,7 @@ fun patternOut (e : exp) =
| eterm of exp
| etuple of exp list
| rexp of (con * exp) list * bool
+ | rpath of con
| xml of exp
| xmlOne of exp
| xmlOpt of exp
@@ -1151,15 +1152,15 @@ ctuple : capps STAR capps ([capps1, capps2])
| capps STAR ctuple (capps :: ctuple)
rcon : ([])
- | ident EQ cexp ([(ident, cexp)])
- | ident EQ cexp COMMA rcon ((ident, cexp) :: rcon)
+ | rpath EQ cexp ([(rpath, cexp)])
+ | rpath EQ cexp COMMA rcon ((rpath, cexp) :: rcon)
-rconn : ident ([(ident, (CUnit, s (identleft, identright)))])
- | ident COMMA rconn ((ident, (CUnit, s (identleft, identright))) :: rconn)
+rconn : rpath ([(rpath, (CUnit, s (rpathleft, rpathright)))])
+ | rpath COMMA rconn ((rpath, (CUnit, s (rpathleft, rpathright))) :: rconn)
rcone : ([])
- | ident COLON cexp ([(ident, cexp)])
- | ident COLON cexp COMMA rcone ((ident, cexp) :: rcone)
+ | rpath COLON cexp ([(rpath, cexp)])
+ | rpath COLON cexp COMMA rcone ((rpath, cexp) :: rcone)
ident : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
| INT (CName (Int64.toString INT), s (INTleft, INTright))
@@ -1567,8 +1568,11 @@ ptuple : pat COMMA pat ([pat1, pat2])
| pat COMMA ptuple (pat :: ptuple)
rexp : DOTDOTDOT ([], true)
- | ident EQ eexp ([(ident, eexp)], false)
- | ident EQ eexp COMMA rexp ((ident, eexp) :: #1 rexp, #2 rexp)
+ | rpath EQ eexp ([(rpath, eexp)], false)
+ | rpath EQ eexp COMMA rexp ((rpath, eexp) :: #1 rexp, #2 rexp)
+
+rpath : path (CVar path, s (pathleft, pathright))
+ | CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
xml : xmlOne xml (let
val pos = s (xmlOneleft, xmlright)
diff --git a/tests/qualrecord.ur b/tests/qualrecord.ur
new file mode 100644
index 00000000..4db64e5f
--- /dev/null
+++ b/tests/qualrecord.ur
@@ -0,0 +1,7 @@
+structure M = struct
+ con the_best_name = #Wiggles
+ con the_runner_up = #Beppo
+end
+
+val x : {M.the_best_name : int, A : int, M.the_runner_up : int} =
+ {M.the_best_name = 8, A = 9, M.the_runner_up = 10}