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 1641 - (view) (download)
Original Path: sml/trunk/src/compiler/ElabData/syntax/absyn.sml

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

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