4 This defines the interface between the Haskell lexer/parser "hsp"
5 (written in lex/yacc/C) and the Haskell compiler proper, "hsc"
8 White space in the form of spaces, tabs and newlines may occur between
9 prefix items (I wouldn't recommend it [WDP]). A literal tab
10 terminates a string constant (and by extension also an integer
11 constant, character constant, identifier or infix operator).
13 There is a general list form, where L indicates a Cons node and N
14 indicates Nil. Elements in a list may be of arbitrary type.
16 KH, 22/08/91: Changed for Haskell 1.1+ -- this is where Haskell and LML
17 finally part company...
19 JH, 09/07/92: {0,5,6,I,O,u,v,w} Used in Data Parallel Haskell variant
22 WDP, 02/04/93: Added full-blown pragmas.
23 WDP, 15/08/93: Added even more full-blown pragmas.
25 `Tag' namespace already used:
27 #$%()+,-.012356789:=>@ABCDEGILMNOPQRSTUWXZ_abcdefghijklmnopstuvwxyz~
35 L el l List constructor el : l
42 #chars<TAB> String of characters before <TAB>
50 Expressions or Patterns (e or p)
51 --------------------------------
53 M L s s b [op] [ix] [ei]
55 (name, file, binding, fixities, imports, exports)
57 4 s Integer Constant 0, 1, ...
58 H s Unboxed Integer constant 0#, 1#, ... /* WDP */
59 F s Floating Point Constant 0.1, 0.2e-3, ...
60 J s Unboxed Double Constant 0.1##, 0.2e-3##, ... /* WDP */
61 K s Unboxed Float Constant 0.1#, 0.2e-3#, ... /* WDP */
62 C s Character Constant '...'
63 P s Unboxed character constant ???????? /* WDP */
64 S s String Constant "..."
65 V s String# Constant "..."# /* WDP */
66 Y s "Literal C" Constant ``printf'' /* WDP */
67 I s "no rep" Integer (unfoldings)
68 R s s "no rep" Rational (numerator, denominator)
69 s s "no rep" String constant (unfoldings)
72 C literal Literal constant
74 a e1 e2 Function application (e1 e2)
75 @ e1 id e2 Infix Application e1 `op` e2
76 ( e id Left section (e op)
77 ) id e Right Section (op e)
79 l L [p] e Lambda Expressions \ p1 ... pn -> e
80 c e [pb] Case Expression case e of pb1 ... pbn
81 b e1 e2 e3 If expression if e1 then e2 else e3
82 E b e Let Expression let b in e
84 : [e] Explicit List [ e1, ..., en ]
85 Z e [q] List Comprehension [ e | q ]
86 . e1 [e2] [e3] Enumeration (e2/e3 may be []) [e1,e2..e3]
88 , [e] Explicit Tuple ( e1, ..., en )
90 R e t Type Constraint e :: t
94 j id s [e] C Call/Asm (ccall/asm id/str e1 ... en)
95 s == "n" --> ccall, non-ptrs only
96 s == "p" --> ccall, ptrs allowed
97 s == "N" --> casm, non-ptrs only
98 s == "P" --> casm, ptrs allowed
99 k s e Set Cost Centre (scc s e)
101 s id p As Pattern id @ p
102 ~ p Irrefutable Pattern ~ p
103 + p e Plus Pattern n + k
104 /*WDP: why a "p" on the plus pat? (KH: historical reasons) */
112 G p e Generator p <- e
118 t L C [id] t [d] iprag DataType Binding data C => t = d1 | ... | dn
119 deriving (id1, ..., idm)
120 n L t1 t2 iprag Type Synonym type t1 = t2
121 p L [pb] Pattern Binding pb1 ; ... ; pbn
122 f L [pb] Function Binding pb1 ; ... ; pbn
123 A b1 b2 Multiple Definitions b1 ; b2
124 $ L C t b iprag Class class C => t [where b]
125 % L C id t b iprag Instance instance C => id t [where b]
126 D L [ty] Default default (ty1, ..., tyn)
128 St L [id] t iprag Type Signature id1, ...., idn :: t
129 Ss L id [t] Pragma: value specialis'ns {-# SPECIALISE id :: t1, ... tn #-}
130 SS L id t Pragma: instance specialis'n {-# SPECIALISE instance id t #-}
131 Si L id [id] Pragma: inline -- id [howto] {-# INLINE id [id]{0,1} #-}
132 Su L id Pragma: magic unfolding {-# MAGIC_UNFOLDING id #-}
133 Sa L id Pragma: abstract synonym {-# ABSTRACT id #-}
135 7 L id [ei] [rn] Import module (Interface only) import id (eis) renaming rn
139 Fixity declarations (op)
141 /* WDP: most suspicious how these don't appear in interfaces */
142 /* WDP: need line numbers? */
144 s1 s2 s3 s1 is the operator name
145 s2 is either "infix", "infixl" or "infixr"
151 T id [t] Type Constructor id t1 ... tn
152 : t Explicit List Type [t]
153 , [t] Explicit Tuple Type (t1, ..., tn)
154 > t1 t2 Explicit Function Type t1 -> t2
155 y id Type Variable id
156 3 C t Type Context C => t
158 2A id t "UniDict": class, type (core unfoldings only)
159 2B id "UniTyVarTemplate"
160 2C [id] t "UniForall" tv1 ... tvN => type
162 2D Nothing (Maybe UniType)
168 [t] Haskell context: t1, ..., tn
174 1 L id [t] Data constructor id st1 ... stn
177 Pattern Bindings (pb)
178 ---------------------
180 W L id p [ge] b Single grhs p | g1 = e1 ... where b
181 (L,id) = (Line,Function)
184 Guarded Expressions (ge)
185 ------------------------
187 g e g | e (unguarded comes in with an
188 unsavoury (Var "_otherwise") `guard')
194 s An identifier is just a string
197 Import declarations (ix)
198 ------------------------
200 e L s id [ei] [rn] b Line, File Name, Module name, imported entities,
201 renamings, interface body
202 h L s id [ei] [rn] b Hiding clause, as above...
208 id id From name, to name
211 Exported/Imported Identifers (ei)
212 ---------------------------------
214 x id ExImport Variable
215 X id ExImport Constructor/Type/Class
216 z id ExImport Class/Type plus all ops/cons
217 8 id [id] ExImport Type(C1,..Cn)
218 9 id [id] ExImport Class(o1,..on)
222 Interface pragmas (iprag)
223 -------------------------
225 User pragmas come in as "signatures"; see Bindings.
229 Pd [d] Data pragma: otherwise-hidden data constructors
230 Pt Type pragma: synonym is *abstract*
231 Pc [gprag] Class pragma: one gprag per superclass
232 Po gprag gprag Class op pragma: gprags for dsel & defm
233 OUT: Pv gprag [2prag] Value pragma: gprag + specialisations
234 Pis id gprag Instance pragma (simple): id is module name, gprag for dfun
235 Pic id gprag [1prag] Ditto (constant methods): also gprags for classops
236 PiS id gprag [3prag] Ditto (specialised): also (type, instance-prag) pairs
238 Pg Aprag uprag Sprag Uprag
239 General ("gprag"): arity, update, strictness, unfolding
241 PA id Arity ("Aprag"): arity
242 Pu id Update ("uprag"): update spec
243 PS id gprag Strictness ("Sprag"): strictness spec, gprag for worker
244 PM id id Magic unfolding ("Uprag"): var, magic-name string
245 PU id core Unfolding ("Uprag"): "guidance", corexpr-unfolding
247 Px Unfold always (these are "guidance" ones...)
248 Py id id Unfold if applied to "m" ty args, "n" val args
249 Pz id id Unfold if applied to "m" ty args, & cons in marked val positions
250 (e.g., "CXXCXX" ==> in 1st & 4th arg positions)
252 P1 id gprag ("1prag"): (name, gen-pragma) pair
253 P2 t gprag ("2prag"): (type, gen-pragma) pair
254 P3 t gprag [iprag] ("3prag"): (type, [(gen-pragma, instance-pragma)]) pair
257 Core syntax [in iprags] (core)
258 ------------------------------
262 <etc -- lots of this stuff>
264 Used in Data Parallel Haskell variant (Jonathan Hill, QMW)
265 ----------------------------------------------------------
269 5 e [parqual] Parallel ZF expression << e | [parquals] >>
270 6 [e] Pod Literal << e1,...,ek>>
271 O [e] e Processor (|e1,...,ek;e|)
275 u [t] t Explicit Processor Type (|t1,..tn;t|)
276 v [t] Explicit Pod Type <<t>>
278 ** Parallel Qualifiers **
280 0 e e Drawn From Generator exp <<- exp
281 w e e Indexed From Generator exp <<= exp
291 s Haskell line number
294 Kevin Hammond @ 22nd. August 1991