X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Fext-core%2FParser.y;h=add3ef0b46b7dab1129525c287524207802e6b9f;hb=9f565a397c17568f725b25720a817326744777f0;hp=1e1c6a3592aa215727896901cfe36884a77e09ae;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/utils/ext-core/Parser.y b/utils/ext-core/Parser.y index 1e1c6a3..add3ef0 100644 --- a/utils/ext-core/Parser.y +++ b/utils/ext-core/Parser.y @@ -20,7 +20,7 @@ import Lex '%in' { TKin } '%case' { TKcase } '%of' { TKof } - '%coerce' { TKcoerce } + '%cast' { TKcast } '%note' { TKnote } '%external' { TKexternal } '%_' { TKwild } @@ -36,6 +36,7 @@ import Lex '\\' { TKlambda} '@' { TKat } '.' { TKdot } + ':' { TKcolon } '?' { TKquestion} ';' { TKsemicolon } NAME { TKname $$ } @@ -172,10 +173,12 @@ exp :: { Exp } { 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 @@ -209,17 +212,43 @@ name :: { Id } 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) } {