Module Mml.Ast

type name = string
type binop =
  1. | Add
    (*

    Addition: +

    *)
  2. | Mul
    (*

    Multiplication: *

    *)
  3. | Sub
    (*

    Subtraction: -

    *)
  4. | Div
    (*

    Division: /

    *)
  5. | Leq
    (*

    Less than or equal: <=

    *)
  6. | Lt
    (*

    Less than: <

    *)
  7. | Eq
    (*

    Equal: =

    *)
  8. | Geq
    (*

    Greater than or equal: >=

    *)
  9. | Gt
    (*

    Greater than: >

    *)

Binary operators

val pp_binop : Ppx_deriving_runtime.Format.formatter -> binop -> Ppx_deriving_runtime.unit
val show_binop : binop -> Ppx_deriving_runtime.string
type 'name t =
  1. | Var of 'name
    (*

    Variable reference: represents a variable by its name

    *)
  2. | Fun of 'name * 'name t
    (*

    Function abstraction: fun x -> body creates a function with parameter x and body

    *)
  3. | App of 'name t * 'name t
    (*

    Function application: f arg applies function f to argument arg

    *)
  4. | Int of int
    (*

    Integer literal: constant integer value

    *)
  5. | Neg of 'name t
    (*

    Unary negation: -e negates the value of expression e

    *)
  6. | Bin of binop * 'name t * 'name t
    (*

    Binary operation: e1 op e2 applies binary operator op to e1 and e2

    *)
  7. | Let of 'name * 'name t * 'name t
    (*

    Let binding: let x = e1 in e2 binds x to e1 in scope of e2

    *)
  8. | If of 'name t * 'name t * 'name t
    (*

    Conditional: if cond then e1 else e2 evaluates to e1 if cond is non-zero, otherwise e2

    *)
  9. | LetRec of 'name * 'name t * 'name t
    (*

    Recursive let: let rec f = e1 in e2 creates recursive binding of f to e1 in e2

    *)
  10. | Fix
    (*

    Fixed-point operator: fix enables recursion without explicit let rec

    *)

Abstract syntax tree for miniML expressions