2 -----------------------------------------------------------------------------
3 $Id: Parser.y,v 1.106 2002/10/09 15:03:53 simonpj Exp $
7 Author(s): Simon Marlow, Sven Panne 1997, 1998, 1999
8 -----------------------------------------------------------------------------
12 module Parser ( parseModule, parseStmt, parseIdentifier, parseIface ) where
14 #include "HsVersions.h"
17 import HsTypes ( mkHsTupCon )
20 import HscTypes ( ParsedIface(..), IsBootInterface )
23 import PrelNames ( mAIN_Name, funTyConName, listTyConName,
24 parrTyConName, consDataConName, nilDataConName )
25 import TysWiredIn ( unitTyCon, unitDataCon, tupleTyCon, tupleCon )
26 import ForeignCall ( Safety(..), CExportSpec(..),
27 CCallConv(..), CCallTarget(..), defaultCCallConv,
29 import OccName ( UserFS, varName, tcName, dataName, tcClsName, tvName )
30 import TyCon ( DataConDetails(..) )
31 import SrcLoc ( SrcLoc )
33 import CmdLineOpts ( opt_SccProfilingOn, opt_InPackage )
34 import Type ( Kind, mkArrowKind, liftedTypeKind )
35 import BasicTypes ( Boxity(..), Fixity(..), FixityDirection(..), IPName(..),
36 NewOrData(..), StrictnessMark(..), Activation(..),
41 import CStrings ( CLabelString )
43 import Maybes ( orElse )
49 -----------------------------------------------------------------------------
50 Conflicts: 29 shift/reduce, [SDM 19/9/2002]
52 10 for abiguity in 'if x then y else z + 1' [State 136]
53 (shift parses as 'if x then y else (z + 1)', as per longest-parse rule)
54 10 because op might be: : - ! * . `x` VARSYM CONSYM QVARSYM QCONSYM
56 1 for ambiguity in 'if x then y else z with ?x=3' [State 136]
57 (shift parses as 'if x then y else (z with ?x=3)'
59 1 for ambiguity in 'if x then y else z :: T' [State 136]
60 (shift parses as 'if x then y else (z :: T)', as per longest-parse rule)
62 8 for ambiguity in 'e :: a `b` c'. Does this mean [States 160,246]
66 1 for ambiguity in 'let ?x ...' [State 268]
67 the parser can't tell whether the ?x is the lhs of a normal binding or
68 an implicit binding. Fortunately resolving as shift gives it the only
69 sensible meaning, namely the lhs of an implicit binding.
71 1 for ambiguity in '{-# RULES "name" [ ... #-} [State 332]
72 we don't know whether the '[' starts the activation or not: it
73 might be the start of the declaration with the activation being
76 1 for ambiguity in '{-# RULES "name" forall = ... #-}' [State 394]
77 since 'forall' is a valid variable name, we don't know whether
78 to treat a forall on the input as the beginning of a quantifier
79 or the beginning of the rule itself. Resolving to shift means
80 it's always treated as a quantifier, hence the above is disallowed.
81 This saves explicitly defining a grammar for the rule lhs that
82 doesn't include 'forall'.
84 6 for conflicts between `fdecl' and `fdeclDEPRECATED', [States 384,385]
85 which are resolved correctly, and moreover,
86 should go away when `fdeclDEPRECATED' is removed.
88 -----------------------------------------------------------------------------
92 '_' { ITunderscore } -- Haskell keywords
97 'default' { ITdefault }
98 'deriving' { ITderiving }
101 'hiding' { IThiding }
103 'import' { ITimport }
106 'infixl' { ITinfixl }
107 'infixr' { ITinfixr }
108 'instance' { ITinstance }
110 'module' { ITmodule }
111 'newtype' { ITnewtype }
113 'qualified' { ITqualified }
117 '_scc_' { ITscc } -- ToDo: remove
119 'forall' { ITforall } -- GHC extension keywords
120 'foreign' { ITforeign }
121 'export' { ITexport }
123 'dynamic' { ITdynamic }
125 'threadsafe' { ITthreadsafe }
126 'unsafe' { ITunsafe }
129 'stdcall' { ITstdcallconv }
130 'ccall' { ITccallconv }
131 'dotnet' { ITdotnet }
132 '_ccall_' { ITccall (False, False, PlayRisky) }
133 '_ccall_GC_' { ITccall (False, False, PlaySafe False) }
134 '_casm_' { ITccall (False, True, PlayRisky) }
135 '_casm_GC_' { ITccall (False, True, PlaySafe False) }
137 '{-# SPECIALISE' { ITspecialise_prag }
138 '{-# SOURCE' { ITsource_prag }
139 '{-# INLINE' { ITinline_prag }
140 '{-# NOINLINE' { ITnoinline_prag }
141 '{-# RULES' { ITrules_prag }
142 '{-# SCC' { ITscc_prag }
143 '{-# DEPRECATED' { ITdeprecated_prag }
144 '#-}' { ITclose_prag }
147 '__interface' { ITinterface } -- interface keywords
148 '__export' { IT__export }
149 '__instimport' { ITinstimport }
150 '__forall' { IT__forall }
151 '__letrec' { ITletrec }
152 '__coerce' { ITcoerce }
153 '__depends' { ITdepends }
154 '__inline' { ITinline }
155 '__DEFAULT' { ITdefaultbranch }
157 '__integer' { ITinteger_lit }
158 '__float' { ITfloat_lit }
159 '__rational' { ITrational_lit }
160 '__addr' { ITaddr_lit }
161 '__label' { ITlabel_lit }
162 '__litlit' { ITlit_lit }
163 '__string' { ITstring_lit }
164 '__ccall' { ITccall $$ }
166 '__sccC' { ITsccAllCafs }
169 '__P' { ITspecialise }
172 '__S' { ITstrict $$ }
173 '__M' { ITcprinfo $$ }
176 '..' { ITdotdot } -- reserved symbols
192 '{' { ITocurly } -- special symbols
196 vccurly { ITvccurly } -- virtual close curly (from layout)
209 VARID { ITvarid $$ } -- identifiers
211 VARSYM { ITvarsym $$ }
212 CONSYM { ITconsym $$ }
213 QVARID { ITqvarid $$ }
214 QCONID { ITqconid $$ }
215 QVARSYM { ITqvarsym $$ }
216 QCONSYM { ITqconsym $$ }
218 IPDUPVARID { ITdupipvarid $$ } -- GHC extension
219 IPSPLITVARID { ITsplitipvarid $$ } -- GHC extension
222 STRING { ITstring $$ }
223 INTEGER { ITinteger $$ }
224 RATIONAL { ITrational $$ }
226 PRIMCHAR { ITprimchar $$ }
227 PRIMSTRING { ITprimstring $$ }
228 PRIMINTEGER { ITprimint $$ }
229 PRIMFLOAT { ITprimfloat $$ }
230 PRIMDOUBLE { ITprimdouble $$ }
231 CLITLIT { ITlitlit $$ }
234 '[|' { ITopenExpQuote }
235 '[p|' { ITopenPatQuote }
236 '[t|' { ITopenTypQuote }
237 '[d|' { ITopenDecQuote }
238 '|]' { ITcloseQuote }
239 ID_SPLICE { ITidEscape $$ } -- $x
240 '$(' { ITparenEscape } -- $( exp )
242 %monad { P } { thenP } { returnP }
243 %lexer { lexer } { ITeof }
244 %name parseModule module
245 %name parseStmt maybe_stmt
246 %name parseIdentifier identifier
247 %name parseIface iface
251 -----------------------------------------------------------------------------
254 -- The place for module deprecation is really too restrictive, but if it
255 -- was allowed at its natural place just before 'module', we get an ugly
256 -- s/r conflict with the second alternative. Another solution would be the
257 -- introduction of a new pragma DEPRECATED_MODULE, but this is not very nice,
258 -- either, and DEPRECATED is only expected to be used by people who really
259 -- know what they are doing. :-)
261 module :: { RdrNameHsModule }
262 : srcloc 'module' modid maybemoddeprec maybeexports 'where' body
263 { HsModule (mkHomeModule $3) Nothing $5 (fst $7) (snd $7) $4 $1 }
265 { HsModule (mkHomeModule mAIN_Name) Nothing Nothing
266 (fst $2) (snd $2) Nothing $1 }
268 maybemoddeprec :: { Maybe DeprecTxt }
269 : '{-# DEPRECATED' STRING '#-}' { Just $2 }
270 | {- empty -} { Nothing }
272 body :: { ([RdrNameImportDecl], [RdrNameHsDecl]) }
274 | layout_on top close { $2 }
276 top :: { ([RdrNameImportDecl], [RdrNameHsDecl]) }
277 : importdecls { (reverse $1,[]) }
278 | importdecls ';' cvtopdecls { (reverse $1,$3) }
279 | cvtopdecls { ([],$1) }
281 cvtopdecls :: { [RdrNameHsDecl] }
282 : topdecls { cvTopDecls $1 }
284 -----------------------------------------------------------------------------
285 -- Interfaces (.hi-boot files)
287 iface :: { ParsedIface }
288 : 'module' modid 'where' ifacebody
291 pi_pkg = opt_InPackage,
292 pi_vers = 1, -- Module version
294 pi_exports = (1,[($2,mkIfaceExports $4)]),
298 pi_decls = map (\x -> (1,x)) $4,
304 ifacebody :: { [RdrNameTyClDecl] }
305 : '{' ifacedecls '}' { $2 }
306 | layout_on ifacedecls close { $2 }
308 ifacedecls :: { [RdrNameTyClDecl] }
309 : ifacedecl ';' ifacedecls { $1 : $3 }
310 | ';' ifacedecls { $2 }
314 ifacedecl :: { RdrNameTyClDecl }
316 | srcloc var '::' sigtype { 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 -- No longer allow things like [] and (,,,) to be exported
332 -- They are built in syntax, always available
333 export :: { RdrNameIE }
335 | oqtycon { IEThingAbs $1 }
336 | oqtycon '(' '..' ')' { IEThingAll $1 }
337 | oqtycon '(' ')' { IEThingWith $1 [] }
338 | oqtycon '(' qcnames ')' { IEThingWith $1 (reverse $3) }
339 | 'module' modid { IEModuleContents $2 }
341 qcnames :: { [RdrName] }
342 : qcnames ',' qcname { $3 : $1 }
345 qcname :: { RdrName } -- Variable or data constructor
349 -----------------------------------------------------------------------------
350 -- Import Declarations
352 -- import decls can be *empty*, or even just a string of semicolons
353 -- whereas topdecls must contain at least one topdecl.
355 importdecls :: { [RdrNameImportDecl] }
356 : importdecls ';' importdecl { $3 : $1 }
357 | importdecls ';' { $1 }
358 | importdecl { [ $1 ] }
361 importdecl :: { RdrNameImportDecl }
362 : 'import' srcloc maybe_src optqualified modid maybeas maybeimpspec
363 { ImportDecl $5 $3 $4 $6 $7 $2 }
365 maybe_src :: { IsBootInterface }
366 : '{-# SOURCE' '#-}' { True }
367 | {- empty -} { False }
369 optqualified :: { Bool }
370 : 'qualified' { True }
371 | {- empty -} { False }
373 maybeas :: { Maybe ModuleName }
374 : 'as' modid { Just $2 }
375 | {- empty -} { Nothing }
377 maybeimpspec :: { Maybe (Bool, [RdrNameIE]) }
378 : impspec { Just $1 }
379 | {- empty -} { Nothing }
381 impspec :: { (Bool, [RdrNameIE]) }
382 : '(' exportlist ')' { (False, reverse $2) }
383 | 'hiding' '(' exportlist ')' { (True, reverse $3) }
385 -----------------------------------------------------------------------------
386 -- Fixity Declarations
390 | INTEGER {% checkPrecP (fromInteger $1) }
392 infix :: { FixityDirection }
394 | 'infixl' { InfixL }
395 | 'infixr' { InfixR }
398 : ops ',' op { $3 : $1 }
401 -----------------------------------------------------------------------------
402 -- Top-Level Declarations
404 topdecls :: { [RdrBinding] } -- Reversed
405 : topdecls ';' topdecl { $3 : $1 }
406 | topdecls ';' { $1 }
409 topdecl :: { RdrBinding }
410 : tycl_decl { RdrHsDecl (TyClD $1) }
411 | srcloc 'instance' inst_type where
412 { let (binds,sigs) = cvMonoBindsAndSigs $4
413 in RdrHsDecl (InstD (InstDecl $3 binds sigs Nothing $1)) }
414 | srcloc 'default' '(' comma_types0 ')' { RdrHsDecl (DefD (DefaultDecl $4 $1)) }
415 | 'foreign' fdecl { RdrHsDecl $2 }
416 | '{-# DEPRECATED' deprecations '#-}' { RdrBindings $2 }
417 | '{-# RULES' rules '#-}' { RdrBindings $2 }
418 | '$(' exp ')' { RdrHsDecl (SpliceD $2) }
421 tycl_decl :: { RdrNameTyClDecl }
422 : srcloc 'type' syn_hdr '=' ctype
423 -- Note ctype, not sigtype.
424 -- We allow an explicit for-all but we don't insert one
425 -- in type Foo a = (b,b)
426 -- Instead we just say b is out of scope
427 { let (tc,tvs) = $3 in TySynonym tc tvs $5 $1 }
430 | srcloc 'data' tycl_hdr constrs deriving
431 { mkTyData DataType $3 (DataCons (reverse $4)) $5 $1 }
433 | srcloc 'newtype' tycl_hdr '=' newconstr deriving
434 { mkTyData NewType $3 (DataCons [$5]) $6 $1 }
436 | srcloc 'class' tycl_hdr fds where
438 (binds,sigs) = cvMonoBindsAndSigs $5
440 mkClassDecl $3 $4 (map cvClassOpSig sigs) (Just binds) $1 }
442 syn_hdr :: { (RdrName, [RdrNameHsTyVar]) } -- We don't retain the syntax of an infix
443 -- type synonym declaration. Oh well.
444 : tycon tv_bndrs { ($1, $2) }
445 | tv_bndr tyconop tv_bndr { ($2, [$1,$3]) }
447 -- tycl_hdr parses the header of a type or class decl,
448 -- which takes the form
451 -- (Eq a, Ord b) => T a b
452 -- Rather a lot of inlining here, else we get reduce/reduce errors
453 tycl_hdr :: { (RdrNameContext, RdrName, [RdrNameHsTyVar]) }
454 : context '=>' type {% checkTyClHdr $3 `thenP` \ (tc,tvs) ->
455 returnP ($1, tc, tvs) }
456 | type {% checkTyClHdr $1 `thenP` \ (tc,tvs) ->
457 returnP ([], tc, tvs) }
459 -----------------------------------------------------------------------------
460 -- Nested declarations
462 decls :: { [RdrBinding] } -- Reversed
463 : decls ';' decl { $3 : $1 }
469 wherebinds :: { RdrNameHsBinds }
470 : where { cvBinds $1 }
472 where :: { [RdrBinding] } -- Reversed
473 : 'where' decllist { $2 }
476 decllist :: { [RdrBinding] } -- Reversed
477 : '{' decls '}' { $2 }
478 | layout_on decls close { $2 }
480 letbinds :: { RdrNameHsExpr -> RdrNameHsExpr }
481 : decllist { HsLet (cvBinds $1) }
482 | '{' dbinds '}' { \e -> HsWith e $2 False{-not with-} }
483 | layout_on dbinds close { \e -> HsWith e $2 False{-not with-} }
487 -----------------------------------------------------------------------------
488 -- Transformation Rules
490 rules :: { [RdrBinding] }
491 : rule ';' rules { $1 : $3 }
495 rule :: { RdrBinding }
496 : STRING activation rule_forall infixexp '=' srcloc exp
497 { RdrHsDecl (RuleD (HsRule $1 $2 $3 $4 $7 $6)) }
499 activation :: { Activation } -- Omitted means AlwaysActive
500 : {- empty -} { AlwaysActive }
501 | explicit_activation { $1 }
503 inverse_activation :: { Activation } -- Omitted means NeverActive
504 : {- empty -} { NeverActive }
505 | explicit_activation { $1 }
507 explicit_activation :: { Activation } -- In brackets
508 : '[' INTEGER ']' { ActiveAfter (fromInteger $2) }
509 | '[' '~' INTEGER ']' { ActiveBefore (fromInteger $3) }
511 rule_forall :: { [RdrNameRuleBndr] }
512 : 'forall' rule_var_list '.' { $2 }
515 rule_var_list :: { [RdrNameRuleBndr] }
517 | rule_var rule_var_list { $1 : $2 }
519 rule_var :: { RdrNameRuleBndr }
520 : varid { RuleBndr $1 }
521 | '(' varid '::' ctype ')' { RuleBndrSig $2 $4 }
523 -----------------------------------------------------------------------------
526 deprecations :: { [RdrBinding] }
527 : deprecation ';' deprecations { $1 : $3 }
528 | deprecation { [$1] }
531 -- SUP: TEMPORARY HACK, not checking for `module Foo'
532 deprecation :: { RdrBinding }
533 : srcloc depreclist STRING
535 [ RdrHsDecl (DeprecD (Deprecation n $3 $1)) | n <- $2 ] }
538 -----------------------------------------------------------------------------
539 -- Foreign import and export declarations
541 -- for the time being, the following accepts foreign declarations conforming
542 -- to the FFI Addendum, Version 1.0 as well as pre-standard declarations
544 -- * a flag indicates whether pre-standard declarations have been used and
545 -- triggers a deprecation warning further down the road
547 -- NB: The first two rules could be combined into one by replacing `safety1'
548 -- with `safety'. However, the combined rule conflicts with the
551 fdecl :: { RdrNameHsDecl }
552 fdecl : srcloc 'import' callconv safety1 fspec {% mkImport $3 $4 $5 $1 }
553 | srcloc 'import' callconv fspec {% mkImport $3 (PlaySafe False) $4 $1 }
554 | srcloc 'export' callconv fspec {% mkExport $3 $4 $1 }
555 -- the following syntax is DEPRECATED
556 | srcloc fdecl1DEPRECATED { ForD ($2 True $1) }
557 | srcloc fdecl2DEPRECATED { $2 $1 }
559 fdecl1DEPRECATED :: { Bool -> SrcLoc -> ForeignDecl RdrName }
561 ----------- DEPRECATED label decls ------------
562 : 'label' ext_name varid '::' sigtype
563 { ForeignImport $3 $5 (CImport defaultCCallConv (PlaySafe False) nilFS nilFS
564 (CLabel ($2 `orElse` mkExtName $3))) }
566 ----------- DEPRECATED ccall/stdcall decls ------------
568 -- NB: This business with the case expression below may seem overly
569 -- complicated, but it is necessary to avoid some conflicts.
571 -- DEPRECATED variant #1: lack of a calling convention specification
573 | 'import' {-no callconv-} ext_name safety varid_no_unsafe '::' sigtype
575 target = StaticTarget ($2 `orElse` mkExtName $4)
577 ForeignImport $4 $6 (CImport defaultCCallConv $3 nilFS nilFS
578 (CFunction target)) }
580 -- DEPRECATED variant #2: external name consists of two separate strings
581 -- (module name and function name) (import)
582 | 'import' callconv STRING STRING safety varid_no_unsafe '::' sigtype
584 DNCall -> parseError "Illegal format of .NET foreign import"
585 CCall cconv -> returnP $
587 imp = CFunction (StaticTarget $4)
589 ForeignImport $6 $8 (CImport cconv $5 nilFS nilFS imp) }
591 -- DEPRECATED variant #3: `unsafe' after entity
592 | 'import' callconv STRING 'unsafe' varid_no_unsafe '::' sigtype
594 DNCall -> parseError "Illegal format of .NET foreign import"
595 CCall cconv -> returnP $
597 imp = CFunction (StaticTarget $3)
599 ForeignImport $5 $7 (CImport cconv PlayRisky nilFS nilFS imp) }
601 -- DEPRECATED variant #4: use of the special identifier `dynamic' without
602 -- an explicit calling convention (import)
603 | 'import' {-no callconv-} 'dynamic' safety varid_no_unsafe '::' sigtype
604 { ForeignImport $4 $6 (CImport defaultCCallConv $3 nilFS nilFS
605 (CFunction DynamicTarget)) }
607 -- DEPRECATED variant #5: use of the special identifier `dynamic' (import)
608 | 'import' callconv 'dynamic' safety varid_no_unsafe '::' sigtype
610 DNCall -> parseError "Illegal format of .NET foreign import"
611 CCall cconv -> returnP $
612 ForeignImport $5 $7 (CImport cconv $4 nilFS nilFS
613 (CFunction DynamicTarget)) }
615 -- DEPRECATED variant #6: lack of a calling convention specification
617 | 'export' {-no callconv-} ext_name varid '::' sigtype
618 { ForeignExport $3 $5 (CExport (CExportStatic ($2 `orElse` mkExtName $3)
621 -- DEPRECATED variant #7: external name consists of two separate strings
622 -- (module name and function name) (export)
623 | 'export' callconv STRING STRING varid '::' sigtype
625 DNCall -> parseError "Illegal format of .NET foreign import"
626 CCall cconv -> returnP $
628 (CExport (CExportStatic $4 cconv)) }
630 -- DEPRECATED variant #8: use of the special identifier `dynamic' without
631 -- an explicit calling convention (export)
632 | 'export' {-no callconv-} 'dynamic' varid '::' sigtype
633 { ForeignImport $3 $5 (CImport defaultCCallConv (PlaySafe False) nilFS nilFS
636 -- DEPRECATED variant #9: use of the special identifier `dynamic' (export)
637 | 'export' callconv 'dynamic' varid '::' sigtype
639 DNCall -> parseError "Illegal format of .NET foreign import"
640 CCall cconv -> returnP $
641 ForeignImport $4 $6 (CImport cconv (PlaySafe False) nilFS nilFS CWrapper) }
643 ----------- DEPRECATED .NET decls ------------
644 -- NB: removed the .NET call declaration, as it is entirely subsumed
645 -- by the new standard FFI declarations
647 fdecl2DEPRECATED :: { SrcLoc -> RdrNameHsDecl }
649 : 'import' 'dotnet' 'type' ext_name tycon
650 { \loc -> TyClD (ForeignType $5 $4 DNType loc) }
651 -- left this one unchanged for the moment as type imports are not
652 -- covered currently by the FFI standard -=chak
655 callconv :: { CallConv }
656 : 'stdcall' { CCall StdCallConv }
657 | 'ccall' { CCall CCallConv }
658 | 'dotnet' { DNCall }
661 : 'unsafe' { PlayRisky }
662 | 'safe' { PlaySafe False }
663 | 'threadsafe' { PlaySafe True }
664 | {- empty -} { PlaySafe False }
666 safety1 :: { Safety }
667 : 'unsafe' { PlayRisky }
668 | 'safe' { PlaySafe False }
669 | 'threadsafe' { PlaySafe True }
670 -- only needed to avoid conflicts with the DEPRECATED rules
672 fspec :: { (FastString, RdrName, RdrNameHsType) }
673 : STRING var '::' sigtype { ($1 , $2, $4) }
674 | var '::' sigtype { (nilFS, $1, $3) }
675 -- if the entity string is missing, it defaults to the empty string;
676 -- the meaning of an empty entity string depends on the calling
680 ext_name :: { Maybe CLabelString }
682 | STRING STRING { Just $2 } -- Ignore "module name" for now
683 | {- empty -} { Nothing }
686 -----------------------------------------------------------------------------
689 opt_sig :: { Maybe RdrNameHsType }
690 : {- empty -} { Nothing }
691 | '::' sigtype { Just $2 }
693 opt_asig :: { Maybe RdrNameHsType }
694 : {- empty -} { Nothing }
695 | '::' atype { Just $2 }
697 sigtypes :: { [RdrNameHsType] }
699 | sigtypes ',' sigtype { $3 : $1 }
701 sigtype :: { RdrNameHsType }
702 : ctype { mkHsForAllTy Nothing [] $1 }
704 sig_vars :: { [RdrName] }
705 : sig_vars ',' var { $3 : $1 }
708 -----------------------------------------------------------------------------
711 -- A ctype is a for-all type
712 ctype :: { RdrNameHsType }
713 : 'forall' tv_bndrs '.' ctype { mkHsForAllTy (Just $2) [] $4 }
714 | context '=>' type { mkHsForAllTy Nothing $1 $3 }
715 -- A type of form (context => type) is an *implicit* HsForAllTy
718 -- We parse a context as a btype so that we don't get reduce/reduce
719 -- errors in ctype. The basic problem is that
721 -- looks so much like a tuple type. We can't tell until we find the =>
722 context :: { RdrNameContext }
723 : btype {% checkContext $1 }
725 type :: { RdrNameHsType }
726 : ipvar '::' gentype { mkHsIParamTy $1 $3 }
729 gentype :: { RdrNameHsType }
731 | btype qtyconop gentype { HsOpTy $1 (HsTyOp $2) $3 }
732 | btype '`' tyvar '`' gentype { HsOpTy $1 (HsTyOp $3) $5 }
733 | btype '->' gentype { HsOpTy $1 HsArrow $3 }
735 btype :: { RdrNameHsType }
736 : btype atype { HsAppTy $1 $2 }
739 atype :: { RdrNameHsType }
740 : gtycon { HsTyVar $1 }
741 | tyvar { HsTyVar $1 }
742 | '(' type ',' comma_types1 ')' { HsTupleTy (mkHsTupCon tcName Boxed ($2:$4)) ($2:$4) }
743 | '(#' comma_types1 '#)' { HsTupleTy (mkHsTupCon tcName Unboxed $2) $2 }
744 | '[' type ']' { HsListTy $2 }
745 | '[:' type ':]' { HsPArrTy $2 }
746 | '(' ctype ')' { HsParTy $2 }
747 | '(' ctype '::' kind ')' { HsKindSig $2 $4 }
749 | INTEGER { HsNumTy $1 }
751 -- An inst_type is what occurs in the head of an instance decl
752 -- e.g. (Foo a, Gaz b) => Wibble a b
753 -- It's kept as a single type, with a MonoDictTy at the right
754 -- hand corner, for convenience.
755 inst_type :: { RdrNameHsType }
756 : ctype {% checkInstType $1 }
758 comma_types0 :: { [RdrNameHsType] }
759 : comma_types1 { $1 }
762 comma_types1 :: { [RdrNameHsType] }
764 | type ',' comma_types1 { $1 : $3 }
766 tv_bndrs :: { [RdrNameHsTyVar] }
767 : tv_bndr tv_bndrs { $1 : $2 }
770 tv_bndr :: { RdrNameHsTyVar }
771 : tyvar { UserTyVar $1 }
772 | '(' tyvar '::' kind ')' { IfaceTyVar $2 $4 }
774 fds :: { [([RdrName], [RdrName])] }
776 | '|' fds1 { reverse $2 }
778 fds1 :: { [([RdrName], [RdrName])] }
779 : fds1 ',' fd { $3 : $1 }
782 fd :: { ([RdrName], [RdrName]) }
783 : varids0 '->' varids0 { (reverse $1, reverse $3) }
785 varids0 :: { [RdrName] }
787 | varids0 tyvar { $2 : $1 }
789 -----------------------------------------------------------------------------
794 | akind '->' kind { mkArrowKind $1 $3 }
797 : '*' { liftedTypeKind }
798 | '(' kind ')' { $2 }
801 -----------------------------------------------------------------------------
802 -- Datatype declarations
804 newconstr :: { RdrNameConDecl }
805 : srcloc conid atype { ConDecl $2 [] [] (PrefixCon [unbangedType $3]) $1 }
806 | srcloc conid '{' var '::' ctype '}'
807 { ConDecl $2 [] [] (RecCon [($4, unbangedType $6)]) $1 }
809 constrs :: { [RdrNameConDecl] }
810 : {- empty; a GHC extension -} { [] }
811 | '=' constrs1 { $2 }
813 constrs1 :: { [RdrNameConDecl] }
814 : constrs1 '|' constr { $3 : $1 }
817 constr :: { RdrNameConDecl }
818 : srcloc forall context '=>' constr_stuff
819 { ConDecl (fst $5) $2 $3 (snd $5) $1 }
820 | srcloc forall constr_stuff
821 { ConDecl (fst $3) $2 [] (snd $3) $1 }
823 forall :: { [RdrNameHsTyVar] }
824 : 'forall' tv_bndrs '.' { $2 }
827 constr_stuff :: { (RdrName, RdrNameConDetails) }
828 : btype {% mkPrefixCon $1 [] }
829 | btype '!' atype satypes {% mkPrefixCon $1 (BangType MarkedUserStrict $3 : $4) }
830 | oqtycon '{' '}' {% mkRecCon $1 [] }
831 | oqtycon '{' fielddecls '}' {% mkRecCon $1 $3 }
832 | sbtype conop sbtype { ($2, InfixCon $1 $3) }
834 satypes :: { [RdrNameBangType] }
835 : atype satypes { unbangedType $1 : $2 }
836 | '!' atype satypes { BangType MarkedUserStrict $2 : $3 }
839 sbtype :: { RdrNameBangType }
840 : btype { unbangedType $1 }
841 | '!' atype { BangType MarkedUserStrict $2 }
843 fielddecls :: { [([RdrName],RdrNameBangType)] }
844 : fielddecl ',' fielddecls { $1 : $3 }
847 fielddecl :: { ([RdrName],RdrNameBangType) }
848 : sig_vars '::' stype { (reverse $1, $3) }
850 stype :: { RdrNameBangType }
851 : ctype { unbangedType $1 }
852 | '!' atype { BangType MarkedUserStrict $2 }
854 deriving :: { Maybe RdrNameContext }
855 : {- empty -} { Nothing }
856 | 'deriving' context { Just $2 }
857 -- Glasgow extension: allow partial
858 -- applications in derivings
860 -----------------------------------------------------------------------------
863 {- There's an awkward overlap with a type signature. Consider
864 f :: Int -> Int = ...rhs...
865 Then we can't tell whether it's a type signature or a value
866 definition with a result signature until we see the '='.
867 So we have to inline enough to postpone reductions until we know.
871 ATTENTION: Dirty Hackery Ahead! If the second alternative of vars is var
872 instead of qvar, we get another shift/reduce-conflict. Consider the
875 { (^^) :: Int->Int ; } Type signature; only var allowed
877 { (^^) :: Int->Int = ... ; } Value defn with result signature;
878 qvar allowed (because of instance decls)
880 We can't tell whether to reduce var to qvar until after we've read the signatures.
883 decl :: { RdrBinding }
885 | infixexp srcloc opt_sig rhs {% checkValDef $1 $3 $4 $2 }
887 rhs :: { RdrNameGRHSs }
888 : '=' srcloc exp wherebinds { GRHSs (unguardedRHS $3 $2) $4 placeHolderType }
889 | gdrhs wherebinds { GRHSs (reverse $1) $2 placeHolderType }
891 gdrhs :: { [RdrNameGRHS] }
892 : gdrhs gdrh { $2 : $1 }
895 gdrh :: { RdrNameGRHS }
896 : '|' srcloc quals '=' exp { GRHS (reverse (ResultStmt $5 $2 : $3)) $2 }
898 sigdecl :: { RdrBinding }
899 : infixexp srcloc '::' sigtype
900 {% checkValSig $1 $4 $2 }
901 -- See the above notes for why we need infixexp here
902 | var ',' sig_vars srcloc '::' sigtype
903 { mkSigDecls [ Sig n $6 $4 | n <- $1:$3 ] }
904 | srcloc infix prec ops { mkSigDecls [ FixSig (FixitySig n (Fixity $3 $2) $1)
906 | '{-# INLINE' srcloc activation qvar '#-}'
907 { RdrHsDecl (SigD (InlineSig True $4 $3 $2)) }
908 | '{-# NOINLINE' srcloc inverse_activation qvar '#-}'
909 { RdrHsDecl (SigD (InlineSig False $4 $3 $2)) }
910 | '{-# SPECIALISE' srcloc qvar '::' sigtypes '#-}'
911 { mkSigDecls [ SpecSig $3 t $2 | t <- $5] }
912 | '{-# SPECIALISE' srcloc 'instance' inst_type '#-}'
913 { RdrHsDecl (SigD (SpecInstSig $4 $2)) }
915 -----------------------------------------------------------------------------
918 exp :: { RdrNameHsExpr }
919 : infixexp '::' sigtype { ExprWithTySig $1 $3 }
920 | infixexp 'with' dbinding { HsWith $1 $3 True{-not a let-} }
923 infixexp :: { RdrNameHsExpr }
925 | infixexp qop exp10 { (OpApp $1 (HsVar $2)
926 (panic "fixity") $3 )}
928 exp10 :: { RdrNameHsExpr }
929 : '\\' srcloc aexp aexps opt_asig '->' srcloc exp
930 {% checkPatterns $2 ($3 : reverse $4) `thenP` \ ps ->
931 returnP (HsLam (Match ps $5
932 (GRHSs (unguardedRHS $8 $7)
933 EmptyBinds placeHolderType))) }
934 | 'let' letbinds 'in' exp { $2 $4 }
935 | 'if' srcloc exp 'then' exp 'else' exp { HsIf $3 $5 $7 $2 }
936 | 'case' srcloc exp 'of' altslist { HsCase $3 $5 $2 }
937 | '-' fexp { mkHsNegApp $2 }
938 | srcloc 'do' stmtlist {% checkDo $3 `thenP` \ stmts ->
939 returnP (mkHsDo DoExpr stmts $1) }
940 | srcloc 'mdo' stmtlist {% checkMDo $3 `thenP` \ stmts ->
941 returnP (mkHsDo MDoExpr stmts $1) }
943 | '_ccall_' ccallid aexps0 { HsCCall $2 $3 PlayRisky False placeHolderType }
944 | '_ccall_GC_' ccallid aexps0 { HsCCall $2 $3 (PlaySafe False) False placeHolderType }
945 | '_casm_' CLITLIT aexps0 { HsCCall $2 $3 PlayRisky True placeHolderType }
946 | '_casm_GC_' CLITLIT aexps0 { HsCCall $2 $3 (PlaySafe False) True placeHolderType }
948 | scc_annot exp { if opt_SccProfilingOn
954 scc_annot :: { FastString }
955 : '_scc_' STRING { $2 }
956 | '{-# SCC' STRING '#-}' { $2 }
958 ccallid :: { FastString }
962 fexp :: { RdrNameHsExpr }
963 : fexp aexp { (HsApp $1 $2) }
966 aexps0 :: { [RdrNameHsExpr] }
967 : aexps { reverse $1 }
969 aexps :: { [RdrNameHsExpr] }
970 : aexps aexp { $2 : $1 }
973 aexp :: { RdrNameHsExpr }
974 : qvar '@' aexp { EAsPat $1 $3 }
975 | '~' aexp { ELazyPat $2 }
978 aexp1 :: { RdrNameHsExpr }
979 : aexp1 '{' fbinds '}' {% (mkRecConstrOrUpdate $1 (reverse $3)) }
982 -- Here was the syntax for type applications that I was planning
983 -- but there are difficulties (e.g. what order for type args)
984 -- so it's not enabled yet.
985 | qcname '{|' gentype '|}' { (HsApp (HsVar $1) (HsType $3)) }
987 aexp2 :: { RdrNameHsExpr }
988 : ipvar { HsIPVar $1 }
989 | qcname { HsVar $1 }
990 | literal { HsLit $1 }
991 | INTEGER { HsOverLit (mkHsIntegral $1) }
992 | RATIONAL { HsOverLit (mkHsFractional $1) }
993 | '(' exp ')' { HsPar $2 }
994 | '(' exp ',' texps ')' { ExplicitTuple ($2 : reverse $4) Boxed}
995 | '(#' texps '#)' { ExplicitTuple (reverse $2) Unboxed }
996 | '[' list ']' { $2 }
997 | '[:' parr ':]' { $2 }
998 | '(' infixexp qop ')' { (SectionL $2 (HsVar $3)) }
999 | '(' qopm infixexp ')' { (SectionR $2 $3) }
1002 -- MetaHaskell Extension
1003 | ID_SPLICE { mkHsSplice (HsVar (mkUnqual varName $1))} -- $x
1004 | '$(' exp ')' { mkHsSplice $2 } -- $( exp )
1005 | '[|' exp '|]' { HsBracket (ExpBr $2) }
1006 | '[t|' ctype '|]' { HsBracket (TypBr $2) }
1007 | '[p|' srcloc infixexp '|]' {% checkPattern $2 $3 `thenP` \p ->
1008 returnP (HsBracket (PatBr p)) }
1009 | '[d|' cvtopdecls '|]' { HsBracket (DecBr (mkGroup $2)) }
1012 texps :: { [RdrNameHsExpr] }
1013 : texps ',' exp { $3 : $1 }
1017 -----------------------------------------------------------------------------
1020 -- The rules below are little bit contorted to keep lexps left-recursive while
1021 -- avoiding another shift/reduce-conflict.
1023 list :: { RdrNameHsExpr }
1024 : exp { ExplicitList placeHolderType [$1] }
1025 | lexps { ExplicitList placeHolderType (reverse $1) }
1026 | exp '..' { ArithSeqIn (From $1) }
1027 | exp ',' exp '..' { ArithSeqIn (FromThen $1 $3) }
1028 | exp '..' exp { ArithSeqIn (FromTo $1 $3) }
1029 | exp ',' exp '..' exp { ArithSeqIn (FromThenTo $1 $3 $5) }
1030 | exp srcloc pquals {% let { body [qs] = qs;
1031 body qss = [ParStmt (map reverse qss)] }
1033 returnP ( mkHsDo ListComp
1034 (reverse (ResultStmt $1 $2 : body $3))
1039 lexps :: { [RdrNameHsExpr] }
1040 : lexps ',' exp { $3 : $1 }
1041 | exp ',' exp { [$3,$1] }
1043 -----------------------------------------------------------------------------
1044 -- List Comprehensions
1046 pquals :: { [[RdrNameStmt]] }
1047 : pquals '|' quals { $3 : $1 }
1048 | '|' quals { [$2] }
1050 quals :: { [RdrNameStmt] }
1051 : quals ',' stmt { $3 : $1 }
1054 -----------------------------------------------------------------------------
1055 -- Parallel array expressions
1057 -- The rules below are little bit contorted; see the list case for details.
1058 -- Note that, in contrast to lists, we only have finite arithmetic sequences.
1059 -- Moreover, we allow explicit arrays with no element (represented by the nil
1060 -- constructor in the list case).
1062 parr :: { RdrNameHsExpr }
1063 : { ExplicitPArr placeHolderType [] }
1064 | exp { ExplicitPArr placeHolderType [$1] }
1065 | lexps { ExplicitPArr placeHolderType
1067 | exp '..' exp { PArrSeqIn (FromTo $1 $3) }
1068 | exp ',' exp '..' exp { PArrSeqIn (FromThenTo $1 $3 $5) }
1069 | exp srcloc pquals {% let {
1076 (reverse (ResultStmt $1 $2
1081 -- We are reusing `lexps' and `pquals' from the list case.
1083 -----------------------------------------------------------------------------
1084 -- Case alternatives
1086 altslist :: { [RdrNameMatch] }
1087 : '{' alts '}' { reverse $2 }
1088 | layout_on alts close { reverse $2 }
1090 alts :: { [RdrNameMatch] }
1094 alts1 :: { [RdrNameMatch] }
1095 : alts1 ';' alt { $3 : $1 }
1099 alt :: { RdrNameMatch }
1100 : srcloc infixexp opt_sig ralt wherebinds
1101 {% (checkPattern $1 $2 `thenP` \p ->
1102 returnP (Match [p] $3
1103 (GRHSs $4 $5 placeHolderType)) )}
1105 ralt :: { [RdrNameGRHS] }
1106 : '->' srcloc exp { [GRHS [ResultStmt $3 $2] $2] }
1107 | gdpats { reverse $1 }
1109 gdpats :: { [RdrNameGRHS] }
1110 : gdpats gdpat { $2 : $1 }
1113 gdpat :: { RdrNameGRHS }
1114 : srcloc '|' quals '->' exp { GRHS (reverse (ResultStmt $5 $1:$3)) $1}
1116 -----------------------------------------------------------------------------
1117 -- Statement sequences
1119 stmtlist :: { [RdrNameStmt] }
1120 : '{' stmts '}' { $2 }
1121 | layout_on_for_do stmts close { $2 }
1123 -- do { ;; s ; s ; ; s ;; }
1124 -- The last Stmt should be a ResultStmt, but that's hard to enforce
1125 -- here, because we need too much lookahead if we see do { e ; }
1126 -- So we use ExprStmts throughout, and switch the last one over
1127 -- in ParseUtils.checkDo instead
1128 stmts :: { [RdrNameStmt] }
1129 : stmt stmts_help { $1 : $2 }
1131 | {- empty -} { [] }
1133 stmts_help :: { [RdrNameStmt] }
1135 | {- empty -} { [] }
1137 -- For typing stmts at the GHCi prompt, where
1138 -- the input may consist of just comments.
1139 maybe_stmt :: { Maybe RdrNameStmt }
1141 | {- nothing -} { Nothing }
1143 stmt :: { RdrNameStmt }
1144 : srcloc infixexp '<-' exp {% checkPattern $1 $2 `thenP` \p ->
1145 returnP (BindStmt p $4 $1) }
1146 | srcloc exp { ExprStmt $2 placeHolderType $1 }
1147 | srcloc 'let' decllist { LetStmt (cvBinds $3) }
1149 -----------------------------------------------------------------------------
1150 -- Record Field Update/Construction
1152 fbinds :: { RdrNameHsRecordBinds }
1153 : fbinds ',' fbind { $3 : $1 }
1156 | {- empty -} { [] }
1158 fbind :: { (RdrName, RdrNameHsExpr) }
1159 : qvar '=' exp { ($1,$3) }
1161 -----------------------------------------------------------------------------
1162 -- Implicit Parameter Bindings
1164 dbinding :: { [(IPName RdrName, RdrNameHsExpr)] }
1165 : '{' dbinds '}' { $2 }
1166 | layout_on dbinds close { $2 }
1168 dbinds :: { [(IPName RdrName, RdrNameHsExpr)] }
1169 : dbinds ';' dbind { $3 : $1 }
1172 -- | {- empty -} { [] }
1174 dbind :: { (IPName RdrName, RdrNameHsExpr) }
1175 dbind : ipvar '=' exp { ($1, $3) }
1177 -----------------------------------------------------------------------------
1178 -- Variables, Constructors and Operators.
1180 identifier :: { RdrName }
1185 depreclist :: { [RdrName] }
1186 depreclist : deprec_var { [$1] }
1187 | deprec_var ',' depreclist { $1 : $3 }
1189 deprec_var :: { RdrName }
1190 deprec_var : var { $1 }
1193 gcon :: { RdrName } -- Data constructor namespace
1196 -- the case of '[:' ':]' is part of the production `parr'
1198 sysdcon :: { RdrName } -- Data constructor namespace
1199 : '(' ')' { getRdrName unitDataCon }
1200 | '(' commas ')' { getRdrName (tupleCon Boxed $2) }
1201 | '[' ']' { nameRdrName nilDataConName }
1205 | '(' varsym ')' { $2 }
1209 | '(' varsym ')' { $2 }
1210 | '(' qvarsym1 ')' { $2 }
1211 -- We've inlined qvarsym here so that the decision about
1212 -- whether it's a qvar or a var can be postponed until
1213 -- *after* we see the close paren.
1215 ipvar :: { IPName RdrName }
1216 : IPDUPVARID { Dupable (mkUnqual varName $1) }
1217 | IPSPLITVARID { Linear (mkUnqual varName $1) }
1221 | '(' qconsym ')' { $2 }
1223 varop :: { RdrName }
1225 | '`' varid '`' { $2 }
1227 qvarop :: { RdrName }
1229 | '`' qvarid '`' { $2 }
1231 qvaropm :: { RdrName }
1232 : qvarsym_no_minus { $1 }
1233 | '`' qvarid '`' { $2 }
1235 conop :: { RdrName }
1237 | '`' conid '`' { $2 }
1239 qconop :: { RdrName }
1241 | '`' qconid '`' { $2 }
1243 -----------------------------------------------------------------------------
1244 -- Type constructors
1246 gtycon :: { RdrName } -- A "general" qualified tycon
1248 | '(' ')' { getRdrName unitTyCon }
1249 | '(' commas ')' { getRdrName (tupleTyCon Boxed $2) }
1250 | '(' '->' ')' { nameRdrName funTyConName }
1251 | '[' ']' { nameRdrName listTyConName }
1252 | '[:' ':]' { nameRdrName parrTyConName }
1254 oqtycon :: { RdrName } -- An "ordinary" qualified tycon
1256 | '(' qtyconsym ')' { $2 }
1258 qtyconop :: { RdrName } -- Qualified or unqualified
1260 | '`' qtycon '`' { $2 }
1262 tyconop :: { RdrName } -- Unqualified
1264 | '`' tycon '`' { $2 }
1266 qtycon :: { RdrName } -- Qualified or unqualified
1267 : QCONID { mkQual tcClsName $1 }
1270 tycon :: { RdrName } -- Unqualified
1271 : CONID { mkUnqual tcClsName $1 }
1273 qtyconsym :: { RdrName }
1274 : QCONSYM { mkQual tcClsName $1 }
1277 tyconsym :: { RdrName }
1278 : CONSYM { mkUnqual tcClsName $1 }
1280 -----------------------------------------------------------------------------
1283 op :: { RdrName } -- used in infix decls
1287 qop :: { RdrName {-HsExpr-} } -- used in sections
1291 qopm :: { RdrNameHsExpr } -- used in sections
1292 : qvaropm { HsVar $1 }
1293 | qconop { HsVar $1 }
1295 -----------------------------------------------------------------------------
1298 qvarid :: { RdrName }
1300 | QVARID { mkQual varName $1 }
1302 varid :: { RdrName }
1303 : varid_no_unsafe { $1 }
1304 | 'unsafe' { mkUnqual varName FSLIT("unsafe") }
1305 | 'safe' { mkUnqual varName FSLIT("safe") }
1306 | 'threadsafe' { mkUnqual varName FSLIT("threadsafe") }
1308 varid_no_unsafe :: { RdrName }
1309 : VARID { mkUnqual varName $1 }
1310 | special_id { mkUnqual varName $1 }
1311 | 'forall' { mkUnqual varName FSLIT("forall") }
1313 tyvar :: { RdrName }
1314 : VARID { mkUnqual tvName $1 }
1315 | special_id { mkUnqual tvName $1 }
1316 | 'unsafe' { mkUnqual tvName FSLIT("unsafe") }
1317 | 'safe' { mkUnqual tvName FSLIT("safe") }
1318 | 'threadsafe' { mkUnqual tvName FSLIT("threadsafe") }
1320 -- These special_ids are treated as keywords in various places,
1321 -- but as ordinary ids elsewhere. 'special_id' collects all these
1322 -- except 'unsafe' and 'forall' whose treatment differs depending on context
1323 special_id :: { UserFS }
1325 : 'as' { FSLIT("as") }
1326 | 'qualified' { FSLIT("qualified") }
1327 | 'hiding' { FSLIT("hiding") }
1328 | 'export' { FSLIT("export") }
1329 | 'label' { FSLIT("label") }
1330 | 'dynamic' { FSLIT("dynamic") }
1331 | 'stdcall' { FSLIT("stdcall") }
1332 | 'ccall' { FSLIT("ccall") }
1334 -----------------------------------------------------------------------------
1337 qvarsym :: { RdrName }
1341 qvarsym_no_minus :: { RdrName }
1342 : varsym_no_minus { $1 }
1345 qvarsym1 :: { RdrName }
1346 qvarsym1 : QVARSYM { mkQual varName $1 }
1348 varsym :: { RdrName }
1349 : varsym_no_minus { $1 }
1350 | '-' { mkUnqual varName FSLIT("-") }
1352 varsym_no_minus :: { RdrName } -- varsym not including '-'
1353 : VARSYM { mkUnqual varName $1 }
1354 | special_sym { mkUnqual varName $1 }
1357 -- See comments with special_id
1358 special_sym :: { UserFS }
1359 special_sym : '!' { FSLIT("!") }
1360 | '.' { FSLIT(".") }
1361 | '*' { FSLIT("*") }
1363 -----------------------------------------------------------------------------
1364 -- Data constructors
1366 qconid :: { RdrName } -- Qualified or unqualifiedb
1368 | QCONID { mkQual dataName $1 }
1370 conid :: { RdrName }
1371 : CONID { mkUnqual dataName $1 }
1373 qconsym :: { RdrName } -- Qualified or unqualified
1375 | QCONSYM { mkQual dataName $1 }
1377 consym :: { RdrName }
1378 : CONSYM { mkUnqual dataName $1 }
1379 | ':' { nameRdrName consDataConName }
1380 -- ':' means only list cons
1383 -----------------------------------------------------------------------------
1386 literal :: { HsLit }
1387 : CHAR { HsChar $1 }
1388 | STRING { HsString $1 }
1389 | PRIMINTEGER { HsIntPrim $1 }
1390 | PRIMCHAR { HsCharPrim $1 }
1391 | PRIMSTRING { HsStringPrim $1 }
1392 | PRIMFLOAT { HsFloatPrim $1 }
1393 | PRIMDOUBLE { HsDoublePrim $1 }
1394 | CLITLIT { HsLitLit $1 placeHolderType }
1396 srcloc :: { SrcLoc } : {% getSrcLocP }
1398 -----------------------------------------------------------------------------
1402 : vccurly { () } -- context popped in lexer.
1403 | error {% popContext }
1405 layout_on :: { () } : {% layoutOn True{-strict-} }
1406 layout_on_for_do :: { () } : {% layoutOn False }
1408 -----------------------------------------------------------------------------
1409 -- Miscellaneous (mostly renamings)
1411 modid :: { ModuleName }
1412 : CONID { mkModuleNameFS $1 }
1413 | QCONID { mkModuleNameFS
1415 (unpackFS (fst $1) ++
1416 '.':unpackFS (snd $1)))
1420 : commas ',' { $1 + 1 }
1423 -----------------------------------------------------------------------------
1427 happyError buf PState{ loc = loc } = PFailed (srcParseErr buf loc)