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

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