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