Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /branches/vis12/src/compiler/parser/parse-tree.sml
ViewVC logotype

Annotation of /branches/vis12/src/compiler/parser/parse-tree.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2634 - (view) (download)

1 : jhr 25 (* parse-tree.sml
2 :     *
3 : jhr 435 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 : jhr 25 * All rights reserved.
5 :     *
6 :     * Diderot parse-tree representation.
7 :     *)
8 :    
9 :     structure ParseTree =
10 :     struct
11 :    
12 : jhr 27 type 'a mark = 'a Error.mark
13 :    
14 : jhr 25 type var = Atom.atom
15 :     type dim = IntInf.int
16 :    
17 :     datatype program
18 : jhr 81 = Program of decl list mark
19 : jhr 25
20 :     and decl
21 :     = D_Mark of decl mark
22 : jhr 2011 | D_Input of ty * var * string option * expr option
23 : jhr 2634 (* input variable decl with optional description *)
24 : jhr 2277 (* and optional default value *)
25 :     | D_Var of var_decl (* global variable decl *)
26 : jhr 2135 | D_Func of ty * var * param list * fun_body (* function decl *)
27 : jhr 2277 | D_Strand of { (* strand decl *)
28 :     name : var,
29 :     params : param list,
30 :     state : (bool * var_decl) list, (* state variables; true means output *)
31 :     methods : method list
32 :     }
33 : jhr 40 | D_InitialArray of create * iter list
34 :     | D_InitialCollection of create * iter list
35 : jhr 25
36 : jhr 30 and param
37 :     = P_Mark of param mark
38 :     | P_Param of ty * var
39 :    
40 : jhr 25 and ty
41 :     = T_Mark of ty mark
42 :     | T_Bool
43 :     | T_Int
44 :     | T_Real
45 :     | T_String
46 :     | T_Vec of dim
47 : jhr 26 | T_Kernel of dim
48 : jhr 70 | T_Field of {diff : dim, dim : dim, shape : dim list}
49 : jhr 26 | T_Tensor of dim list
50 : jhr 70 | T_Image of {dim : dim, shape : dim list}
51 : jhr 1116 | T_Seq of ty * dim
52 : jhr 1687 | T_DynSeq of ty
53 : jhr 25
54 : jhr 2277 and fun_body (* function bodies can be expressions or blocks *)
55 : jhr 2133 = FB_Expr of expr
56 :     | FB_Stmt of stmt
57 :    
58 : jhr 27 and var_decl
59 :     = VD_Mark of var_decl mark
60 :     | VD_Decl of ty * var * expr
61 :    
62 : jhr 30 and method
63 :     = M_Mark of method mark
64 : jhr 1640 | M_Method of StrandUtil.method_name * stmt
65 : jhr 30
66 : jhr 40 and create
67 :     = C_Mark of create mark
68 :     | C_Create of (var * expr list)
69 :    
70 :     and iter
71 :     = I_Mark of iter mark
72 :     | I_Range of var * expr * expr
73 :    
74 : jhr 25 and stmt
75 : jhr 27 = S_Mark of stmt mark
76 :     | S_Block of stmt list
77 :     | S_Decl of var_decl
78 :     | S_IfThen of expr * stmt
79 :     | S_IfThenElse of expr * stmt * stmt
80 :     | S_Assign of var * expr
81 : jhr 1296 | S_OpAssign of var * var * expr
82 : jhr 27 | S_New of var * expr list
83 :     | S_Die
84 :     | S_Stabilize
85 : jhr 2133 | S_Return of expr
86 : jhr 1640 | S_Print of expr list
87 : jhr 25
88 :     and expr
89 :     = E_Mark of expr mark
90 :     | E_Var of var
91 : jhr 27 | E_Lit of Literal.literal
92 : jhr 78 | E_OrElse of expr * expr
93 :     | E_AndAlso of expr * expr
94 : jhr 2277 | E_Cond of expr * expr * expr (* e1 'if' e2 'else' e3 *)
95 : jhr 25 | E_BinOp of expr * var * expr
96 : jhr 27 | E_UnaryOp of var * expr
97 : jhr 2277 | E_Slice of expr * expr option list (* tensor slicing *)
98 :     | E_Subscript of expr * expr (* e "{" e' "}" -- sequence subscripting *)
99 :     | E_Apply of expr * expr list (* field/function application *)
100 :     | E_Tuple of expr list (* tuple construction (not used yet) *)
101 :     | E_Sequence of expr list (* sequence construction *)
102 :     | E_Cons of expr list (* tensor construction *)
103 :     | E_Real of expr (* int to real conversion *)
104 :     | E_Id of dim (* identity matrix *)
105 :     | E_Zero of dim list (* zero tensor *)
106 :     | E_Image of string (* initializer for images *)
107 :     | E_Load of string (* initializer for dynamic sequences *)
108 : jhr 25
109 :     end

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