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

SCM Repository

[diderot] View of /branches/vis15/src/compiler/ast/ast.sml
ViewVC logotype

View of /branches/vis15/src/compiler/ast/ast.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3406 - (download) (annotate)
Wed Nov 11 15:55:00 2015 UTC (3 years, 11 months ago) by jhr
File size: 2645 byte(s)
working on merge: add signature to Var module
(* ast.sml
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 *
 * A typed abstract-syntax tree representation of Diderot programs.
 *)

structure AST =
  struct

    structure Ty = Types

    type var = Var.t

    datatype var_kind = datatype Var.kind

    datatype program = Program of {
        props : StrandUtil.program_prop list,
	globals : global_dcl list,
	strand : strand,
	init : stmt option,
	create : int option * expr,			(* initial strand creation; first argument *)
							(* is dimension *)
	update : stmt option
      }

  (* global declarations *)
    and global_dcl
      = D_Const of var_dcl				(* constant-variable declaration *)
      | D_Input of var_dcl * string option		(* input-variable declaration *)
      | D_Var of var_dcl				(* global-variable declaration *)
      | D_Func of var * var list * stmt			(* user-defined function *)

    and strand = Strand of {
        name : Atom.atom,
        params : var list,
        state : var_dcl list,
        methods : method list
      }

    and method
      = M_Method of StrandUtil.method_name * stmt

    and stmt
      = S_Block of stmt list
      | S_Decl of var_dcl
      | S_IfThenElse of expr * stmt * stmt
      | S_Foreach of var * expr * stmt
      | S_Assign of var * expr
      | S_New of Atom.atom * expr list
      | S_Continue
      | S_Die
      | S_Stabilize
      | S_Return of expr
      | S_Print of expr list

    and expr
      = E_Var of var
      | E_Lit of Literal.t
      | E_Select of expr * var				(* strand state-variable selection *)
      | E_Apply						(* application; we record the meta-variable *)
	  of var * Ty.meta_var list * expr list * Ty.ty	(* arguments so that we know how the the *)
							(* parameters were instantiated. *)
      | E_Comprehension					(* sequence comprehension *)
	  of expr * (var * expr) list * Ty.ty
      | E_Tensor of expr list * Ty.ty                   (* tensor-value construction *)
      | E_Seq of expr list * Ty.ty                      (* sequence-value construction (ty is result type) *)
      | E_Slice of expr * expr option list * Ty.ty      (* tensor slicing (ty is result type) *)
      | E_Cond of expr * expr * expr * Ty.ty            (* ty is result type *)
      | E_LoadNrrd of Ty.meta_var list * string * Ty.ty (* dynamic sequence and image loading *)
      | E_Coerce of {                                   (* coercion between types *)
            srcTy : Ty.ty,
            dstTy : Ty.ty,
            e : expr
          }

    withtype var_dcl = var * expr option

  end

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