(* ast.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu) * All rights reserved. * * A typed abstract-syntax tree representation of Diderot programs. *) structure AST = struct structure Ty = Types (* AST variable kinds *) datatype var_kind = BasisVar | InputVar | GlobalVar | StrandParam (* parameter to strand definition *) | StrandStateVar (* strand state variable *) | StrandOutputVar (* strand output variable *) | LocalVar (* local variable in method *) datatype var = V of { name : string, (* print name of variable *) id : Stamp.stamp, (* unique ID *) kind : var_kind, (* variable kind *) ty : Ty.scheme (* type scheme *) } datatype program = Program of decl list and decl = D_Input of var * expr option | D_Var of var_decl (* global variable decl *) | D_Strand of { (* strand decl *) name : Atom.atom, params : var list, state : var_decl list, (* true marks output variables *) methods : method list } | D_InitialArray of create * iter list | D_InitialCollection of create * iter list and var_decl = VD_Decl of var * expr and method = M_Method of Atom.atom * stmt and create = C_Create of (Atom.atom * expr list) and iter (* NOTE: the typechecker restricts the variable and expression to have integer type *) = I_Range of var * expr * expr and stmt = S_Block of stmt list | S_Decl of var_decl | S_IfThenElse of expr * stmt * stmt | S_Assign of var * expr | S_New of Atom.atom * expr list | S_Die | S_Stabilize and expr = E_Var of var | E_Lit of Literal.literal | E_Tuple of expr list | E_Apply of var * Ty.meta_var list * expr list * Ty.ty (* note: operators can be polymorphic, so we record the type arguments. *) | E_Cons of expr list (* tensor-value construction *) | E_Slice of expr * expr option list * Ty.ty (* tensor slicing *) | E_Cond of expr * expr * expr * Ty.ty (* ty is result type *) end
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: ty (* tensor slicing *) | E_Cond of expr * expr * expr * Ty.ty (* ty is result type *) end