(* Abstract Syntax Tree and functions for printing it *)

(* This code was original from MicroC and modified by:
Keir Lauritzen, Leon Song, Guy Yardeni, Darren Hakimi*)

type op = Add | Sub | Mult | Div | Equal | Neq | Less | Leq | Greater | Geq |
          And | Or

type uop = Neg | Not

type typ = String_t | Void | Float | Array_f | Array_s

type bind = typ * string

type expr =
    | String_Lit of string
    | Float_Lit of float
    | Array_F_Lit of (string * float) list
    | Array_S_Lit of (string * string) list
    | Id of string
    | Binop of expr * op * expr
    | Unop of uop * expr
    | Assign of string * expr
    | Call of string * expr list
    | Noexpr
    | Retrieve of string * expr
    | Array_Assign of string * expr * expr

type bind_init = typ * string * expr

type stmt =
    | Block of stmt list
    | Expr of expr
    | Return of expr
    | If of expr * stmt * stmt
    | For of expr * expr * expr * stmt
    | While of expr * stmt

type action = 
    bind_init list * stmt list

type pattern = Begin | End | RegexPattern of string

type rule = pattern * action

type func_decl = {
    typ : typ;
    fname : string;
    formals : bind list;
    locals : bind_init list;
    body : stmt list;
}

type program = {
    func_decls: func_decl list;
    rules: rule list;
}

let string_of_program input_program = "42"


