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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3014 - (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 : lamonts 2095 type sname = Atom.atom
16 : lamonts 2083 type field = Atom.atom
17 : lamonts 2467 type seqKind = Atom.atom (* "all" || "active" || "stable" *)
18 : jhr 25 type dim = IntInf.int
19 :    
20 :     datatype program
21 : jhr 81 = Program of decl list mark
22 : jhr 25
23 :     and decl
24 :     = D_Mark of decl mark
25 : jhr 2011 | D_Input of ty * var * string option * expr option
26 : jhr 3014 (* input variable decl with optional description *)
27 : jhr 2298 (* 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 : jhr 40 | D_InitialArray of create * iter list
37 :     | D_InitialCollection of create * iter list
38 : jhr 2298 | D_Global of stmt (* global block *)
39 : jhr 25
40 : jhr 30 and param
41 :     = P_Mark of param mark
42 :     | P_Param of ty * var
43 :    
44 : jhr 25 and ty
45 :     = T_Mark of ty mark
46 :     | T_Bool
47 :     | T_Int
48 :     | T_Real
49 :     | T_String
50 : lamonts 2083 | T_Strand of var
51 : jhr 25 | T_Vec of dim
52 : jhr 26 | T_Kernel of dim
53 : jhr 70 | T_Field of {diff : dim, dim : dim, shape : dim list}
54 : jhr 26 | T_Tensor of dim list
55 : jhr 70 | T_Image of {dim : dim, shape : dim list}
56 : jhr 1116 | T_Seq of ty * dim
57 : jhr 1687 | T_DynSeq of ty
58 : jhr 25
59 : jhr 2298 and fun_body (* function bodies can be expressions or blocks *)
60 :     = FB_Expr of expr
61 :     | FB_Stmt of stmt
62 :    
63 : jhr 27 and var_decl
64 :     = VD_Mark of var_decl mark
65 :     | VD_Decl of ty * var * expr
66 :    
67 : jhr 30 and method
68 :     = M_Mark of method mark
69 : jhr 1640 | M_Method of StrandUtil.method_name * stmt
70 : jhr 30
71 : jhr 40 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 : jhr 25 and stmt
80 : jhr 27 = S_Mark of stmt mark
81 :     | S_Block of stmt list
82 :     | S_Decl of var_decl
83 : lamonts 2083 | S_Foreach of var_decl * stmt
84 : jhr 27 | S_IfThen of expr * stmt
85 :     | S_IfThenElse of expr * stmt * stmt
86 :     | S_Assign of var * expr
87 : jhr 1296 | S_OpAssign of var * var * expr
88 : jhr 27 | S_New of var * expr list
89 :     | S_Die
90 :     | S_Stabilize
91 : jhr 2298 | S_Return of expr
92 : jhr 1640 | S_Print of expr list
93 : jhr 25
94 :     and expr
95 :     = E_Mark of expr mark
96 :     | E_Var of var
97 : jhr 27 | E_Lit of Literal.literal
98 : jhr 78 | E_OrElse of expr * expr
99 : lamonts 2453 | E_StrandSeq of sname * seqKind
100 :     | E_Reduction of expr * expr * var * expr
101 : jhr 78 | E_AndAlso of expr * expr
102 : jhr 3014 | E_Cond of expr * expr * expr (* e1 'if' e2 'else' e3 *)
103 : jhr 25 | E_BinOp of expr * var * expr
104 : jhr 27 | E_UnaryOp of var * expr
105 : lamonts 2083 | E_Selector of expr * field
106 : jhr 2298 | E_Slice of expr * expr option list (* tensor slicing *)
107 :     | E_Subscript of expr * expr (* e "{" e' "}" -- sequence subscripting *)
108 :     | E_Apply of expr * expr list (* field/function application *)
109 : jhr 3014 | E_Tuple of expr list (* tuple construction (not used yet) *)
110 :     | E_Sequence of expr list (* sequence construction *)
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_Image of string (* initializer for images *)
116 :     | E_Load of string (* initializer for dynamic sequences *)
117 : jhr 25
118 :     end

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