Module Middleend.Anf

Copyright 2024, Mikhail Gavrilenko, Danila Rudnev-Stepanyan, Daniel Vlasenko

SPDX-License-Identifier: LGPL-3.0-or-later

type im_expr =
  1. | Imm_num of int
  2. | Imm_ident of Common.Ast.ident

Immediate, atomic expressions that do not require the reduction

type comp_expr =
  1. | Comp_imm of im_expr
  2. | Comp_binop of Common.Ast.ident * im_expr * im_expr
  3. | Comp_app of im_expr * im_expr list
  4. | Comp_branch of im_expr * anf_expr * anf_expr
  5. | Comp_func of Common.Ast.ident list * anf_expr
  6. | Comp_tuple of im_expr list
  7. | Comp_alloc of im_expr list
  8. | Comp_load of im_expr * int

Complex/Computable expression

and anf_expr =
  1. | Anf_comp_expr of comp_expr
  2. | Anf_let of Common.Ast.Expression.rec_flag * Common.Ast.ident * comp_expr * anf_expr
type astructure_item =
  1. | Anf_str_eval of anf_expr
  2. | Anf_str_value of Common.Ast.Expression.rec_flag * Common.Ast.ident * anf_expr
type aprogram = astructure_item list
type anf_error = [
  1. | `Only_simple_var_params
  2. | `Func_no_params
  3. | `Let_and_not_supported
  4. | `Unsupported_let_pattern of string
  5. | `Unsupported_expr_in_normaliser
  6. | `Mutual_rec_not_supported
  7. | `Unsupported_toplevel_let
  8. | `Unsupported_toplevel_item
]
val pp_anf_error : anf_error -> string
val anf_program_res : Common.Ast.Structure.structure_item list -> (aprogram, anf_error) Stdlib.result