This repository has been archived on 2022-12-27. You can view files and clone it, but cannot push or open issues or pull requests.
compilateurMIPS/ast.ml

46 lines
733 B
OCaml
Raw Normal View History

2022-12-08 19:55:22 +01:00
type type_t = Int_t
2022-12-06 20:39:15 +01:00
module Syntax = struct
2022-12-08 19:55:22 +01:00
type ident = string
type value = Int of int
2022-12-06 20:39:15 +01:00
type expr =
2022-12-08 19:55:22 +01:00
| Val of
{ value : value
; pos : Lexing.position
}
| Var of
{ name : ident
; pos : Lexing.position
}
type instr =
| Decl of
{ name : ident
; type_t : type_t
2022-12-06 22:22:48 +01:00
; pos : Lexing.position
}
2022-12-08 19:55:22 +01:00
| Assign of
{ var : ident
; expr : expr
; pos : Lexing.position
}
and block = instr list
2022-12-06 20:39:15 +01:00
end
module IR = struct
2022-12-08 19:55:22 +01:00
type ident = string
2022-12-08 14:04:46 +01:00
type value = Int of int
2022-12-08 19:55:22 +01:00
type expr =
| Val of value
| Var of ident
type instr =
| Decl of ident
| Assign of ident * expr
and block = instr list
2022-12-06 20:39:15 +01:00
end