Commit a59e4ad6 authored by Raphaël Rieu-Helft's avatar Raphaël Rieu-Helft

Add C AST to the printer

parent 1c9adfcf
open Ident
module C = struct
type ty =
| Tvoid
| Tsyntax of string (* ints, floats, doubles, chars are here *)
| Tptr of ty
| Tarray of ty * expr
| Tstruct of ident * (ident * ty) list
| Tunion of ident * (ident * ty) list
| Tproto of proto
| Tnamed of ident (* alias from typedef *)
(* enum, const could be added *)
(* int x=2, *y ... *)
and names = ty * (ident * expr) list
(* names with a single declaration *)
and name = ty * ident * expr
(* return type, parameter list. Variadic functions not handled. *)
and proto = ty * (ty * ident) list
and binop = Band | Bor | Beq | Bne | Bassign (* += and co. maybe to add *)
and unop = Unot | Ustar | Uaddr (* (pre|post)(incr|decr) maybe to add *)
and expr =
| Enothing
| Eunop of unop * expr
| Ebinop of binop * expr * expr
| Eternary of expr * expr * expr (* c ? then : else *)
| Ecast of ty * expr
| Ecall of expr * expr list
| Econst of constant
| Evar of string
| Esize_expr of expr
| Esize_type of ty
| Eindex of expr * expr (* Array access *)
| Edot of expr * string (* Field access with dot *)
| Earrow of expr * string (* Pointer access with arrow *)
and constant =
| Cint of string
| Cfloat of string
| Cchar of string
| Cstring of string
| Ccompound of expr list
type stmt =
| Snop
| Sexpr of expr
| Sblock of body
| Sseq of stmt * stmt
| Sif of expr * stmt * stmt
| Swhile of expr * stmt
| Sfor of expr * expr * expr * stmt
| Sbreak
| Sreturn of expr
and definition =
| Dfun of name * body
| Ddecl of names
| Dtypedef of ty * ident
| Dstructural of names (* struct, union... *)
and body = definition list * stmt
type file = definition list
end
let fg ?fname m =
let n = m.Pmodule.mod_theory.Theory.th_name.Ident.id_string in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment