mirror of
https://github.com/LucasVbr/croissant.git
synced 2026-05-16 17:12:07 +00:00
refactor: Syntax with unit tests
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user