2 -----------------------------------------------------------------------------
3 $Id: Parser.y,v 1.108 2002/10/10 15:14:37 sof 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 (reverse $2) }
418 | srcloc '$(' exp ')' { RdrHsDecl (SpliceD (SpliceDecl $3 $1)) }
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 : rules ';' rule { $3 : $1 }
496 rule :: { RdrBinding }
497 : STRING activation rule_forall infixexp '=' srcloc exp
498 { RdrHsDecl (RuleD (HsRule $1 $2 $3 $4 $7 $6)) }
500 activation :: { Activation } -- Omitted means AlwaysActive
501 : {- empty -} { AlwaysActive }
502 | explicit_activation { $1 }
504 inverse_activation :: { Activation } -- Omitted means NeverActive
505 : {- empty -} { NeverActive }
506 | explicit_activation { $1 }
508 explicit_activation :: { Activation } -- In brackets
509 : '[' INTEGER ']' { ActiveAfter (fromInteger $2) }
510 | '[' '~' INTEGER ']' { ActiveBefore (fromInteger $3) }
512 rule_forall :: { [RdrNameRuleBndr] }
513 : 'forall' rule_var_list '.' { $2 }
516 rule_var_list :: { [RdrNameRuleBndr] }
518 | rule_var rule_var_list { $1 : $2 }
520 rule_var :: { RdrNameRuleBndr }
521 : varid { RuleBndr $1 }
522 | '(' varid '::' ctype ')' { RuleBndrSig $2 $4 }
524 -----------------------------------------------------------------------------
527 deprecations :: { [RdrBinding] }
528 : deprecation ';' deprecations { $1 : $3 }
529 | deprecation { [$1] }
532 -- SUP: TEMPORARY HACK, not checking for `module Foo'
533 deprecation :: { RdrBinding }
534 : srcloc depreclist STRING
536 [ RdrHsDecl (DeprecD (Deprecation n $3 $1)) | n <- $2 ] }
539 -----------------------------------------------------------------------------
540 -- Foreign import and export declarations
542 -- for the time being, the following accepts foreign declarations conforming
543 -- to the FFI Addendum, Version 1.0 as well as pre-standard declarations
545 -- * a flag indicates whether pre-standard declarations have been used and
546 -- triggers a deprecation warning further down the road
548 -- NB: The first two rules could be combined into one by replacing `safety1'
549 -- with `safety'. However, the combined rule conflicts with the
552 fdecl :: { RdrNameHsDecl }
553 fdecl : srcloc 'import' callconv safety1 fspec {% mkImport $3 $4 $5 $1 }
554 | srcloc 'import' callconv fspec {% mkImport $3 (PlaySafe False) $4 $1 }
555 | srcloc 'export' callconv fspec {% mkExport $3 $4 $1 }
556 -- the following syntax is DEPRECATED
557 | srcloc fdecl1DEPRECATED { ForD ($2 True $1) }
558 | srcloc fdecl2DEPRECATED { $2 $1 }
560 fdecl1DEPRECATED :: { Bool -> SrcLoc -> ForeignDecl RdrName }
562 ----------- DEPRECATED label decls ------------
563 : 'label' ext_name varid '::' sigtype
564 { ForeignImport $3 $5 (CImport defaultCCallConv (PlaySafe False) nilFS nilFS
565 (CLabel ($2 `orElse` mkExtName $3))) }
567 ----------- DEPRECATED ccall/stdcall decls ------------
569 -- NB: This business with the case expression below may seem overly
570 -- complicated, but it is necessary to avoid some conflicts.
572 -- DEPRECATED variant #1: lack of a calling convention specification
574 | 'import' {-no callconv-} ext_name safety varid_no_unsafe '::' sigtype
576 target = StaticTarget ($2 `orElse` mkExtName $4)
578 ForeignImport $4 $6 (CImport defaultCCallConv $3 nilFS nilFS
579 (CFunction target)) }
581 -- DEPRECATED variant #2: external name consists of two separate strings
582 -- (module name and function name) (import)
583 | 'import' callconv STRING STRING safety varid_no_unsafe '::' sigtype
585 DNCall -> parseError "Illegal format of .NET foreign import"
586 CCall cconv -> returnP $
588 imp = CFunction (StaticTarget $4)
590 ForeignImport $6 $8 (CImport cconv $5 nilFS nilFS imp) }
592 -- DEPRECATED variant #3: `unsafe' after entity
593 | 'import' callconv STRING 'unsafe' varid_no_unsafe '::' sigtype
595 DNCall -> parseError "Illegal format of .NET foreign import"
596 CCall cconv -> returnP $
598 imp = CFunction (StaticTarget $3)
600 ForeignImport $5 $7 (CImport cconv PlayRisky nilFS nilFS imp) }
602 -- DEPRECATED variant #4: use of the special identifier `dynamic' without
603 -- an explicit calling convention (import)
604 | 'import' {-no callconv-} 'dynamic' safety varid_no_unsafe '::' sigtype
605 { ForeignImport $4 $6 (CImport defaultCCallConv $3 nilFS nilFS
606 (CFunction DynamicTarget)) }
608 -- DEPRECATED variant #5: use of the special identifier `dynamic' (import)
609 | 'import' callconv 'dynamic' safety varid_no_unsafe '::' sigtype
611 DNCall -> parseError "Illegal format of .NET foreign import"
612 CCall cconv -> returnP $
613 ForeignImport $5 $7 (CImport cconv $4 nilFS nilFS
614 (CFunction DynamicTarget)) }
616 -- DEPRECATED variant #6: lack of a calling convention specification
618 | 'export' {-no callconv-} ext_name varid '::' sigtype
619 { ForeignExport $3 $5 (CExport (CExportStatic ($2 `orElse` mkExtName $3)
622 -- DEPRECATED variant #7: external name consists of two separate strings
623 -- (module name and function name) (export)
624 | 'export' callconv STRING STRING varid '::' sigtype
626 DNCall -> parseError "Illegal format of .NET foreign import"
627 CCall cconv -> returnP $
629 (CExport (CExportStatic $4 cconv)) }
631 -- DEPRECATED variant #8: use of the special identifier `dynamic' without
632 -- an explicit calling convention (export)
633 | 'export' {-no callconv-} 'dynamic' varid '::' sigtype
634 { ForeignImport $3 $5 (CImport defaultCCallConv (PlaySafe False) nilFS nilFS
637 -- DEPRECATED variant #9: use of the special identifier `dynamic' (export)
638 | 'export' callconv 'dynamic' varid '::' sigtype
640 DNCall -> parseError "Illegal format of .NET foreign import"
641 CCall cconv -> returnP $
642 ForeignImport $4 $6 (CImport cconv (PlaySafe False) nilFS nilFS CWrapper) }
644 ----------- DEPRECATED .NET decls ------------
645 -- NB: removed the .NET call declaration, as it is entirely subsumed
646 -- by the new standard FFI declarations
648 fdecl2DEPRECATED :: { SrcLoc -> RdrNameHsDecl }
650 : 'import' 'dotnet' 'type' ext_name tycon
651 { \loc -> TyClD (ForeignType $5 $4 DNType loc) }
652 -- left this one unchanged for the moment as type imports are not
653 -- covered currently by the FFI standard -=chak
656 callconv :: { CallConv }
657 : 'stdcall' { CCall StdCallConv }
658 | 'ccall' { CCall CCallConv }
659 | 'dotnet' { DNCall }
662 : 'unsafe' { PlayRisky }
663 | 'safe' { PlaySafe False }
664 | 'threadsafe' { PlaySafe True }
665 | {- empty -} { PlaySafe False }
667 safety1 :: { Safety }
668 : 'unsafe' { PlayRisky }
669 | 'safe' { PlaySafe False }
670 | 'threadsafe' { PlaySafe True }
671 -- only needed to avoid conflicts with the DEPRECATED rules
673 fspec :: { (FastString, RdrName, RdrNameHsType) }
674 : STRING var '::' sigtype { ($1 , $2, $4) }
675 | var '::' sigtype { (nilFS, $1, $3) }
676 -- if the entity string is missing, it defaults to the empty string;
677 -- the meaning of an empty entity string depends on the calling
681 ext_name :: { Maybe CLabelString }
683 | STRING STRING { Just $2 } -- Ignore "module name" for now
684 | {- empty -} { Nothing }
687 -----------------------------------------------------------------------------
690 opt_sig :: { Maybe RdrNameHsType }
691 : {- empty -} { Nothing }
692 | '::' sigtype { Just $2 }
694 opt_asig :: { Maybe RdrNameHsType }
695 : {- empty -} { Nothing }
696 | '::' atype { Just $2 }
698 sigtypes :: { [RdrNameHsType] }
700 | sigtypes ',' sigtype { $3 : $1 }
702 sigtype :: { RdrNameHsType }
703 : ctype { mkHsForAllTy Nothing [] $1 }
705 sig_vars :: { [RdrName] }
706 : sig_vars ',' var { $3 : $1 }
709 -----------------------------------------------------------------------------
712 -- A ctype is a for-all type
713 ctype :: { RdrNameHsType }
714 : 'forall' tv_bndrs '.' ctype { mkHsForAllTy (Just $2) [] $4 }
715 | context '=>' type { mkHsForAllTy Nothing $1 $3 }
716 -- A type of form (context => type) is an *implicit* HsForAllTy
719 -- We parse a context as a btype so that we don't get reduce/reduce
720 -- errors in ctype. The basic problem is that
722 -- looks so much like a tuple type. We can't tell until we find the =>
723 context :: { RdrNameContext }
724 : btype {% checkContext $1 }
726 type :: { RdrNameHsType }
727 : ipvar '::' gentype { mkHsIParamTy $1 $3 }
730 gentype :: { RdrNameHsType }
732 | btype qtyconop gentype { HsOpTy $1 (HsTyOp $2) $3 }
733 | btype '`' tyvar '`' gentype { HsOpTy $1 (HsTyOp $3) $5 }
734 | btype '->' gentype { HsOpTy $1 HsArrow $3 }
736 btype :: { RdrNameHsType }
737 : btype atype { HsAppTy $1 $2 }
740 atype :: { RdrNameHsType }
741 : gtycon { HsTyVar $1 }
742 | tyvar { HsTyVar $1 }
743 | '(' type ',' comma_types1 ')' { HsTupleTy (mkHsTupCon tcName Boxed ($2:$4)) ($2:$4) }
744 | '(#' comma_types1 '#)' { HsTupleTy (mkHsTupCon tcName Unboxed $2) $2 }
745 | '[' type ']' { HsListTy $2 }
746 | '[:' type ':]' { HsPArrTy $2 }
747 | '(' ctype ')' { HsParTy $2 }
748 | '(' ctype '::' kind ')' { HsKindSig $2 $4 }
750 | INTEGER { HsNumTy $1 }
752 -- An inst_type is what occurs in the head of an instance decl
753 -- e.g. (Foo a, Gaz b) => Wibble a b
754 -- It's kept as a single type, with a MonoDictTy at the right
755 -- hand corner, for convenience.
756 inst_type :: { RdrNameHsType }
757 : ctype {% checkInstType $1 }
759 comma_types0 :: { [RdrNameHsType] }
760 : comma_types1 { $1 }
763 comma_types1 :: { [RdrNameHsType] }
765 | type ',' comma_types1 { $1 : $3 }
767 tv_bndrs :: { [RdrNameHsTyVar] }
768 : tv_bndr tv_bndrs { $1 : $2 }
771 tv_bndr :: { RdrNameHsTyVar }
772 : tyvar { UserTyVar $1 }
773 | '(' tyvar '::' kind ')' { IfaceTyVar $2 $4 }
775 fds :: { [([RdrName], [RdrName])] }
777 | '|' fds1 { reverse $2 }
779 fds1 :: { [([RdrName], [RdrName])] }
780 : fds1 ',' fd { $3 : $1 }
783 fd :: { ([RdrName], [RdrName]) }
784 : varids0 '->' varids0 { (reverse $1, reverse $3) }
786 varids0 :: { [RdrName] }
788 | varids0 tyvar { $2 : $1 }
790 -----------------------------------------------------------------------------
795 | akind '->' kind { mkArrowKind $1 $3 }
798 : '*' { liftedTypeKind }
799 | '(' kind ')' { $2 }
802 -----------------------------------------------------------------------------
803 -- Datatype declarations
805 newconstr :: { RdrNameConDecl }
806 : srcloc conid atype { ConDecl $2 [] [] (PrefixCon [unbangedType $3]) $1 }
807 | srcloc conid '{' var '::' ctype '}'
808 { ConDecl $2 [] [] (RecCon [($4, unbangedType $6)]) $1 }
810 constrs :: { [RdrNameConDecl] }
811 : {- empty; a GHC extension -} { [] }
812 | '=' constrs1 { $2 }
814 constrs1 :: { [RdrNameConDecl] }
815 : constrs1 '|' constr { $3 : $1 }
818 constr :: { RdrNameConDecl }
819 : srcloc forall context '=>' constr_stuff
820 { ConDecl (fst $5) $2 $3 (snd $5) $1 }
821 | srcloc forall constr_stuff
822 { ConDecl (fst $3) $2 [] (snd $3) $1 }
824 forall :: { [RdrNameHsTyVar] }
825 : 'forall' tv_bndrs '.' { $2 }
828 constr_stuff :: { (RdrName, RdrNameConDetails) }
829 : btype {% mkPrefixCon $1 [] }
830 | btype '!' atype satypes {% mkPrefixCon $1 (BangType MarkedUserStrict $3 : $4) }
831 | oqtycon '{' '}' {% mkRecCon $1 [] }
832 | oqtycon '{' fielddecls '}' {% mkRecCon $1 $3 }
833 | sbtype conop sbtype { ($2, InfixCon $1 $3) }
835 satypes :: { [RdrNameBangType] }
836 : atype satypes { unbangedType $1 : $2 }
837 | '!' atype satypes { BangType MarkedUserStrict $2 : $3 }
840 sbtype :: { RdrNameBangType }
841 : btype { unbangedType $1 }
842 | '!' atype { BangType MarkedUserStrict $2 }
844 fielddecls :: { [([RdrName],RdrNameBangType)] }
845 : fielddecl ',' fielddecls { $1 : $3 }
848 fielddecl :: { ([RdrName],RdrNameBangType) }
849 : sig_vars '::' stype { (reverse $1, $3) }
851 stype :: { RdrNameBangType }
852 : ctype { unbangedType $1 }
853 | '!' atype { BangType MarkedUserStrict $2 }
855 deriving :: { Maybe RdrNameContext }
856 : {- empty -} { Nothing }
857 | 'deriving' context { Just $2 }
858 -- Glasgow extension: allow partial
859 -- applications in derivings
861 -----------------------------------------------------------------------------
864 {- There's an awkward overlap with a type signature. Consider
865 f :: Int -> Int = ...rhs...
866 Then we can't tell whether it's a type signature or a value
867 definition with a result signature until we see the '='.
868 So we have to inline enough to postpone reductions until we know.
872 ATTENTION: Dirty Hackery Ahead! If the second alternative of vars is var
873 instead of qvar, we get another shift/reduce-conflict. Consider the
876 { (^^) :: Int->Int ; } Type signature; only var allowed
878 { (^^) :: Int->Int = ... ; } Value defn with result signature;
879 qvar allowed (because of instance decls)
881 We can't tell whether to reduce var to qvar until after we've read the signatures.
884 decl :: { RdrBinding }
886 | infixexp srcloc opt_sig rhs {% checkValDef $1 $3 $4 $2 }
888 rhs :: { RdrNameGRHSs }
889 : '=' srcloc exp wherebinds { GRHSs (unguardedRHS $3 $2) $4 placeHolderType }
890 | gdrhs wherebinds { GRHSs (reverse $1) $2 placeHolderType }
892 gdrhs :: { [RdrNameGRHS] }
893 : gdrhs gdrh { $2 : $1 }
896 gdrh :: { RdrNameGRHS }
897 : '|' srcloc quals '=' exp { GRHS (reverse (ResultStmt $5 $2 : $3)) $2 }
899 sigdecl :: { RdrBinding }
900 : infixexp srcloc '::' sigtype
901 {% checkValSig $1 $4 $2 }
902 -- See the above notes for why we need infixexp here
903 | var ',' sig_vars srcloc '::' sigtype
904 { mkSigDecls [ Sig n $6 $4 | n <- $1:$3 ] }
905 | srcloc infix prec ops { mkSigDecls [ FixSig (FixitySig n (Fixity $3 $2) $1)
907 | '{-# INLINE' srcloc activation qvar '#-}'
908 { RdrHsDecl (SigD (InlineSig True $4 $3 $2)) }
909 | '{-# NOINLINE' srcloc inverse_activation qvar '#-}'
910 { RdrHsDecl (SigD (InlineSig False $4 $3 $2)) }
911 | '{-# SPECIALISE' srcloc qvar '::' sigtypes '#-}'
912 { mkSigDecls [ SpecSig $3 t $2 | t <- $5] }
913 | '{-# SPECIALISE' srcloc 'instance' inst_type '#-}'
914 { RdrHsDecl (SigD (SpecInstSig $4 $2)) }
916 -----------------------------------------------------------------------------
919 exp :: { RdrNameHsExpr }
920 : infixexp '::' sigtype { ExprWithTySig $1 $3 }
921 | infixexp 'with' dbinding { HsWith $1 $3 True{-not a let-} }
924 infixexp :: { RdrNameHsExpr }
926 | infixexp qop exp10 { (OpApp $1 (HsVar $2)
927 (panic "fixity") $3 )}
929 exp10 :: { RdrNameHsExpr }
930 : '\\' srcloc aexp aexps opt_asig '->' srcloc exp
931 {% checkPatterns $2 ($3 : reverse $4) `thenP` \ ps ->
932 returnP (HsLam (Match ps $5
933 (GRHSs (unguardedRHS $8 $7)
934 EmptyBinds placeHolderType))) }
935 | 'let' letbinds 'in' exp { $2 $4 }
936 | 'if' srcloc exp 'then' exp 'else' exp { HsIf $3 $5 $7 $2 }
937 | 'case' srcloc exp 'of' altslist { HsCase $3 $5 $2 }
938 | '-' fexp { mkHsNegApp $2 }
939 | srcloc 'do' stmtlist {% checkDo $3 `thenP` \ stmts ->
940 returnP (mkHsDo DoExpr stmts $1) }
941 | srcloc 'mdo' stmtlist {% checkMDo $3 `thenP` \ stmts ->
942 returnP (mkHsDo MDoExpr stmts $1) }
944 | '_ccall_' ccallid aexps0 { HsCCall $2 $3 PlayRisky False placeHolderType }
945 | '_ccall_GC_' ccallid aexps0 { HsCCall $2 $3 (PlaySafe False) False placeHolderType }
946 | '_casm_' CLITLIT aexps0 { HsCCall $2 $3 PlayRisky True placeHolderType }
947 | '_casm_GC_' CLITLIT aexps0 { HsCCall $2 $3 (PlaySafe False) True placeHolderType }
949 | scc_annot exp { if opt_SccProfilingOn
955 scc_annot :: { FastString }
956 : '_scc_' STRING { $2 }
957 | '{-# SCC' STRING '#-}' { $2 }
959 ccallid :: { FastString }
963 fexp :: { RdrNameHsExpr }
964 : fexp aexp { (HsApp $1 $2) }
967 aexps0 :: { [RdrNameHsExpr] }
968 : aexps { reverse $1 }
970 aexps :: { [RdrNameHsExpr] }
971 : aexps aexp { $2 : $1 }
974 aexp :: { RdrNameHsExpr }
975 : qvar '@' aexp { EAsPat $1 $3 }
976 | '~' aexp { ELazyPat $2 }
979 aexp1 :: { RdrNameHsExpr }
980 : aexp1 '{' fbinds '}' {% (mkRecConstrOrUpdate $1 (reverse $3)) }
983 -- Here was the syntax for type applications that I was planning
984 -- but there are difficulties (e.g. what order for type args)
985 -- so it's not enabled yet.
986 | qcname '{|' gentype '|}' { (HsApp (HsVar $1) (HsType $3)) }
988 aexp2 :: { RdrNameHsExpr }
989 : ipvar { HsIPVar $1 }
990 | qcname { HsVar $1 }
991 | literal { HsLit $1 }
992 | INTEGER { HsOverLit (mkHsIntegral $1) }
993 | RATIONAL { HsOverLit (mkHsFractional $1) }
994 | '(' exp ')' { HsPar $2 }
995 | '(' exp ',' texps ')' { ExplicitTuple ($2 : reverse $4) Boxed}
996 | '(#' texps '#)' { ExplicitTuple (reverse $2) Unboxed }
997 | '[' list ']' { $2 }
998 | '[:' parr ':]' { $2 }
999 | '(' infixexp qop ')' { (SectionL $2 (HsVar $3)) }
1000 | '(' qopm infixexp ')' { (SectionR $2 $3) }
1003 -- MetaHaskell Extension
1004 | srcloc ID_SPLICE { mkHsSplice (HsVar (mkUnqual varName $2)) $1 } -- $x
1005 | srcloc '$(' exp ')' { mkHsSplice $3 $1 } -- $( exp )
1006 | srcloc '[|' exp '|]' { HsBracket (ExpBr $3) $1 }
1007 | srcloc '[t|' ctype '|]' { HsBracket (TypBr $3) $1 }
1008 | srcloc '[p|' infixexp '|]' {% checkPattern $1 $3 `thenP` \p ->
1009 returnP (HsBracket (PatBr p) $1) }
1010 | srcloc '[d|' cvtopdecls '|]' { HsBracket (DecBr (mkGroup $3)) $1 }
1013 texps :: { [RdrNameHsExpr] }
1014 : texps ',' exp { $3 : $1 }
1018 -----------------------------------------------------------------------------
1021 -- The rules below are little bit contorted to keep lexps left-recursive while
1022 -- avoiding another shift/reduce-conflict.
1024 list :: { RdrNameHsExpr }
1025 : exp { ExplicitList placeHolderType [$1] }
1026 | lexps { ExplicitList placeHolderType (reverse $1) }
1027 | exp '..' { ArithSeqIn (From $1) }
1028 | exp ',' exp '..' { ArithSeqIn (FromThen $1 $3) }
1029 | exp '..' exp { ArithSeqIn (FromTo $1 $3) }
1030 | exp ',' exp '..' exp { ArithSeqIn (FromThenTo $1 $3 $5) }
1031 | exp srcloc pquals {% let { body [qs] = qs;
1032 body qss = [ParStmt (map reverse qss)] }
1034 returnP ( mkHsDo ListComp
1035 (reverse (ResultStmt $1 $2 : body $3))
1040 lexps :: { [RdrNameHsExpr] }
1041 : lexps ',' exp { $3 : $1 }
1042 | exp ',' exp { [$3,$1] }
1044 -----------------------------------------------------------------------------
1045 -- List Comprehensions
1047 pquals :: { [[RdrNameStmt]] }
1048 : pquals '|' quals { $3 : $1 }
1049 | '|' quals { [$2] }
1051 quals :: { [RdrNameStmt] }
1052 : quals ',' stmt { $3 : $1 }
1055 -----------------------------------------------------------------------------
1056 -- Parallel array expressions
1058 -- The rules below are little bit contorted; see the list case for details.
1059 -- Note that, in contrast to lists, we only have finite arithmetic sequences.
1060 -- Moreover, we allow explicit arrays with no element (represented by the nil
1061 -- constructor in the list case).
1063 parr :: { RdrNameHsExpr }
1064 : { ExplicitPArr placeHolderType [] }
1065 | exp { ExplicitPArr placeHolderType [$1] }
1066 | lexps { ExplicitPArr placeHolderType
1068 | exp '..' exp { PArrSeqIn (FromTo $1 $3) }
1069 | exp ',' exp '..' exp { PArrSeqIn (FromThenTo $1 $3 $5) }
1070 | exp srcloc pquals {% let {
1077 (reverse (ResultStmt $1 $2
1082 -- We are reusing `lexps' and `pquals' from the list case.
1084 -----------------------------------------------------------------------------
1085 -- Case alternatives
1087 altslist :: { [RdrNameMatch] }
1088 : '{' alts '}' { reverse $2 }
1089 | layout_on alts close { reverse $2 }
1091 alts :: { [RdrNameMatch] }
1095 alts1 :: { [RdrNameMatch] }
1096 : alts1 ';' alt { $3 : $1 }
1100 alt :: { RdrNameMatch }
1101 : srcloc infixexp opt_sig ralt wherebinds
1102 {% (checkPattern $1 $2 `thenP` \p ->
1103 returnP (Match [p] $3
1104 (GRHSs $4 $5 placeHolderType)) )}
1106 ralt :: { [RdrNameGRHS] }
1107 : '->' srcloc exp { [GRHS [ResultStmt $3 $2] $2] }
1108 | gdpats { reverse $1 }
1110 gdpats :: { [RdrNameGRHS] }
1111 : gdpats gdpat { $2 : $1 }
1114 gdpat :: { RdrNameGRHS }
1115 : srcloc '|' quals '->' exp { GRHS (reverse (ResultStmt $5 $1:$3)) $1}
1117 -----------------------------------------------------------------------------
1118 -- Statement sequences
1120 stmtlist :: { [RdrNameStmt] }
1121 : '{' stmts '}' { $2 }
1122 | layout_on_for_do stmts close { $2 }
1124 -- do { ;; s ; s ; ; s ;; }
1125 -- The last Stmt should be a ResultStmt, but that's hard to enforce
1126 -- here, because we need too much lookahead if we see do { e ; }
1127 -- So we use ExprStmts throughout, and switch the last one over
1128 -- in ParseUtils.checkDo instead
1129 stmts :: { [RdrNameStmt] }
1130 : stmt stmts_help { $1 : $2 }
1132 | {- empty -} { [] }
1134 stmts_help :: { [RdrNameStmt] }
1136 | {- empty -} { [] }
1138 -- For typing stmts at the GHCi prompt, where
1139 -- the input may consist of just comments.
1140 maybe_stmt :: { Maybe RdrNameStmt }
1142 | {- nothing -} { Nothing }
1144 stmt :: { RdrNameStmt }
1145 : srcloc infixexp '<-' exp {% checkPattern $1 $2 `thenP` \p ->
1146 returnP (BindStmt p $4 $1) }
1147 | srcloc exp { ExprStmt $2 placeHolderType $1 }
1148 | srcloc 'let' decllist { LetStmt (cvBinds $3) }
1150 -----------------------------------------------------------------------------
1151 -- Record Field Update/Construction
1153 fbinds :: { RdrNameHsRecordBinds }
1154 : fbinds ',' fbind { $3 : $1 }
1157 | {- empty -} { [] }
1159 fbind :: { (RdrName, RdrNameHsExpr) }
1160 : qvar '=' exp { ($1,$3) }
1162 -----------------------------------------------------------------------------
1163 -- Implicit Parameter Bindings
1165 dbinding :: { [(IPName RdrName, RdrNameHsExpr)] }
1166 : '{' dbinds '}' { $2 }
1167 | layout_on dbinds close { $2 }
1169 dbinds :: { [(IPName RdrName, RdrNameHsExpr)] }
1170 : dbinds ';' dbind { $3 : $1 }
1173 -- | {- empty -} { [] }
1175 dbind :: { (IPName RdrName, RdrNameHsExpr) }
1176 dbind : ipvar '=' exp { ($1, $3) }
1178 -----------------------------------------------------------------------------
1179 -- Variables, Constructors and Operators.
1181 identifier :: { RdrName }
1186 depreclist :: { [RdrName] }
1187 depreclist : deprec_var { [$1] }
1188 | deprec_var ',' depreclist { $1 : $3 }
1190 deprec_var :: { RdrName }
1191 deprec_var : var { $1 }
1194 gcon :: { RdrName } -- Data constructor namespace
1197 -- the case of '[:' ':]' is part of the production `parr'
1199 sysdcon :: { RdrName } -- Data constructor namespace
1200 : '(' ')' { getRdrName unitDataCon }
1201 | '(' commas ')' { getRdrName (tupleCon Boxed $2) }
1202 | '[' ']' { nameRdrName nilDataConName }
1206 | '(' varsym ')' { $2 }
1210 | '(' varsym ')' { $2 }
1211 | '(' qvarsym1 ')' { $2 }
1212 -- We've inlined qvarsym here so that the decision about
1213 -- whether it's a qvar or a var can be postponed until
1214 -- *after* we see the close paren.
1216 ipvar :: { IPName RdrName }
1217 : IPDUPVARID { Dupable (mkUnqual varName $1) }
1218 | IPSPLITVARID { Linear (mkUnqual varName $1) }
1222 | '(' qconsym ')' { $2 }
1224 varop :: { RdrName }
1226 | '`' varid '`' { $2 }
1228 qvarop :: { RdrName }
1230 | '`' qvarid '`' { $2 }
1232 qvaropm :: { RdrName }
1233 : qvarsym_no_minus { $1 }
1234 | '`' qvarid '`' { $2 }
1236 conop :: { RdrName }
1238 | '`' conid '`' { $2 }
1240 qconop :: { RdrName }
1242 | '`' qconid '`' { $2 }
1244 -----------------------------------------------------------------------------
1245 -- Type constructors
1247 gtycon :: { RdrName } -- A "general" qualified tycon
1249 | '(' ')' { getRdrName unitTyCon }
1250 | '(' commas ')' { getRdrName (tupleTyCon Boxed $2) }
1251 | '(' '->' ')' { nameRdrName funTyConName }
1252 | '[' ']' { nameRdrName listTyConName }
1253 | '[:' ':]' { nameRdrName parrTyConName }
1255 oqtycon :: { RdrName } -- An "ordinary" qualified tycon
1257 | '(' qtyconsym ')' { $2 }
1259 qtyconop :: { RdrName } -- Qualified or unqualified
1261 | '`' qtycon '`' { $2 }
1263 tyconop :: { RdrName } -- Unqualified
1265 | '`' tycon '`' { $2 }
1267 qtycon :: { RdrName } -- Qualified or unqualified
1268 : QCONID { mkQual tcClsName $1 }
1271 tycon :: { RdrName } -- Unqualified
1272 : CONID { mkUnqual tcClsName $1 }
1274 qtyconsym :: { RdrName }
1275 : QCONSYM { mkQual tcClsName $1 }
1278 tyconsym :: { RdrName }
1279 : CONSYM { mkUnqual tcClsName $1 }
1281 -----------------------------------------------------------------------------
1284 op :: { RdrName } -- used in infix decls
1288 qop :: { RdrName {-HsExpr-} } -- used in sections
1292 qopm :: { RdrNameHsExpr } -- used in sections
1293 : qvaropm { HsVar $1 }
1294 | qconop { HsVar $1 }
1296 -----------------------------------------------------------------------------
1299 qvarid :: { RdrName }
1301 | QVARID { mkQual varName $1 }
1303 varid :: { RdrName }
1304 : varid_no_unsafe { $1 }
1305 | 'unsafe' { mkUnqual varName FSLIT("unsafe") }
1306 | 'safe' { mkUnqual varName FSLIT("safe") }
1307 | 'threadsafe' { mkUnqual varName FSLIT("threadsafe") }
1309 varid_no_unsafe :: { RdrName }
1310 : VARID { mkUnqual varName $1 }
1311 | special_id { mkUnqual varName $1 }
1312 | 'forall' { mkUnqual varName FSLIT("forall") }
1314 tyvar :: { RdrName }
1315 : VARID { mkUnqual tvName $1 }
1316 | special_id { mkUnqual tvName $1 }
1317 | 'unsafe' { mkUnqual tvName FSLIT("unsafe") }
1318 | 'safe' { mkUnqual tvName FSLIT("safe") }
1319 | 'threadsafe' { mkUnqual tvName FSLIT("threadsafe") }
1321 -- These special_ids are treated as keywords in various places,
1322 -- but as ordinary ids elsewhere. 'special_id' collects all these
1323 -- except 'unsafe' and 'forall' whose treatment differs depending on context
1324 special_id :: { UserFS }
1326 : 'as' { FSLIT("as") }
1327 | 'qualified' { FSLIT("qualified") }
1328 | 'hiding' { FSLIT("hiding") }
1329 | 'export' { FSLIT("export") }
1330 | 'label' { FSLIT("label") }
1331 | 'dynamic' { FSLIT("dynamic") }
1332 | 'stdcall' { FSLIT("stdcall") }
1333 | 'ccall' { FSLIT("ccall") }
1335 -----------------------------------------------------------------------------
1338 qvarsym :: { RdrName }
1342 qvarsym_no_minus :: { RdrName }
1343 : varsym_no_minus { $1 }
1346 qvarsym1 :: { RdrName }
1347 qvarsym1 : QVARSYM { mkQual varName $1 }
1349 varsym :: { RdrName }
1350 : varsym_no_minus { $1 }
1351 | '-' { mkUnqual varName FSLIT("-") }
1353 varsym_no_minus :: { RdrName } -- varsym not including '-'
1354 : VARSYM { mkUnqual varName $1 }
1355 | special_sym { mkUnqual varName $1 }
1358 -- See comments with special_id
1359 special_sym :: { UserFS }
1360 special_sym : '!' { FSLIT("!") }
1361 | '.' { FSLIT(".") }
1362 | '*' { FSLIT("*") }
1364 -----------------------------------------------------------------------------
1365 -- Data constructors
1367 qconid :: { RdrName } -- Qualified or unqualifiedb
1369 | QCONID { mkQual dataName $1 }
1371 conid :: { RdrName }
1372 : CONID { mkUnqual dataName $1 }
1374 qconsym :: { RdrName } -- Qualified or unqualified
1376 | QCONSYM { mkQual dataName $1 }
1378 consym :: { RdrName }
1379 : CONSYM { mkUnqual dataName $1 }
1380 | ':' { nameRdrName consDataConName }
1381 -- ':' means only list cons
1384 -----------------------------------------------------------------------------
1387 literal :: { HsLit }
1388 : CHAR { HsChar $1 }
1389 | STRING { HsString $1 }
1390 | PRIMINTEGER { HsIntPrim $1 }
1391 | PRIMCHAR { HsCharPrim $1 }
1392 | PRIMSTRING { HsStringPrim $1 }
1393 | PRIMFLOAT { HsFloatPrim $1 }
1394 | PRIMDOUBLE { HsDoublePrim $1 }
1395 | CLITLIT { HsLitLit $1 placeHolderType }
1397 srcloc :: { SrcLoc } : {% getSrcLocP }
1399 -----------------------------------------------------------------------------
1403 : vccurly { () } -- context popped in lexer.
1404 | error {% popContext }
1406 layout_on :: { () } : {% layoutOn True{-strict-} }
1407 layout_on_for_do :: { () } : {% layoutOn False }
1409 -----------------------------------------------------------------------------
1410 -- Miscellaneous (mostly renamings)
1412 modid :: { ModuleName }
1413 : CONID { mkModuleNameFS $1 }
1414 | QCONID { mkModuleNameFS
1416 (unpackFS (fst $1) ++
1417 '.':unpackFS (snd $1)))
1421 : commas ',' { $1 + 1 }
1424 -----------------------------------------------------------------------------
1428 happyError buf PState{ loc = loc } = PFailed (srcParseErr buf loc)