fix export/import list parsing (allow (,)), and remove unnecessary reverses
[ghc-hetmet.git] / compiler / parser / Parser.y.pp
index 3bb5ab4..1ad8d5f 100644 (file)
@@ -342,10 +342,13 @@ maybeexports :: { Maybe [LIE RdrName] }
        :  '(' exportlist ')'                   { Just $2 }
        |  {- empty -}                          { Nothing }
 
-exportlist :: { [LIE RdrName] }
-       :  exportlist ',' export                { $3 : $1 }
-       |  exportlist ','                       { $1 }
-       |  export                               { [$1]  }
+exportlist  :: { [LIE RdrName] }
+       : ','                                   { [] }
+       | exportlist1                           { $1 }
+
+exportlist1 :: { [LIE RdrName] }
+       :  export                               { [$1] }
+       |  export ',' exportlist                { $1 : $3 }
        |  {- empty -}                          { [] }
 
    -- No longer allow things like [] and (,,,) to be exported
@@ -399,8 +402,8 @@ maybeimpspec :: { Located (Maybe (Bool, [LIE RdrName])) }
        | {- empty -}                           { noLoc Nothing }
 
 impspec :: { Located (Bool, [LIE RdrName]) }
-       :  '(' exportlist ')'                   { LL (False, reverse $2) }
-       |  'hiding' '(' exportlist ')'          { LL (True,  reverse $3) }
+       :  '(' exportlist ')'                   { LL (False, $2) }
+       |  'hiding' '(' exportlist ')'          { LL (True,  $3) }
 
 -----------------------------------------------------------------------------
 -- Fixity Declarations