refactor: Syntax with unit tests

This commit is contained in:
Lucàs
2024-07-08 16:44:42 +02:00
parent 6df363c78d
commit 2e76ccf9fc
39 changed files with 460 additions and 771 deletions
+21
View File
@@ -0,0 +1,21 @@
open Literals
open UnaryOperators
open BinaryOperators
type expressions =
| Literal of literals
| UnaryExpression of unary_operators * expressions
| BinaryExpression of binary_operators * expressions * expressions
let rec pp_expressions = function
| Literal l ->
let pp_l = pp_literals l in
Printf.sprintf "Literal(%s)" pp_l
| UnaryExpression (op, e) ->
let pp_op = pp_unary_operators op and pp_e = pp_expressions e in
Printf.sprintf "UnaryExpression(%s, %s)" pp_op pp_e
| BinaryExpression (op, e1, e2) ->
let pp_op = pp_binary_operators op
and pp_e1 = pp_expressions e1
and pp_e2 = pp_expressions e2 in
Printf.sprintf "BinaryExpression(%s, %s, %s)" pp_op pp_e1 pp_e2