2 -----------------------------------------------------------------------------
3 $Id: Parser.y,v 1.96 2002/04/29 14:03:57 simonmar Exp $
7 Author(s): Simon Marlow, Sven Panne 1997, 1998, 1999
8 -----------------------------------------------------------------------------
12 module Parser ( parseModule, parseStmt, parseIdentifier, parseIface ) where
15 import HsTypes ( mkHsTupCon )
18 import RnMonad ( ParsedIface(..) )
22 import PrelNames ( mAIN_Name, unitTyCon_RDR, funTyCon_RDR,
23 listTyCon_RDR, parrTyCon_RDR, tupleTyCon_RDR,
24 unitCon_RDR, nilCon_RDR, tupleCon_RDR )
25 import ForeignCall ( Safety(..), CExportSpec(..),
26 CCallConv(..), CCallTarget(..), defaultCCallConv,
28 import OccName ( UserFS, varName, tcName, dataName, tcClsName, tvName )
29 import TyCon ( DataConDetails(..) )
30 import SrcLoc ( SrcLoc )
32 import CmdLineOpts ( opt_SccProfilingOn, opt_InPackage )
33 import Type ( Kind, mkArrowKind, liftedTypeKind )
34 import BasicTypes ( Boxity(..), Fixity(..), FixityDirection(..), IPName(..),
35 NewOrData(..), StrictnessMark(..), Activation(..) )
39 import CStrings ( CLabelString )
41 import Maybes ( orElse )
44 #include "HsVersions.h"
48 -----------------------------------------------------------------------------
49 Conflicts: 21 shift/reduce, -=chak[4Feb2]
51 9 for abiguity in 'if x then y else z + 1'
52 (shift parses as 'if x then y else (z + 1)', as per longest-parse rule)
53 8 because op might be: - ! * . `x` VARSYM CONSYM QVARSYM QCONSYM
54 1 for ambiguity in 'if x then y else z :: T'
55 (shift parses as 'if x then y else (z :: T)', as per longest-parse rule)
56 1 for ambiguity in 'if x then y else z with ?x=3'
57 (shift parses as 'if x then y else (z with ?x=3)'
59 3 for ambiguity in 'case x of y :: a -> b'
60 (don't know whether to reduce 'a' as a btype or shift the '->'.
61 conclusion: bogus expression anyway, doesn't matter)
63 1 for ambiguity in '{-# RULES "name" [ ... #-}
64 we don't know whether the '[' starts the activation or not: it
65 might be the start of the declaration with the activation being
68 1 for ambiguity in '{-# RULES "name" forall = ... #-}'
69 since 'forall' is a valid variable name, we don't know whether
70 to treat a forall on the input as the beginning of a quantifier
71 or the beginning of the rule itself. Resolving to shift means
72 it's always treated as a quantifier, hence the above is disallowed.
73 This saves explicitly defining a grammar for the rule lhs that
74 doesn't include 'forall'.
76 1 for ambiguity in 'let ?x ...'
77 the parser can't tell whether the ?x is the lhs of a normal binding or
78 an implicit binding. Fortunately resolving as shift gives it the only
79 sensible meaning, namely the lhs of an implicit binding.
81 6 for conflicts between `fdecl' and `fdeclDEPRECATED', which are resolved
82 correctly, and moreover, should go away when `fdeclDEPRECATED' is removed.
84 -----------------------------------------------------------------------------
88 '_' { ITunderscore } -- Haskell keywords
93 'default' { ITdefault }
94 'deriving' { ITderiving }
102 'infixl' { ITinfixl }
103 'infixr' { ITinfixr }
104 'instance' { ITinstance }
106 'module' { ITmodule }
107 'newtype' { ITnewtype }
109 'qualified' { ITqualified }
113 '_scc_' { ITscc } -- ToDo: remove
115 'forall' { ITforall } -- GHC extension keywords
116 'foreign' { ITforeign }
117 'export' { ITexport }
119 'dynamic' { ITdynamic }
121 'threadsafe' { ITthreadsafe }
122 'unsafe' { ITunsafe }
124 'stdcall' { ITstdcallconv }
125 'ccall' { ITccallconv }
126 'dotnet' { ITdotnet }
127 '_ccall_' { ITccall (False, False, PlayRisky) }
128 '_ccall_GC_' { ITccall (False, False, PlaySafe False) }
129 '_casm_' { ITccall (False, True, PlayRisky) }
130 '_casm_GC_' { ITccall (False, True, PlaySafe False) }
132 '{-# SPECIALISE' { ITspecialise_prag }
133 '{-# SOURCE' { ITsource_prag }
134 '{-# INLINE' { ITinline_prag }
135 '{-# NOINLINE' { ITnoinline_prag }
136 '{-# RULES' { ITrules_prag }
137 '{-# SCC' { ITscc_prag }
138 '{-# DEPRECATED' { ITdeprecated_prag }
139 '#-}' { ITclose_prag }
142 '__interface' { ITinterface } -- interface keywords
143 '__export' { IT__export }
144 '__instimport' { ITinstimport }
145 '__forall' { IT__forall }
146 '__letrec' { ITletrec }
147 '__coerce' { ITcoerce }
148 '__depends' { ITdepends }
149 '__inline' { ITinline }
150 '__DEFAULT' { ITdefaultbranch }
152 '__integer' { ITinteger_lit }
153 '__float' { ITfloat_lit }
154 '__rational' { ITrational_lit }
155 '__addr' { ITaddr_lit }
156 '__label' { ITlabel_lit }
157 '__litlit' { ITlit_lit }
158 '__string' { ITstring_lit }
159 '__ccall' { ITccall $$ }
161 '__sccC' { ITsccAllCafs }
164 '__P' { ITspecialise }
167 '__S' { ITstrict $$ }
168 '__M' { ITcprinfo $$ }
171 '..' { ITdotdot } -- reserved symbols
186 '{' { ITocurly } -- special symbols
190 vccurly { ITvccurly } -- virtual close curly (from layout)
203 VARID { ITvarid $$ } -- identifiers
205 VARSYM { ITvarsym $$ }
206 CONSYM { ITconsym $$ }
207 QVARID { ITqvarid $$ }
208 QCONID { ITqconid $$ }
209 QVARSYM { ITqvarsym $$ }
210 QCONSYM { ITqconsym $$ }
212 IPDUPVARID { ITdupipvarid $$ } -- GHC extension
213 IPSPLITVARID { ITsplitipvarid $$ } -- GHC extension
216 STRING { ITstring $$ }
217 INTEGER { ITinteger $$ }
218 RATIONAL { ITrational $$ }
220 PRIMCHAR { ITprimchar $$ }
221 PRIMSTRING { ITprimstring $$ }
222 PRIMINTEGER { ITprimint $$ }
223 PRIMFLOAT { ITprimfloat $$ }
224 PRIMDOUBLE { ITprimdouble $$ }
225 CLITLIT { ITlitlit $$ }
227 %monad { P } { thenP } { returnP }
228 %lexer { lexer } { ITeof }
229 %name parseModule module
230 %name parseStmt maybe_stmt
231 %name parseIdentifier identifier
232 %name parseIface iface
236 -----------------------------------------------------------------------------
239 -- The place for module deprecation is really too restrictive, but if it
240 -- was allowed at its natural place just before 'module', we get an ugly
241 -- s/r conflict with the second alternative. Another solution would be the
242 -- introduction of a new pragma DEPRECATED_MODULE, but this is not very nice,
243 -- either, and DEPRECATED is only expected to be used by people who really
244 -- know what they are doing. :-)
246 module :: { RdrNameHsModule }
247 : srcloc 'module' modid maybemoddeprec maybeexports 'where' body
248 { HsModule $3 Nothing $5 (fst $7) (snd $7) $4 $1 }
250 { HsModule mAIN_Name Nothing Nothing (fst $2) (snd $2) Nothing $1 }
252 maybemoddeprec :: { Maybe DeprecTxt }
253 : '{-# DEPRECATED' STRING '#-}' { Just $2 }
254 | {- empty -} { Nothing }
256 body :: { ([RdrNameImportDecl], [RdrNameHsDecl]) }
258 | layout_on top close { $2 }
260 top :: { ([RdrNameImportDecl], [RdrNameHsDecl]) }
261 : importdecls { (reverse $1,[]) }
262 | importdecls ';' cvtopdecls { (reverse $1,$3) }
263 | cvtopdecls { ([],$1) }
265 cvtopdecls :: { [RdrNameHsDecl] }
266 : topdecls { cvTopDecls (groupBindings $1)}
268 -----------------------------------------------------------------------------
269 -- Interfaces (.hi-boot files)
271 iface :: { ParsedIface }
272 : 'module' modid 'where' ifacebody
275 pi_pkg = opt_InPackage,
276 pi_vers = 1, -- Module version
278 pi_exports = (1,[($2,mkIfaceExports $4)]),
282 pi_decls = map (\x -> (1,x)) $4,
288 ifacebody :: { [RdrNameTyClDecl] }
289 : '{' ifacedecls '}' { $2 }
290 | layout_on ifacedecls close { $2 }
292 ifacedecls :: { [RdrNameTyClDecl] }
293 : ifacedecl ';' ifacedecls { $1 : $3 }
294 | ';' ifacedecls { $2 }
298 ifacedecl :: { RdrNameTyClDecl }
299 : srcloc 'data' tycl_hdr constrs
300 { mkTyData DataType $3 (DataCons (reverse $4)) Nothing $1 }
302 | srcloc 'newtype' tycl_hdr '=' newconstr
303 { mkTyData NewType $3 (DataCons [$5]) Nothing $1 }
305 | srcloc 'class' tycl_hdr fds where
307 (binds,sigs) = cvMonoBindsAndSigs cvClassOpSig
310 mkClassDecl $3 $4 sigs (Just binds) $1 }
312 | srcloc 'type' tycon tv_bndrs '=' ctype
313 { TySynonym $3 $4 $6 $1 }
315 | srcloc var '::' sigtype
316 { IfaceSig $2 $4 [] $1 }
318 -----------------------------------------------------------------------------
321 maybeexports :: { Maybe [RdrNameIE] }
322 : '(' exportlist ')' { Just $2 }
323 | {- empty -} { Nothing }
325 exportlist :: { [RdrNameIE] }
326 : exportlist ',' export { $3 : $1 }
327 | exportlist ',' { $1 }
331 -- GHC extension: we allow things like [] and (,,,) to be exported
332 export :: { RdrNameIE }
334 | gtycon { IEThingAbs $1 }
335 | gtycon '(' '..' ')' { IEThingAll $1 }
336 | gtycon '(' ')' { IEThingWith $1 [] }
337 | gtycon '(' qcnames ')' { IEThingWith $1 (reverse $3) }
338 | 'module' modid { IEModuleContents $2 }
340 qcnames :: { [RdrName] }
341 : qcnames ',' qcname { $3 : $1 }
344 qcname :: { RdrName }
348 -----------------------------------------------------------------------------
349 -- Import Declarations
351 -- import decls can be *empty*, or even just a string of semicolons
352 -- whereas topdecls must contain at least one topdecl.
354 importdecls :: { [RdrNameImportDecl] }
355 : importdecls ';' importdecl { $3 : $1 }
356 | importdecls ';' { $1 }
357 | importdecl { [ $1 ] }
360 importdecl :: { RdrNameImportDecl }
361 : 'import' srcloc maybe_src optqualified modid maybeas maybeimpspec
362 { ImportDecl $5 $3 $4 $6 $7 $2 }
364 maybe_src :: { WhereFrom }
365 : '{-# SOURCE' '#-}' { ImportByUserSource }
366 | {- empty -} { ImportByUser }
368 optqualified :: { Bool }
369 : 'qualified' { True }
370 | {- empty -} { False }
372 maybeas :: { Maybe ModuleName }
373 : 'as' modid { Just $2 }
374 | {- empty -} { Nothing }
376 maybeimpspec :: { Maybe (Bool, [RdrNameIE]) }
377 : impspec { Just $1 }
378 | {- empty -} { Nothing }
380 impspec :: { (Bool, [RdrNameIE]) }
381 : '(' exportlist ')' { (False, reverse $2) }
382 | 'hiding' '(' exportlist ')' { (True, reverse $3) }
384 -----------------------------------------------------------------------------
385 -- Fixity Declarations
389 | INTEGER {% checkPrec $1 `thenP_`
390 returnP (fromInteger $1) }
392 infix :: { FixityDirection }
394 | 'infixl' { InfixL }
395 | 'infixr' { InfixR }
398 : ops ',' op { $3 : $1 }
401 -----------------------------------------------------------------------------
402 -- Top-Level Declarations
404 topdecls :: { [RdrBinding] }
405 : topdecls ';' topdecl { ($3 : $1) }
406 | topdecls ';' { $1 }
409 topdecl :: { RdrBinding }
410 : srcloc 'type' tycon tv_bndrs '=' ctype
411 -- Note ctype, not sigtype.
412 -- We allow an explicit for-all but we don't insert one
413 -- in type Foo a = (b,b)
414 -- Instead we just say b is out of scope
415 { RdrHsDecl (TyClD (TySynonym $3 $4 $6 $1)) }
418 | srcloc 'data' tycl_hdr constrs deriving
419 {% returnP (RdrHsDecl (TyClD
420 (mkTyData DataType $3 (DataCons (reverse $4)) $5 $1))) }
422 | srcloc 'newtype' tycl_hdr '=' newconstr deriving
423 {% returnP (RdrHsDecl (TyClD
424 (mkTyData NewType $3 (DataCons [$5]) $6 $1))) }
426 | srcloc 'class' tycl_hdr fds where
428 (binds,sigs) = cvMonoBindsAndSigs cvClassOpSig (groupBindings $5)
430 returnP (RdrHsDecl (TyClD
431 (mkClassDecl $3 $4 sigs (Just binds) $1))) }
433 | srcloc 'instance' inst_type where
435 = cvMonoBindsAndSigs cvInstDeclSig
437 in RdrHsDecl (InstD (InstDecl $3 binds sigs Nothing $1)) }
439 | srcloc 'default' '(' comma_types0 ')' { RdrHsDecl (DefD (DefaultDecl $4 $1)) }
440 | 'foreign' fdecl { RdrHsDecl $2 }
441 | '{-# DEPRECATED' deprecations '#-}' { $2 }
442 | '{-# RULES' rules '#-}' { $2 }
445 -- tycl_hdr parses the header of a type or class decl,
446 -- which takes the form
449 -- (Eq a, Ord b) => T a b
450 -- Rather a lot of inlining here, else we get reduce/reduce errors
451 tycl_hdr :: { (RdrNameContext, RdrName, [RdrNameHsTyVar]) }
452 : '(' comma_types1 ')' '=>' gtycon tv_bndrs
453 {% mapP checkPred $2 `thenP` \ cxt ->
454 returnP (cxt, $5, $6) }
456 | '(' ')' '=>' gtycon tv_bndrs
459 -- qtycon for the class below name would lead to many s/r conflicts
460 -- FIXME: does the renamer pick up all wrong forms and raise an
462 | gtycon atypes1 '=>' gtycon atypes0
463 {% checkTyVars $5 `thenP` \ tvs ->
464 returnP ([HsClassP $1 $2], $4, tvs) }
467 {% checkTyVars $2 `thenP` \ tvs ->
468 returnP ([], $1, tvs) }
469 -- We have to have qtycon in this production to avoid s/r
470 -- conflicts with the previous one. The renamer will complain
471 -- if we use a qualified tycon.
473 -- Using a `gtycon' throughout. This enables special syntax,
474 -- such as "[]" for tycons as well as tycon ops in
475 -- parentheses. This is beyond H98, but used repeatedly in
476 -- the Prelude modules. (So, it would be a good idea to raise
477 -- an error in the renamer if some non-H98 form is used and
478 -- -fglasgow-exts is not given.) -=chak
480 decls :: { [RdrBinding] }
481 : decls ';' decl { $3 : $1 }
486 decl :: { RdrBinding }
489 | '{-# INLINE' srcloc activation qvar '#-}' { RdrSig (InlineSig True $4 $3 $2) }
490 | '{-# NOINLINE' srcloc inverse_activation qvar '#-}' { RdrSig (InlineSig False $4 $3 $2) }
491 | '{-# SPECIALISE' srcloc qvar '::' sigtypes '#-}'
492 { foldr1 RdrAndBindings
493 (map (\t -> RdrSig (SpecSig $3 t $2)) $5) }
494 | '{-# SPECIALISE' srcloc 'instance' inst_type '#-}'
495 { RdrSig (SpecInstSig $4 $2) }
497 wherebinds :: { RdrNameHsBinds }
498 : where { cvBinds cvValSig (groupBindings $1) }
500 where :: { [RdrBinding] }
501 : 'where' decllist { $2 }
504 declbinds :: { RdrNameHsBinds }
505 : decllist { cvBinds cvValSig (groupBindings $1) }
507 decllist :: { [RdrBinding] }
508 : '{' decls '}' { $2 }
509 | layout_on decls close { $2 }
511 letbinds :: { RdrNameHsExpr -> RdrNameHsExpr }
512 : decllist { HsLet (cvBinds cvValSig (groupBindings $1)) }
513 | '{' dbinds '}' { \e -> HsWith e $2 False{-not with-} }
514 | layout_on dbinds close { \e -> HsWith e $2 False{-not with-} }
516 fixdecl :: { RdrBinding }
517 : srcloc infix prec ops { foldr1 RdrAndBindings
518 [ RdrSig (FixSig (FixitySig n
522 -----------------------------------------------------------------------------
523 -- Transformation Rules
525 rules :: { RdrBinding }
526 : rules ';' rule { $1 `RdrAndBindings` $3 }
529 | {- empty -} { RdrNullBind }
531 rule :: { RdrBinding }
532 : STRING activation rule_forall infixexp '=' srcloc exp
533 { RdrHsDecl (RuleD (HsRule $1 $2 $3 $4 $7 $6)) }
535 activation :: { Activation } -- Omitted means AlwaysActive
536 : {- empty -} { AlwaysActive }
537 | explicit_activation { $1 }
539 inverse_activation :: { Activation } -- Omitted means NeverActive
540 : {- empty -} { NeverActive }
541 | explicit_activation { $1 }
543 explicit_activation :: { Activation } -- In brackets
544 : '[' INTEGER ']' { ActiveAfter (fromInteger $2) }
545 | '[' '~' INTEGER ']' { ActiveBefore (fromInteger $3) }
547 rule_forall :: { [RdrNameRuleBndr] }
548 : 'forall' rule_var_list '.' { $2 }
551 rule_var_list :: { [RdrNameRuleBndr] }
553 | rule_var rule_var_list { $1 : $2 }
555 rule_var :: { RdrNameRuleBndr }
556 : varid { RuleBndr $1 }
557 | '(' varid '::' ctype ')' { RuleBndrSig $2 $4 }
559 -----------------------------------------------------------------------------
562 deprecations :: { RdrBinding }
563 : deprecations ';' deprecation { $1 `RdrAndBindings` $3 }
564 | deprecations ';' { $1 }
566 | {- empty -} { RdrNullBind }
568 -- SUP: TEMPORARY HACK, not checking for `module Foo'
569 deprecation :: { RdrBinding }
570 : srcloc depreclist STRING
571 { foldr RdrAndBindings RdrNullBind
572 [ RdrHsDecl (DeprecD (Deprecation n $3 $1)) | n <- $2 ] }
575 -----------------------------------------------------------------------------
576 -- Foreign import and export declarations
578 -- for the time being, the following accepts foreign declarations conforming
579 -- to the FFI Addendum, Version 1.0 as well as pre-standard declarations
581 -- * a flag indicates whether pre-standard declarations have been used and
582 -- triggers a deprecation warning further down the road
584 -- NB: The first two rules could be combined into one by replacing `safety1'
585 -- with `safety'. However, the combined rule conflicts with the
588 fdecl :: { RdrNameHsDecl }
589 fdecl : srcloc 'import' callconv safety1 fspec {% mkImport $3 $4 $5 $1 }
590 | srcloc 'import' callconv fspec {% mkImport $3 (PlaySafe False) $4 $1 }
591 | srcloc 'export' callconv fspec {% mkExport $3 $4 $1 }
592 -- the following syntax is DEPRECATED
593 | srcloc fdecl1DEPRECATED { ForD ($2 True $1) }
594 | srcloc fdecl2DEPRECATED { $2 $1 }
596 fdecl1DEPRECATED :: { Bool -> SrcLoc -> ForeignDecl RdrName }
598 ----------- DEPRECATED label decls ------------
599 : 'label' ext_name varid '::' sigtype
600 { ForeignImport $3 $5 (CImport defaultCCallConv (PlaySafe False) nilFS nilFS
601 (CLabel ($2 `orElse` mkExtName $3))) }
603 ----------- DEPRECATED ccall/stdcall decls ------------
605 -- NB: This business with the case expression below may seem overly
606 -- complicated, but it is necessary to avoid some conflicts.
608 -- DEPRECATED variant #1: lack of a calling convention specification
610 | 'import' {-no callconv-} ext_name safety varid_no_unsafe '::' sigtype
612 target = StaticTarget ($2 `orElse` mkExtName $4)
614 ForeignImport $4 $6 (CImport defaultCCallConv $3 nilFS nilFS
615 (CFunction target)) }
617 -- DEPRECATED variant #2: external name consists of two separate strings
618 -- (module name and function name) (import)
619 | 'import' callconv STRING STRING safety varid_no_unsafe '::' sigtype
621 DNCall -> parseError "Illegal format of .NET foreign import"
622 CCall cconv -> returnP $
624 imp = CFunction (StaticTarget $4)
626 ForeignImport $6 $8 (CImport cconv $5 nilFS nilFS imp) }
628 -- DEPRECATED variant #3: `unsafe' after entity
629 | 'import' callconv STRING 'unsafe' varid_no_unsafe '::' sigtype
631 DNCall -> parseError "Illegal format of .NET foreign import"
632 CCall cconv -> returnP $
634 imp = CFunction (StaticTarget $3)
636 ForeignImport $5 $7 (CImport cconv PlayRisky nilFS nilFS imp) }
638 -- DEPRECATED variant #4: use of the special identifier `dynamic' without
639 -- an explicit calling convention (import)
640 | 'import' {-no callconv-} 'dynamic' safety varid_no_unsafe '::' sigtype
641 { ForeignImport $4 $6 (CImport defaultCCallConv $3 nilFS nilFS
642 (CFunction DynamicTarget)) }
644 -- DEPRECATED variant #5: use of the special identifier `dynamic' (import)
645 | 'import' callconv 'dynamic' safety varid_no_unsafe '::' sigtype
647 DNCall -> parseError "Illegal format of .NET foreign import"
648 CCall cconv -> returnP $
649 ForeignImport $5 $7 (CImport cconv $4 nilFS nilFS
650 (CFunction DynamicTarget)) }
652 -- DEPRECATED variant #6: lack of a calling convention specification
654 | 'export' {-no callconv-} ext_name varid '::' sigtype
655 { ForeignExport $3 $5 (CExport (CExportStatic ($2 `orElse` mkExtName $3)
658 -- DEPRECATED variant #7: external name consists of two separate strings
659 -- (module name and function name) (export)
660 | 'export' callconv STRING STRING varid '::' sigtype
662 DNCall -> parseError "Illegal format of .NET foreign import"
663 CCall cconv -> returnP $
665 (CExport (CExportStatic $4 cconv)) }
667 -- DEPRECATED variant #8: use of the special identifier `dynamic' without
668 -- an explicit calling convention (export)
669 | 'export' {-no callconv-} 'dynamic' varid '::' sigtype
670 { ForeignImport $3 $5 (CImport defaultCCallConv (PlaySafe False) nilFS nilFS
673 -- DEPRECATED variant #9: use of the special identifier `dynamic' (export)
674 | 'export' callconv 'dynamic' varid '::' sigtype
676 DNCall -> parseError "Illegal format of .NET foreign import"
677 CCall cconv -> returnP $
678 ForeignImport $4 $6 (CImport cconv (PlaySafe False) nilFS nilFS CWrapper) }
680 ----------- DEPRECATED .NET decls ------------
681 -- NB: removed the .NET call declaration, as it is entirely subsumed
682 -- by the new standard FFI declarations
684 fdecl2DEPRECATED :: { SrcLoc -> RdrNameHsDecl }
686 : 'import' 'dotnet' 'type' ext_name tycon
687 { \loc -> TyClD (ForeignType $5 $4 DNType loc) }
688 -- left this one unchanged for the moment as type imports are not
689 -- covered currently by the FFI standard -=chak
692 callconv :: { CallConv }
693 : 'stdcall' { CCall StdCallConv }
694 | 'ccall' { CCall CCallConv }
695 | 'dotnet' { DNCall }
698 : 'unsafe' { PlayRisky }
699 | 'safe' { PlaySafe False }
700 | 'threadsafe' { PlaySafe True }
701 | {- empty -} { PlaySafe False }
703 safety1 :: { Safety }
704 : 'unsafe' { PlayRisky }
705 | 'safe' { PlaySafe False }
706 | 'threadsafe' { PlaySafe True }
707 -- only needed to avoid conflicts with the DEPRECATED rules
709 fspec :: { (FastString, RdrName, RdrNameHsType) }
710 : STRING varid '::' sigtype { ($1 , $2, $4) }
711 | varid '::' sigtype { (nilFS, $1, $3) }
712 -- if the entity string is missing, it defaults to the empty string;
713 -- the meaning of an empty entity string depends on the calling
717 ext_name :: { Maybe CLabelString }
719 | STRING STRING { Just $2 } -- Ignore "module name" for now
720 | {- empty -} { Nothing }
723 -----------------------------------------------------------------------------
726 opt_sig :: { Maybe RdrNameHsType }
727 : {- empty -} { Nothing }
728 | '::' sigtype { Just $2 }
730 opt_asig :: { Maybe RdrNameHsType }
731 : {- empty -} { Nothing }
732 | '::' atype { Just $2 }
734 sigtypes :: { [RdrNameHsType] }
736 | sigtypes ',' sigtype { $3 : $1 }
738 sigtype :: { RdrNameHsType }
739 : ctype { mkHsForAllTy Nothing [] $1 }
741 sig_vars :: { [RdrName] }
742 : sig_vars ',' var { $3 : $1 }
745 -----------------------------------------------------------------------------
748 -- A ctype is a for-all type
749 ctype :: { RdrNameHsType }
750 : 'forall' tv_bndrs '.' ctype { mkHsForAllTy (Just $2) [] $4 }
751 | context '=>' type { mkHsForAllTy Nothing $1 $3 }
752 -- A type of form (context => type) is an *implicit* HsForAllTy
755 -- We parse a context as a btype so that we don't get reduce/reduce
756 -- errors in ctype. The basic problem is that
758 -- looks so much like a tuple type. We can't tell until we find the =>
759 context :: { RdrNameContext }
760 : btype {% checkContext $1 }
762 type :: { RdrNameHsType }
763 : gentype '->' type { HsFunTy $1 $3 }
764 | ipvar '::' type { mkHsIParamTy $1 $3 }
767 gentype :: { RdrNameHsType }
770 | atype tyconop atype { HsOpTy $1 $2 $3 }
772 btype :: { RdrNameHsType }
773 : btype atype { HsAppTy $1 $2 }
776 atype :: { RdrNameHsType }
777 : gtycon { HsTyVar $1 }
778 | tyvar { HsTyVar $1 }
779 | '(' type ',' comma_types1 ')' { HsTupleTy (mkHsTupCon tcName Boxed ($2:$4)) ($2:$4) }
780 | '(#' comma_types1 '#)' { HsTupleTy (mkHsTupCon tcName Unboxed $2) $2 }
781 | '[' type ']' { HsListTy $2 }
782 | '[:' type ':]' { HsPArrTy $2 }
783 | '(' ctype ')' { $2 }
784 | '(' ctype '::' kind ')' { HsKindSig $2 $4 }
786 | INTEGER { HsNumTy $1 }
788 -- An inst_type is what occurs in the head of an instance decl
789 -- e.g. (Foo a, Gaz b) => Wibble a b
790 -- It's kept as a single type, with a MonoDictTy at the right
791 -- hand corner, for convenience.
792 inst_type :: { RdrNameHsType }
793 : ctype {% checkInstType $1 }
795 comma_types0 :: { [RdrNameHsType] }
796 : comma_types1 { $1 }
799 comma_types1 :: { [RdrNameHsType] }
801 | type ',' comma_types1 { $1 : $3 }
803 atypes0 :: { [RdrNameHsType] }
807 atypes1 :: { [RdrNameHsType] }
809 | atype atypes1 { $1 : $2 }
811 tv_bndrs :: { [RdrNameHsTyVar] }
812 : tv_bndr tv_bndrs { $1 : $2 }
815 tv_bndr :: { RdrNameHsTyVar }
816 : tyvar { UserTyVar $1 }
817 | '(' tyvar '::' kind ')' { IfaceTyVar $2 $4 }
819 fds :: { [([RdrName], [RdrName])] }
821 | '|' fds1 { reverse $2 }
823 fds1 :: { [([RdrName], [RdrName])] }
824 : fds1 ',' fd { $3 : $1 }
827 fd :: { ([RdrName], [RdrName]) }
828 : varids0 '->' varids0 { (reverse $1, reverse $3) }
830 varids0 :: { [RdrName] }
832 | varids0 tyvar { $2 : $1 }
834 -----------------------------------------------------------------------------
839 | akind '->' kind { mkArrowKind $1 $3 }
842 : '*' { liftedTypeKind }
843 | '(' kind ')' { $2 }
846 -----------------------------------------------------------------------------
847 -- Datatype declarations
849 newconstr :: { RdrNameConDecl }
850 : srcloc conid atype { mkConDecl $2 [] [] (VanillaCon [unbangedType $3]) $1 }
851 | srcloc conid '{' var '::' ctype '}'
852 { mkConDecl $2 [] [] (RecCon [([$4], unbangedType $6)]) $1 }
854 constrs :: { [RdrNameConDecl] }
855 : {- empty; a GHC extension -} { [] }
856 | '=' constrs1 { $2 }
858 constrs1 :: { [RdrNameConDecl] }
859 : constrs1 '|' constr { $3 : $1 }
862 constr :: { RdrNameConDecl }
863 : srcloc forall context '=>' constr_stuff
864 { mkConDecl (fst $5) $2 $3 (snd $5) $1 }
865 | srcloc forall constr_stuff
866 { mkConDecl (fst $3) $2 [] (snd $3) $1 }
868 forall :: { [RdrNameHsTyVar] }
869 : 'forall' tv_bndrs '.' { $2 }
872 constr_stuff :: { (RdrName, RdrNameConDetails) }
873 : btype {% mkVanillaCon $1 [] }
874 | btype '!' atype satypes {% mkVanillaCon $1 (BangType MarkedUserStrict $3 : $4) }
875 | gtycon '{' '}' {% mkRecCon $1 [] }
876 | gtycon '{' fielddecls '}' {% mkRecCon $1 $3 }
877 | sbtype conop sbtype { ($2, InfixCon $1 $3) }
879 satypes :: { [RdrNameBangType] }
880 : atype satypes { unbangedType $1 : $2 }
881 | '!' atype satypes { BangType MarkedUserStrict $2 : $3 }
884 sbtype :: { RdrNameBangType }
885 : btype { unbangedType $1 }
886 | '!' atype { BangType MarkedUserStrict $2 }
888 fielddecls :: { [([RdrName],RdrNameBangType)] }
889 : fielddecl ',' fielddecls { $1 : $3 }
892 fielddecl :: { ([RdrName],RdrNameBangType) }
893 : sig_vars '::' stype { (reverse $1, $3) }
895 stype :: { RdrNameBangType }
896 : ctype { unbangedType $1 }
897 | '!' atype { BangType MarkedUserStrict $2 }
899 deriving :: { Maybe RdrNameContext }
900 : {- empty -} { Nothing }
901 | 'deriving' context { Just $2 }
902 -- Glasgow extension: allow partial
903 -- applications in derivings
905 -----------------------------------------------------------------------------
908 {- There's an awkward overlap with a type signature. Consider
909 f :: Int -> Int = ...rhs...
910 Then we can't tell whether it's a type signature or a value
911 definition with a result signature until we see the '='.
912 So we have to inline enough to postpone reductions until we know.
916 ATTENTION: Dirty Hackery Ahead! If the second alternative of vars is var
917 instead of qvar, we get another shift/reduce-conflict. Consider the
920 { (^^) :: Int->Int ; } Type signature; only var allowed
922 { (^^) :: Int->Int = ... ; } Value defn with result signature;
923 qvar allowed (because of instance decls)
925 We can't tell whether to reduce var to qvar until after we've read the signatures.
928 valdef :: { RdrBinding }
929 : infixexp srcloc opt_sig rhs {% (checkValDef $1 $3 $4 $2) }
930 | infixexp srcloc '::' sigtype {% (checkValSig $1 $4 $2) }
931 | var ',' sig_vars srcloc '::' sigtype { foldr1 RdrAndBindings
932 [ RdrSig (Sig n $6 $4) | n <- $1:$3 ]
936 rhs :: { RdrNameGRHSs }
937 : '=' srcloc exp wherebinds { (GRHSs (unguardedRHS $3 $2) $4 placeHolderType)}
938 | gdrhs wherebinds { GRHSs (reverse $1) $2 placeHolderType }
940 gdrhs :: { [RdrNameGRHS] }
941 : gdrhs gdrh { $2 : $1 }
944 gdrh :: { RdrNameGRHS }
945 : '|' srcloc quals '=' exp { GRHS (reverse (ResultStmt $5 $2 : $3)) $2 }
947 -----------------------------------------------------------------------------
950 exp :: { RdrNameHsExpr }
951 : infixexp '::' sigtype { (ExprWithTySig $1 $3) }
952 | infixexp 'with' dbinding { HsWith $1 $3 True{-not a let-} }
955 infixexp :: { RdrNameHsExpr }
957 | infixexp qop exp10 { (OpApp $1 (HsVar $2)
958 (panic "fixity") $3 )}
960 exp10 :: { RdrNameHsExpr }
961 : '\\' srcloc aexp aexps opt_asig '->' srcloc exp
962 {% checkPatterns $2 ($3 : reverse $4) `thenP` \ ps ->
963 returnP (HsLam (Match ps $5
964 (GRHSs (unguardedRHS $8 $7)
965 EmptyBinds placeHolderType))) }
966 | 'let' letbinds 'in' exp { $2 $4 }
967 | 'if' srcloc exp 'then' exp 'else' exp { HsIf $3 $5 $7 $2 }
968 | 'case' srcloc exp 'of' altslist { HsCase $3 $5 $2 }
969 | '-' fexp { mkHsNegApp $2 }
970 | srcloc 'do' stmtlist {% checkDo $3 `thenP` \ stmts ->
971 returnP (HsDo DoExpr stmts $1) }
973 | '_ccall_' ccallid aexps0 { HsCCall $2 $3 PlayRisky False placeHolderType }
974 | '_ccall_GC_' ccallid aexps0 { HsCCall $2 $3 (PlaySafe False) False placeHolderType }
975 | '_casm_' CLITLIT aexps0 { HsCCall $2 $3 PlayRisky True placeHolderType }
976 | '_casm_GC_' CLITLIT aexps0 { HsCCall $2 $3 (PlaySafe False) True placeHolderType }
978 | scc_annot exp { if opt_SccProfilingOn
984 scc_annot :: { FastString }
985 : '_scc_' STRING { $2 }
986 | '{-# SCC' STRING '#-}' { $2 }
988 ccallid :: { FastString }
992 fexp :: { RdrNameHsExpr }
993 : fexp aexp { (HsApp $1 $2) }
996 aexps0 :: { [RdrNameHsExpr] }
997 : aexps { reverse $1 }
999 aexps :: { [RdrNameHsExpr] }
1000 : aexps aexp { $2 : $1 }
1001 | {- empty -} { [] }
1003 aexp :: { RdrNameHsExpr }
1004 : qvar '@' aexp { EAsPat $1 $3 }
1005 | '~' aexp { ELazyPat $2 }
1008 aexp1 :: { RdrNameHsExpr }
1009 : var_or_con '{|' gentype '|}' { (HsApp $1 (HsType $3)) }
1010 | aexp1 '{' fbinds '}' {% (mkRecConstrOrUpdate $1
1014 var_or_con :: { RdrNameHsExpr }
1018 aexp2 :: { RdrNameHsExpr }
1019 : ipvar { HsIPVar $1 }
1021 | literal { HsLit $1 }
1022 | INTEGER { HsOverLit (mkHsIntegral $1) }
1023 | RATIONAL { HsOverLit (mkHsFractional $1) }
1024 | '(' exp ')' { HsPar $2 }
1025 | '(' exp ',' texps ')' { ExplicitTuple ($2 : reverse $4) Boxed}
1026 | '(#' texps '#)' { ExplicitTuple (reverse $2) Unboxed }
1027 | '[' list ']' { $2 }
1028 | '[:' parr ':]' { $2 }
1029 | '(' infixexp qop ')' { (SectionL $2 (HsVar $3)) }
1030 | '(' qopm infixexp ')' { (SectionR $2 $3) }
1033 texps :: { [RdrNameHsExpr] }
1034 : texps ',' exp { $3 : $1 }
1038 -----------------------------------------------------------------------------
1041 -- The rules below are little bit contorted to keep lexps left-recursive while
1042 -- avoiding another shift/reduce-conflict.
1044 list :: { RdrNameHsExpr }
1045 : exp { ExplicitList placeHolderType [$1] }
1046 | lexps { ExplicitList placeHolderType (reverse $1) }
1047 | exp '..' { ArithSeqIn (From $1) }
1048 | exp ',' exp '..' { ArithSeqIn (FromThen $1 $3) }
1049 | exp '..' exp { ArithSeqIn (FromTo $1 $3) }
1050 | exp ',' exp '..' exp { ArithSeqIn (FromThenTo $1 $3 $5) }
1051 | exp srcloc pquals {% let { body [qs] = qs;
1052 body qss = [ParStmt (map reverse qss)] }
1054 returnP ( HsDo ListComp
1055 (reverse (ResultStmt $1 $2 : body $3))
1060 lexps :: { [RdrNameHsExpr] }
1061 : lexps ',' exp { $3 : $1 }
1062 | exp ',' exp { [$3,$1] }
1064 -----------------------------------------------------------------------------
1065 -- List Comprehensions
1067 pquals :: { [[RdrNameStmt]] }
1068 : pquals '|' quals { $3 : $1 }
1069 | '|' quals { [$2] }
1071 quals :: { [RdrNameStmt] }
1072 : quals ',' stmt { $3 : $1 }
1075 -----------------------------------------------------------------------------
1076 -- Parallel array expressions
1078 -- The rules below are little bit contorted; see the list case for details.
1079 -- Note that, in contrast to lists, we only have finite arithmetic sequences.
1080 -- Moreover, we allow explicit arrays with no element (represented by the nil
1081 -- constructor in the list case).
1083 parr :: { RdrNameHsExpr }
1084 : { ExplicitPArr placeHolderType [] }
1085 | exp { ExplicitPArr placeHolderType [$1] }
1086 | lexps { ExplicitPArr placeHolderType
1088 | exp '..' exp { PArrSeqIn (FromTo $1 $3) }
1089 | exp ',' exp '..' exp { PArrSeqIn (FromThenTo $1 $3 $5) }
1090 | exp srcloc pquals {% let {
1097 (reverse (ResultStmt $1 $2
1102 -- We are reusing `lexps' and `pquals' from the list case.
1104 -----------------------------------------------------------------------------
1105 -- Case alternatives
1107 altslist :: { [RdrNameMatch] }
1108 : '{' alts '}' { reverse $2 }
1109 | layout_on alts close { reverse $2 }
1111 alts :: { [RdrNameMatch] }
1115 alts1 :: { [RdrNameMatch] }
1116 : alts1 ';' alt { $3 : $1 }
1120 alt :: { RdrNameMatch }
1121 : srcloc infixexp opt_sig ralt wherebinds
1122 {% (checkPattern $1 $2 `thenP` \p ->
1123 returnP (Match [p] $3
1124 (GRHSs $4 $5 placeHolderType)) )}
1126 ralt :: { [RdrNameGRHS] }
1127 : '->' srcloc exp { [GRHS [ResultStmt $3 $2] $2] }
1128 | gdpats { reverse $1 }
1130 gdpats :: { [RdrNameGRHS] }
1131 : gdpats gdpat { $2 : $1 }
1134 gdpat :: { RdrNameGRHS }
1135 : srcloc '|' quals '->' exp { GRHS (reverse (ResultStmt $5 $1:$3)) $1}
1137 -----------------------------------------------------------------------------
1138 -- Statement sequences
1140 stmtlist :: { [RdrNameStmt] }
1141 : '{' stmts '}' { $2 }
1142 | layout_on_for_do stmts close { $2 }
1144 -- do { ;; s ; s ; ; s ;; }
1145 -- The last Stmt should be a ResultStmt, but that's hard to enforce
1146 -- here, because we need too much lookahead if we see do { e ; }
1147 -- So we use ExprStmts throughout, and switch the last one over
1148 -- in ParseUtils.checkDo instead
1149 stmts :: { [RdrNameStmt] }
1150 : stmt stmts_help { $1 : $2 }
1152 | {- empty -} { [] }
1154 stmts_help :: { [RdrNameStmt] }
1156 | {- empty -} { [] }
1158 -- For typing stmts at the GHCi prompt, where
1159 -- the input may consist of just comments.
1160 maybe_stmt :: { Maybe RdrNameStmt }
1162 | {- nothing -} { Nothing }
1164 stmt :: { RdrNameStmt }
1165 : srcloc infixexp '<-' exp {% checkPattern $1 $2 `thenP` \p ->
1166 returnP (BindStmt p $4 $1) }
1167 | srcloc exp { ExprStmt $2 placeHolderType $1 }
1168 | srcloc 'let' declbinds { LetStmt $3 }
1170 -----------------------------------------------------------------------------
1171 -- Record Field Update/Construction
1173 fbinds :: { RdrNameHsRecordBinds }
1174 : fbinds ',' fbind { $3 : $1 }
1177 | {- empty -} { [] }
1179 fbind :: { (RdrName, RdrNameHsExpr, Bool) }
1180 : qvar '=' exp { ($1,$3,False) }
1182 -----------------------------------------------------------------------------
1183 -- Implicit Parameter Bindings
1185 dbinding :: { [(IPName RdrName, RdrNameHsExpr)] }
1186 : '{' dbinds '}' { $2 }
1187 | layout_on dbinds close { $2 }
1189 dbinds :: { [(IPName RdrName, RdrNameHsExpr)] }
1190 : dbinds ';' dbind { $3 : $1 }
1193 -- | {- empty -} { [] }
1195 dbind :: { (IPName RdrName, RdrNameHsExpr) }
1196 dbind : ipvar '=' exp { ($1, $3) }
1198 -----------------------------------------------------------------------------
1199 -- Variables, Constructors and Operators.
1201 identifier :: { RdrName }
1206 depreclist :: { [RdrName] }
1207 depreclist : deprec_var { [$1] }
1208 | deprec_var ',' depreclist { $1 : $3 }
1210 deprec_var :: { RdrName }
1211 deprec_var : var { $1 }
1214 gtycon :: { RdrName }
1216 | '(' qtyconop ')' { $2 }
1217 | '(' ')' { unitTyCon_RDR }
1218 | '(' '->' ')' { funTyCon_RDR }
1219 | '[' ']' { listTyCon_RDR }
1220 | '[:' ':]' { parrTyCon_RDR }
1221 | '(' commas ')' { tupleTyCon_RDR $2 }
1223 gcon :: { RdrName } -- Data constructor namespace
1224 : '(' ')' { unitCon_RDR }
1225 | '[' ']' { nilCon_RDR }
1226 | '(' commas ')' { tupleCon_RDR $2 }
1228 -- the case of '[:' ':]' is part of the production `parr'
1232 | '(' varsym ')' { $2 }
1236 | '(' varsym ')' { $2 }
1237 | '(' qvarsym1 ')' { $2 }
1238 -- We've inlined qvarsym here so that the decision about
1239 -- whether it's a qvar or a var can be postponed until
1240 -- *after* we see the close paren.
1242 ipvar :: { IPName RdrName }
1243 : IPDUPVARID { Dupable (mkUnqual varName $1) }
1244 | IPSPLITVARID { Linear (mkUnqual varName $1) }
1248 | '(' qconsym ')' { $2 }
1250 varop :: { RdrName }
1252 | '`' varid '`' { $2 }
1254 qvarop :: { RdrName }
1256 | '`' qvarid '`' { $2 }
1258 qvaropm :: { RdrName }
1259 : qvarsym_no_minus { $1 }
1260 | '`' qvarid '`' { $2 }
1262 conop :: { RdrName }
1264 | '`' conid '`' { $2 }
1266 qconop :: { RdrName }
1268 | '`' qconid '`' { $2 }
1270 -----------------------------------------------------------------------------
1273 op :: { RdrName } -- used in infix decls
1277 qop :: { RdrName {-HsExpr-} } -- used in sections
1281 qopm :: { RdrNameHsExpr } -- used in sections
1282 : qvaropm { HsVar $1 }
1283 | qconop { HsVar $1 }
1285 -----------------------------------------------------------------------------
1288 qvarid :: { RdrName }
1290 | QVARID { mkQual varName $1 }
1292 varid :: { RdrName }
1293 : varid_no_unsafe { $1 }
1294 | 'unsafe' { mkUnqual varName FSLIT("unsafe") }
1295 | 'safe' { mkUnqual varName FSLIT("safe") }
1296 | 'threadsafe' { mkUnqual varName FSLIT("threadsafe") }
1298 varid_no_unsafe :: { RdrName }
1299 : VARID { mkUnqual varName $1 }
1300 | special_id { mkUnqual varName $1 }
1301 | 'forall' { mkUnqual varName FSLIT("forall") }
1303 tyvar :: { RdrName }
1304 : VARID { mkUnqual tvName $1 }
1305 | special_id { mkUnqual tvName $1 }
1306 | 'unsafe' { mkUnqual tvName FSLIT("unsafe") }
1307 | 'safe' { mkUnqual tvName FSLIT("safe") }
1308 | 'threadsafe' { mkUnqual tvName FSLIT("threadsafe") }
1310 -- These special_ids are treated as keywords in various places,
1311 -- but as ordinary ids elsewhere. 'special_id' collects all these
1312 -- except 'unsafe' and 'forall' whose treatment differs depending on context
1313 special_id :: { UserFS }
1315 : 'as' { FSLIT("as") }
1316 | 'qualified' { FSLIT("qualified") }
1317 | 'hiding' { FSLIT("hiding") }
1318 | 'export' { FSLIT("export") }
1319 | 'label' { FSLIT("label") }
1320 | 'dynamic' { FSLIT("dynamic") }
1321 | 'stdcall' { FSLIT("stdcall") }
1322 | 'ccall' { FSLIT("ccall") }
1324 -----------------------------------------------------------------------------
1327 qconid :: { RdrName } -- Qualified or unqualifiedb
1329 | QCONID { mkQual dataName $1 }
1331 conid :: { RdrName }
1332 : CONID { mkUnqual dataName $1 }
1334 -----------------------------------------------------------------------------
1337 qconsym :: { RdrName } -- Qualified or unqualifiedb
1339 | QCONSYM { mkQual dataName $1 }
1341 consym :: { RdrName }
1342 : CONSYM { mkUnqual dataName $1 }
1344 -----------------------------------------------------------------------------
1347 qvarsym :: { RdrName }
1351 qvarsym_no_minus :: { RdrName }
1352 : varsym_no_minus { $1 }
1355 qvarsym1 :: { RdrName }
1356 qvarsym1 : QVARSYM { mkQual varName $1 }
1358 varsym :: { RdrName }
1359 : varsym_no_minus { $1 }
1360 | '-' { mkUnqual varName FSLIT("-") }
1362 varsym_no_minus :: { RdrName } -- varsym not including '-'
1363 : VARSYM { mkUnqual varName $1 }
1364 | special_sym { mkUnqual varName $1 }
1367 -- See comments with special_id
1368 special_sym :: { UserFS }
1369 special_sym : '!' { FSLIT("!") }
1370 | '.' { FSLIT(".") }
1371 | '*' { FSLIT("*") }
1373 -----------------------------------------------------------------------------
1376 literal :: { HsLit }
1377 : CHAR { HsChar $1 }
1378 | STRING { HsString $1 }
1379 | PRIMINTEGER { HsIntPrim $1 }
1380 | PRIMCHAR { HsCharPrim $1 }
1381 | PRIMSTRING { HsStringPrim $1 }
1382 | PRIMFLOAT { HsFloatPrim $1 }
1383 | PRIMDOUBLE { HsDoublePrim $1 }
1384 | CLITLIT { HsLitLit $1 placeHolderType }
1386 srcloc :: { SrcLoc } : {% getSrcLocP }
1388 -----------------------------------------------------------------------------
1392 : vccurly { () } -- context popped in lexer.
1393 | error {% popContext }
1395 layout_on :: { () } : {% layoutOn True{-strict-} }
1396 layout_on_for_do :: { () } : {% layoutOn False }
1398 -----------------------------------------------------------------------------
1399 -- Miscellaneous (mostly renamings)
1401 modid :: { ModuleName }
1402 : CONID { mkModuleNameFS $1 }
1403 | QCONID { mkModuleNameFS
1405 (unpackFS (fst $1) ++
1406 '.':unpackFS (snd $1)))
1409 tycon :: { RdrName }
1410 : CONID { mkUnqual tcClsName $1 }
1412 tyconop :: { RdrName }
1413 : CONSYM { mkUnqual tcClsName $1 }
1415 qtycon :: { RdrName } -- Qualified or unqualified
1416 : QCONID { mkQual tcClsName $1 }
1419 qtyconop :: { RdrName } -- Qualified or unqualified
1420 : QCONSYM { mkQual tcClsName $1 }
1424 : commas ',' { $1 + 1 }
1427 -----------------------------------------------------------------------------
1431 happyError buf PState{ loc = loc } = PFailed (srcParseErr buf loc)