Cabalize ext-core tools
[ghc-hetmet.git] / utils / ext-core / Parser.y
index ac186e3..add3ef0 100644 (file)
@@ -173,9 +173,11 @@ exp        :: { Exp }
                { foldr Lam $4 $2 }
        | '%let' vdefg '%in' exp 
                { Let $2 $4 }
-       | '%case' ty aexp '%of' vbind '{' alts1 '}'
-               { Case $3 $5 $2 $7 }
-       | '%cast' exp aty 
+       | '%case' '(' ty ')' aexp '%of' vbind '{' alts1 '}'
+               { Case $5 $7 $3 $9 }
+-- Note: ty, not aty! You can cast something to a forall type
+-- Though now we have shift/reduce conflicts like woah
+       | '%cast' exp ty
                { Cast $2 $3 }
        | '%note' STRING exp 
                { Note $2 $3 }
@@ -211,19 +213,33 @@ cname     :: { Id }
        : CNAME { $1 }
          
 mname  :: { AnMname }
-        : pkgName ':' mnames '.' name
-             { ($1, $3, $5) }
+        : pkgName ':' cname
+             { let (parentNames, childName) = splitModuleName $3 in
+                 ($1, parentNames, childName) }
 
 pkgName :: { Id }
         : NAME { $1 }
 
+-- TODO: Clean this up. Now hierarchical names are z-encoded.
+
+-- note that a sequence of mnames is either:
+-- empty, or a series of cnames separated by
+-- dots, with a leading dot
+-- See the definition of mnames: the "name" part
+-- is required.
 mnames :: { [Id] } 
          : {- empty -} {[]}
-         | name '.' mnames {$1:$3}
+         | '.' cname mnames {$2:$3}
 
 -- it sucks to have to repeat the Maybe-checking twice,
 -- but otherwise we get reduce/reduce conflicts
 
+-- TODO: this is the ambiguity here. mname '.' name --
+-- but by maximal-munch, in GHC.Base.Bool the entire 
+-- thing gets counted as the module name. What to do,
+-- besides z-encoding the dots in the hierarchy again?
+-- (Or using syntax other than a dot to separate the
+-- module name from the variable name...)
 qname  :: { (Mname,Id) }
         : name { (Nothing, $1) }
        | mname '.' name