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 3648 - (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 :     | VECTORexp of exp list * ty
36 :     | PACKexp of exp * ty * tycon list (* abstraction packing *)
37 :     | APPexp of exp * exp
38 : mblume 1641 | HANDLEexp of exp * fnrules
39 : blume 902 | RAISEexp of exp * ty
40 :     | 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 :     | CONSTRAINTexp of exp * ty
49 :     | MARKexp of exp * region
50 :    
51 :     and rule = RULE of pat * exp
52 :    
53 :     and pat
54 :     = 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 :     | MARKpat of pat * region
69 : blume 902 | NOpat
70 :    
71 :     and dec
72 : dbm 3648 = VALdec of vb list (* always a single element list (FLINT normalization) *)
73 : blume 902 | VALRECdec of rvb list
74 :     | TYPEdec of tycon list
75 :     | DATATYPEdec of {datatycs: tycon list, withtycs: tycon list}
76 :     | ABSTYPEdec of {abstycs: tycon list, withtycs: tycon list, body: dec}
77 :     | EXCEPTIONdec of eb list
78 :     | STRdec of strb list
79 :     | ABSdec of strb list (* should be merged with STRdec in the future *)
80 :     | FCTdec of fctb list
81 :     | SIGdec of Signature list
82 :     | FSIGdec of fctSig list
83 :     | OPENdec of (SP.path * Structure) list
84 :     | LOCALdec of dec * dec
85 :     | SEQdec of dec list
86 :     | OVLDdec of var
87 :     | FIXdec of {fixity: F.fixity, ops: S.symbol list}
88 :     | MARKdec of dec * region
89 :    
90 :     (*
91 :     * The "argtycs" field in APPstr is used to record the list of instantiated
92 :     * hotycs passed to functor during the functor application.
93 :     *)
94 :     and strexp
95 :     = VARstr of Structure
96 :     | STRstr of B.binding list
97 :     | APPstr of {oper: Functor, arg: Structure, argtycs: tycpath list}
98 :     | LETstr of dec * strexp
99 :     | MARKstr of strexp * region
100 :    
101 :     (*
102 :     * For typing purpose, a functor is viewed as a high-order type constructor
103 :     * (hotyc) that takes a list of hotycs returns another list of hotycs. The
104 :     * "argtycs" field in FCTfct records the list of formal hotyc paramaters.
105 :     *)
106 :     and fctexp
107 :     = VARfct of Functor
108 :     | FCTfct of {param: Structure, argtycs: tycpath list, def: strexp}
109 :     | LETfct of dec * fctexp
110 :     | MARKfct of fctexp * region
111 :    
112 :     (*
113 :     * Each value binding vb only binds one variable identifier. That is,
114 :     * pat is always a simple VARpat (with type constraints) or it simply
115 :     * does not contain any variable patterns; boundtvs gives the list of
116 :     * type variables that are being generalized at this binding.
117 :     *)
118 :     and vb = VB of {pat: pat, exp: exp, boundtvs: tyvar list,
119 :     tyvars: tyvar list ref}
120 :    
121 :     (*
122 :     * Like value binding vb, boundtvs gives a list of type variables
123 :     * being generalized at this binding. However, the mutually recursive
124 :     * list of RVBs could share type variables, that is, the boundtvs sets
125 :     * used in these RVBs could contain overlapping set of type variables.
126 :     *)
127 :     and rvb = RVB of {var: var, exp: exp, boundtvs: tyvar list,
128 :     resultty: ty option, tyvars: tyvar list ref}
129 :    
130 :     and eb = EBgen of {exn: datacon, etype: ty option, ident: exp}
131 :     | EBdef of {exn: datacon, edef: datacon}
132 :    
133 :     and strb = STRB of {name: S.symbol, str: Structure, def: strexp}
134 :     and fctb = FCTB of {name: S.symbol, fct: Functor, def: fctexp}
135 :    
136 : mblume 1641 withtype fnrules = rule list * Types.ty
137 :    
138 : blume 902 end (* local *)
139 :     end

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