diff src/lacweb.grm @ 34:44b5405e74c7

Elaborating module projection
author Adam Chlipala <adamc@hcoop.net>
date Tue, 17 Jun 2008 16:38:54 -0400
parents e6ccf961d8a3
children e3d3c2791105
line wrap: on
line diff
--- a/src/lacweb.grm	Thu Jun 12 17:41:32 2008 -0400
+++ b/src/lacweb.grm	Tue Jun 17 16:38:54 2008 -0400
@@ -60,6 +60,9 @@
  | kind of kind
  | kcolon of explicitness
 
+ | path of string list * string
+ | spath of str
+
  | cexp of con
  | capps of con
  | cterm of con
@@ -126,7 +129,10 @@
        | sgi sgis                       (sgi :: sgis)
 
 str    : STRUCT decls END               (StrConst decls, s (STRUCTleft, ENDright))
-       | CSYMBOL                        (StrVar CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
+       | spath                          (spath)
+
+spath  : CSYMBOL                        (StrVar CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
+       | spath DOT CSYMBOL              (StrProj (spath, CSYMBOL), s (spathleft, CSYMBOLright))
 
 kind   : TYPE                           (KType, s (TYPEleft, TYPEright))
        | NAME                           (KName, s (NAMEleft, NAMEright))
@@ -153,6 +159,9 @@
 kcolon : DCOLON                         (Explicit)
        | TCOLON                         (Implicit)
 
+path   : SYMBOL                         ([], SYMBOL)
+       | CSYMBOL DOT path               (let val (ms, x) = path in (CSYMBOL :: ms, x) end)
+
 cterm  : LPAREN cexp RPAREN             (#1 cexp, s (LPARENleft, RPARENright))
        | LBRACK rcon RBRACK             (CRecord rcon, s (LBRACKleft, RBRACKright))
        | LBRACE rcone RBRACE            (TRecord (CRecord rcone, s (LBRACEleft, RBRACEright)),
@@ -160,7 +169,7 @@
        | DOLLAR cterm                   (TRecord cterm, s (DOLLARleft, ctermright))
        | HASH CSYMBOL                   (CName CSYMBOL, s (HASHleft, CSYMBOLright))
 
-       | SYMBOL                         (CVar SYMBOL, s (SYMBOLleft, SYMBOLright))
+       | path                           (CVar path, s (pathleft, pathright))
        | UNDER                          (CWild (KWild, s (UNDERleft, UNDERright)), s (UNDERleft, UNDERright))
 
 rcon   :                                ([])
@@ -172,7 +181,7 @@
        | ident COLON cexp COMMA rcone   ((ident, cexp) :: rcone)
 
 ident  : CSYMBOL                        (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
-       | SYMBOL                         (CVar SYMBOL, s (SYMBOLleft, SYMBOLright))
+       | SYMBOL                         (CVar ([], SYMBOL), s (SYMBOLleft, SYMBOLright))
 
 eapps  : eterm                          (eterm)
        | eapps eterm                    (EApp (eapps, eterm), s (eappsleft, etermright))
@@ -188,7 +197,7 @@
 
 eterm  : LPAREN eexp RPAREN             (#1 eexp, s (LPARENleft, RPARENright))
 
-       | SYMBOL                         (EVar SYMBOL, s (SYMBOLleft, SYMBOLright))
+       | path                           (EVar path, s (pathleft, pathright))
        | LBRACE rexp RBRACE             (ERecord rexp, s (LBRACEleft, RBRACEright))
 
        | INT                            (EPrim (Prim.Int INT), s (INTleft, INTright))