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

SCM Repository

[diderot] View of /trunk/src/ast/ast.sml
ViewVC logotype

View of /trunk/src/ast/ast.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (download) (annotate)
Wed May 26 18:20:49 2010 UTC (9 years, 1 month ago) by jhr
File size: 1775 byte(s)
  Working on typechecker
(* ast.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.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
      | ActorParam		(* parameter to actor definition *)
      | ActorStateVar		(* actor state 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_Actor of {				(* actor decl *)
	    name : Atom.atom,
	    params : var list,
	    state : var_decl list,
	    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 (var * expr list)

    and iter
      = 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 * Ty.meta_var list * Ty.ty
      | E_Lit of Literal.literal
      | E_Tuple of expr list
      | E_Apply of var * Ty.meta_var list * expr list * Ty.ty
      | E_Cons of Ty.ty * expr list
      | E_Cond of expr * expr * expr

  end

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