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

SCM Repository

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

Annotation of /trunk/src/compiler/parser/parse-tree.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3349 - (view) (download)

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

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