Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/compiler/ElabData/syntax/absyn.sml
ViewVC logotype

Annotation of /sml/trunk/compiler/ElabData/syntax/absyn.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4328 - (view) (download)

1 : blume 902 (* absyn.sml
2 :     *
3 :     * (C) 2001 Lucent Technologies, Bell Labs
4 :     *)
5 :     structure Absyn : ABSYN =
6 :     struct
7 :    
8 :     local
9 :     structure S = Symbol
10 :     structure F = Fixity
11 :     structure SP = SymPath
12 :     structure B = Bindings
13 :     open VarCon Modules Types
14 :     in
15 :    
16 :     type region = Ast.region (* = int * int *)
17 :    
18 :     datatype numberedLabel = LABEL of {name: S.symbol, number: int}
19 :    
20 :     datatype exp
21 : dbm 2492 = VARexp of var ref * tyvar list
22 : dbm 3648 (* the 2nd arg is a type univar list used to capture the instantiation
23 : dbm 2492 parameters for this occurence of var when its type is polymorphic.
24 :     FLINT will use these to provide explicit type parameters for
25 : dbm 3648 var if var is bound to a primop. These will then be used to specialize
26 :     the primop. *)
27 : dbm 2492 | CONexp of datacon * tyvar list (* ditto *)
28 : blume 902 | INTexp of IntInf.int * ty
29 :     | WORDexp of IntInf.int * ty
30 :     | REALexp of string
31 :     | STRINGexp of string
32 :     | CHARexp of string
33 :     | RECORDexp of (numberedLabel * exp) list
34 :     | SELECTexp of numberedLabel * exp (* record selections *)
35 : jhr 4328 | VECTORexp of exp list * ty
36 : blume 902 | PACKexp of exp * ty * tycon list (* abstraction packing *)
37 :     | APPexp of exp * exp
38 : mblume 1641 | HANDLEexp of exp * fnrules
39 : jhr 4328 | RAISEexp of exp * ty
40 : blume 902 | CASEexp of exp * rule list * bool (* true: match; false: bind *)
41 : mblume 1332 | IFexp of { test: exp, thenCase: exp, elseCase: exp }
42 :     | ANDALSOexp of exp * exp
43 :     | ORELSEexp of exp * exp
44 :     | WHILEexp of { test: exp, expr: exp }
45 : mblume 1641 | FNexp of fnrules
46 : blume 902 | LETexp of dec * exp
47 :     | SEQexp of exp list
48 : jhr 4328 | CONSTRAINTexp of exp * ty
49 : blume 902 | MARKexp of exp * region
50 :    
51 :     and rule = RULE of pat * exp
52 :    
53 : jhr 4328 and pat
54 : blume 902 = WILDpat
55 :     | VARpat of var
56 :     | INTpat of IntInf.int * ty
57 :     | WORDpat of IntInf.int * ty
58 :     | REALpat of string
59 :     | STRINGpat of string
60 :     | CHARpat of string
61 : dbm 2492 | CONpat of datacon * tyvar list (* See comment for VARexp *)
62 : blume 902 | RECORDpat of {fields: (label * pat) list, flex: bool, typ: ty ref}
63 : dbm 2492 | APPpat of datacon * tyvar list * pat
64 : blume 902 | CONSTRAINTpat of pat * ty
65 :     | LAYEREDpat of pat * pat
66 :     | ORpat of pat * pat
67 : dbm 3648 | VECTORpat of pat list * ty
68 : jhr 4328 | MARKpat of pat * region
69 : blume 902 | NOpat
70 :    
71 : jhr 4328 and dec
72 : dbm 3648 = VALdec of vb list (* always a single element list (FLINT normalization) *)
73 : blume 902 | VALRECdec of rvb list
74 : jhr 4304 | DOdec of exp
75 : blume 902 | TYPEdec of tycon list
76 :     | DATATYPEdec of {datatycs: tycon list, withtycs: tycon list}
77 :     | ABSTYPEdec of {abstycs: tycon list, withtycs: tycon list, body: dec}
78 :     | EXCEPTIONdec of eb list
79 :     | STRdec of strb list
80 :     | ABSdec of strb list (* should be merged with STRdec in the future *)
81 :     | FCTdec of fctb list
82 :     | SIGdec of Signature list
83 :     | FSIGdec of fctSig list
84 :     | OPENdec of (SP.path * Structure) list
85 :     | LOCALdec of dec * dec
86 :     | SEQdec of dec list
87 :     | OVLDdec of var
88 : jhr 4328 | FIXdec of {fixity: F.fixity, ops: S.symbol list}
89 : blume 902 | MARKdec of dec * region
90 :    
91 :     (*
92 :     * The "argtycs" field in APPstr is used to record the list of instantiated
93 :     * hotycs passed to functor during the functor application.
94 :     *)
95 : jhr 4328 and strexp
96 :     = VARstr of Structure
97 : blume 902 | STRstr of B.binding list
98 :     | APPstr of {oper: Functor, arg: Structure, argtycs: tycpath list}
99 :     | LETstr of dec * strexp
100 :     | MARKstr of strexp * region
101 :    
102 :     (*
103 : jhr 4328 * For typing purpose, a functor is viewed as a high-order type constructor
104 : blume 902 * (hotyc) that takes a list of hotycs returns another list of hotycs. The
105 :     * "argtycs" field in FCTfct records the list of formal hotyc paramaters.
106 :     *)
107 : jhr 4328 and fctexp
108 : blume 902 = VARfct of Functor
109 :     | FCTfct of {param: Structure, argtycs: tycpath list, def: strexp}
110 :     | LETfct of dec * fctexp
111 :     | MARKfct of fctexp * region
112 :    
113 :     (*
114 : jhr 4328 * Each value binding vb only binds one variable identifier. That is,
115 : blume 902 * pat is always a simple VARpat (with type constraints) or it simply
116 :     * does not contain any variable patterns; boundtvs gives the list of
117 : jhr 4328 * type variables that are being generalized at this binding.
118 : blume 902 *)
119 :     and vb = VB of {pat: pat, exp: exp, boundtvs: tyvar list,
120 :     tyvars: tyvar list ref}
121 :    
122 :     (*
123 : jhr 4328 * Like value binding vb, boundtvs gives a list of type variables
124 : blume 902 * being generalized at this binding. However, the mutually recursive
125 :     * list of RVBs could share type variables, that is, the boundtvs sets
126 :     * used in these RVBs could contain overlapping set of type variables.
127 :     *)
128 :     and rvb = RVB of {var: var, exp: exp, boundtvs: tyvar list,
129 :     resultty: ty option, tyvars: tyvar list ref}
130 :    
131 :     and eb = EBgen of {exn: datacon, etype: ty option, ident: exp}
132 :     | EBdef of {exn: datacon, edef: datacon}
133 :    
134 : jhr 4328 and strb = STRB of {name: S.symbol, str: Structure, def: strexp}
135 : blume 902 and fctb = FCTB of {name: S.symbol, fct: Functor, def: fctexp}
136 :    
137 : mblume 1641 withtype fnrules = rule list * Types.ty
138 :    
139 : blume 902 end (* local *)
140 :     end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0