SCM Repository
Annotation of /trunk/src/ast/ast.sml
Parent Directory
|
Revision Log
Revision 82 - (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 : | | LocalVar (* local variable in method *) | ||
22 : | jhr | 69 | |
23 : | jhr | 71 | datatype var = V of { |
24 : | name : string, (* print name of variable *) | ||
25 : | id : Stamp.stamp, (* unique ID *) | ||
26 : | kind : var_kind, (* variable kind *) | ||
27 : | ty : Ty.scheme (* type scheme *) | ||
28 : | } | ||
29 : | |||
30 : | datatype program | ||
31 : | = Program of decl list | ||
32 : | |||
33 : | and decl | ||
34 : | = D_Input of var * expr option | ||
35 : | | D_Var of var_decl (* global variable decl *) | ||
36 : | | D_Actor of { (* actor decl *) | ||
37 : | name : Atom.atom, | ||
38 : | params : var list, | ||
39 : | state : var_decl list, | ||
40 : | methods : method list | ||
41 : | } | ||
42 : | | D_InitialArray of create * iter list | ||
43 : | | D_InitialCollection of create * iter list | ||
44 : | |||
45 : | and var_decl | ||
46 : | = VD_Decl of var * expr | ||
47 : | |||
48 : | and method | ||
49 : | jhr | 82 | = M_Method of Atom.atom * stmt |
50 : | jhr | 71 | |
51 : | and create | ||
52 : | = C_Create of (var * expr list) | ||
53 : | |||
54 : | and iter | ||
55 : | = I_Range of var * expr * expr | ||
56 : | |||
57 : | and stmt | ||
58 : | = S_Block of stmt list | ||
59 : | | S_Decl of var_decl | ||
60 : | | S_IfThenElse of expr * stmt * stmt | ||
61 : | | S_Assign of var * expr | ||
62 : | jhr | 72 | | S_New of Atom.atom * expr list |
63 : | jhr | 71 | | S_Die |
64 : | | S_Stabilize | ||
65 : | |||
66 : | and expr | ||
67 : | jhr | 82 | = E_Var of var * Ty.meta_var list * Ty.ty |
68 : | jhr | 71 | | E_Lit of Literal.literal |
69 : | | E_Tuple of expr list | ||
70 : | jhr | 82 | | E_Apply of var * Ty.meta_var list * expr list * Ty.ty |
71 : | jhr | 71 | | E_Cons of Ty.ty * expr list |
72 : | jhr | 81 | | E_Cond of expr * expr * expr |
73 : | jhr | 71 | |
74 : | jhr | 40 | end |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |