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

SCM Repository

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

View of /branches/vis12/src/compiler/parser/parse-tree.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3191 - (download) (annotate)
Sat Apr 4 00:33:02 2015 UTC (4 years, 3 months ago) by jhr
File size: 3910 byte(s)
  added "continue" statement inside the update method.  The effect is to exit
  the method, but to leave the strand active (unlike die and stabilize).
(* parse-tree.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * Diderot parse-tree representation.
 *)

structure ParseTree =
  struct

    type 'a mark = 'a Error.mark

    type var = Atom.atom
    type field = Atom.atom
    type dim = IntInf.int

    datatype program
      = Program of decl list mark

    and decl
      = D_Mark of decl mark
      | D_Input of ty * var * string option * expr option
                                                (* input variable decl with optional description *)
                                                (* and optional default value *)
      | D_Var of var_decl                       (* global variable decl *)
      | D_Func of ty * var * param list * fun_body (* function decl *)
      | D_Strand of {                           (* strand decl *)
            name : var,
            params : param list,
            state : (bool * var_decl) list,     (* state variables; true means output *)
            methods : method list
          }
      | D_InitialArray of create * iter list
      | D_InitialCollection of create * iter list
      | D_Update of stmt                        (* global update block *) 

    and param
      = P_Mark of param mark
      | P_Param of ty * var

    and ty
      = T_Mark of ty mark
      | T_Bool
      | T_Int
      | T_Real
      | T_String
      | T_Strand of var 
      | T_Vec of dim
      | T_Kernel of dim
      | T_Field of {diff : dim, dim : dim, shape : dim list}
      | T_Tensor of dim list
      | T_Image of {dim : dim, shape : dim list}
      | T_Seq of ty * dim
      | T_DynSeq of ty

    and fun_body                                (* function bodies can be expressions or blocks *)
      = FB_Expr of expr
      | FB_Stmt of stmt

    and var_decl
      = VD_Mark of var_decl mark
      | VD_Decl of ty * var * expr

    and method
      = M_Mark of method mark
      | M_Method of StrandUtil.method_name * stmt

    and create
      = C_Mark of create mark
      | C_Create of (var * expr list)

    and iter
      = I_Mark of iter mark
      | I_Range of var * expr * expr

    and stmt
      = S_Mark of stmt mark
      | S_Block of stmt list
      | S_Decl of var_decl
      | S_Foreach of var_decl * stmt
      | S_IfThen of expr * stmt
      | S_IfThenElse of expr * stmt * stmt
      | S_Assign of var * expr
      | S_OpAssign of var * var * expr
      | S_New of var * expr list
      | S_Continue
      | S_Die
      | S_Stabilize
      | S_Return of expr
      | S_Print of expr list

    and expr
      = E_Mark of expr mark
      | E_Var of var
      | E_Lit of Literal.literal
      | E_OrElse of expr * expr
      | E_AndAlso of expr * expr
      | E_Cond of expr * expr * expr            (* e1 'if' e2 'else' e3 *)
      | E_BinOp of expr * var * expr
      | E_UnaryOp of var * expr
      | E_Select of expr * field 
      | E_Slice of expr * expr option list      (* tensor slicing *)
      | E_Subscript of expr * expr              (* e "{" e' "}" -- sequence subscripting *)
      | E_Apply of expr * expr list             (* field/function application *)
      | E_Tuple of expr list                    (* tuple construction (not used yet) *)
      | E_Sequence of expr list                 (* sequence construction *)
      | E_SeqComp of expr * var * expr		(* sequence comprehension *)
      | E_Cons of expr list                     (* tensor construction *)
      | E_Real of expr                          (* int to real conversion *)
      | E_Id of dim                             (* identity matrix *)
      | E_Zero of dim list                      (* zero tensor *)
      | E_NaN of dim list                       (* NaN tensor *)
      | E_Image of string                       (* initializer for images *)
      | E_Load of string                        (* initializer for dynamic sequences *)

  end

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