SCM Repository
Annotation of /trunk/src/compiler/ast/ast.sml
Parent Directory
|
Revision Log
Revision 171 - (view) (download)
1 : | jhr | 40 | (* ast.sml |
2 : | * | ||
3 : | * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) | ||
4 : | * All rights reserved. | ||
5 : | * | ||
6 : | * A typed abstract-syntax tree representation of Diderot programs. | ||
7 : | *) | ||
8 : | |||
9 : | structure AST = | ||
10 : | struct | ||
11 : | |||
12 : | structure Ty = Types | ||
13 : | |||
14 : | jhr | 71 | (* AST variable kinds *) |
15 : | datatype var_kind | ||
16 : | jhr | 78 | = BasisVar |
17 : | | InputVar | ||
18 : | jhr | 71 | | GlobalVar |
19 : | jhr | 72 | | ActorParam (* parameter to actor definition *) |
20 : | | ActorStateVar (* actor state variable *) | ||
21 : | jhr | 171 | | ActorOutputVar (* actor output variable *) |
22 : | jhr | 72 | | LocalVar (* local variable in method *) |
23 : | jhr | 69 | |
24 : | jhr | 71 | datatype var = V of { |
25 : | name : string, (* print name of variable *) | ||
26 : | id : Stamp.stamp, (* unique ID *) | ||
27 : | kind : var_kind, (* variable kind *) | ||
28 : | ty : Ty.scheme (* type scheme *) | ||
29 : | } | ||
30 : | |||
31 : | datatype program | ||
32 : | = Program of decl list | ||
33 : | |||
34 : | and decl | ||
35 : | = D_Input of var * expr option | ||
36 : | | D_Var of var_decl (* global variable decl *) | ||
37 : | | D_Actor of { (* actor decl *) | ||
38 : | name : Atom.atom, | ||
39 : | params : var list, | ||
40 : | jhr | 171 | state : var_decl list, (* true marks output variables *) |
41 : | jhr | 71 | methods : method list |
42 : | } | ||
43 : | | D_InitialArray of create * iter list | ||
44 : | | D_InitialCollection of create * iter list | ||
45 : | |||
46 : | and var_decl | ||
47 : | = VD_Decl of var * expr | ||
48 : | |||
49 : | and method | ||
50 : | jhr | 82 | = M_Method of Atom.atom * stmt |
51 : | jhr | 71 | |
52 : | and create | ||
53 : | jhr | 89 | = C_Create of (Atom.atom * expr list) |
54 : | jhr | 71 | |
55 : | and iter | ||
56 : | = I_Range of var * expr * expr | ||
57 : | |||
58 : | and stmt | ||
59 : | = S_Block of stmt list | ||
60 : | | S_Decl of var_decl | ||
61 : | | S_IfThenElse of expr * stmt * stmt | ||
62 : | | S_Assign of var * expr | ||
63 : | jhr | 72 | | S_New of Atom.atom * expr list |
64 : | jhr | 71 | | S_Die |
65 : | | S_Stabilize | ||
66 : | |||
67 : | and expr | ||
68 : | jhr | 170 | = E_Var of var |
69 : | jhr | 71 | | E_Lit of Literal.literal |
70 : | | E_Tuple of expr list | ||
71 : | jhr | 82 | | E_Apply of var * Ty.meta_var list * expr list * Ty.ty |
72 : | jhr | 170 | (* note: operators can be polymorphic, so we record the type arguments. *) |
73 : | jhr | 167 | | E_Cons of expr list (* tensor-value construction *) |
74 : | jhr | 81 | | E_Cond of expr * expr * expr |
75 : | jhr | 71 | |
76 : | jhr | 40 | end |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |