'%in' { TKin }
'%case' { TKcase }
'%of' { TKof }
- '%coerce' { TKcoerce }
+ '%cast' { TKcast }
'%note' { TKnote }
'%external' { TKexternal }
'%_' { TKwild }
'\\' { TKlambda}
'@' { TKat }
'.' { TKdot }
+ ':' { TKcolon }
'?' { TKquestion}
';' { TKsemicolon }
NAME { TKname $$ }
{ foldr Lam $4 $2 }
| '%let' vdefg '%in' exp
{ Let $2 $4 }
- | '%case' aexp '%of' vbind '{' alts1 '}'
- { Case $2 $4 $6 }
- | '%coerce' aty exp
- { Coerce $2 $3 }
+ | '%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 }
| '%external' STRING aty
cname :: { Id }
: CNAME { $1 }
-mname :: { Id }
- : CNAME { $1 }
-
-qname :: { (Id,Id) }
- : name { ("",$1) }
+mname :: { AnMname }
+ : 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 -} {[]}
+ | '.' 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
- { ($1,$3) }
+ { (Just $1,$3) }
-qcname :: { (Id,Id) }
- : mname '.' cname
- { ($1,$3) }
+qcname :: { (Mname,Id) }
+ : cname { (Nothing, $1) }
+ | mname '.' cname
+ { (Just $1,$3) }
{