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

SCM Repository

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

Annotation of /branches/vis15/src/compiler/parse-tree/parse-tree.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3352 - (view) (download)

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

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