X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=utils%2Fext-core%2FParser.y;h=67db7bc523aa5bec70635ae1fe7db8ab0a75dffa;hp=ac186e399af0d7ed0eefb5d1a80542c93140bfba;hb=e6232609a0b08ff7136a479f2e2d7d2be5040b1d;hpb=276585028d51a2516a31b91a91a1f4bba5c9f8ba diff --git a/utils/ext-core/Parser.y b/utils/ext-core/Parser.y index ac186e3..67db7bc 100644 --- a/utils/ext-core/Parser.y +++ b/utils/ext-core/Parser.y @@ -8,6 +8,7 @@ import Lex } %name parse +%expect 0 %tokentype { Token } %token @@ -173,9 +174,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 +214,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