mirror of
https://github.com/LucasVbr/croissant.git
synced 2026-12-05 15:20:50 +00:00
feat: Add typecheck to the AST
This commit is contained in:
+10
-10
@@ -11,10 +11,19 @@ let string_of_type = function
|
||||
| BooleanType -> "BooleanType"
|
||||
| VoidType -> "VoidType"
|
||||
|
||||
(** [string_of_literal l] returns a string representation of the literal [l]. *)
|
||||
let string_of_literal = function
|
||||
| Integer i -> "Integer(" ^ string_of_int i ^ ")"
|
||||
| Float f -> "Float(" ^ string_of_float f ^ ")"
|
||||
| Character c -> "Character('" ^ Char.escaped c ^ "')"
|
||||
| String s -> "String(\"" ^ s ^ "\")"
|
||||
| Boolean b -> "Boolean(" ^ string_of_bool b ^ ")"
|
||||
| Null -> "Null"
|
||||
|
||||
(** [string_of_binary_operator op] returns a string representation of the binary operator [op]. *)
|
||||
let string_of_binary_operator = function
|
||||
| Add -> "Add"
|
||||
| Substract -> "Substract"
|
||||
| Subtract -> "Subtract"
|
||||
| Multiply -> "Multiply"
|
||||
| Divide -> "Divide"
|
||||
| AmpersandAmpersand -> "AmpersandAmpersand"
|
||||
@@ -30,15 +39,6 @@ let string_of_binary_operator = function
|
||||
(** [string_of_unary_operator op] returns a string representation of the unary operator [op]. *)
|
||||
let string_of_unary_operator = function Negate -> "Negate" | Not -> "Not"
|
||||
|
||||
(** [string_of_literal l] returns a string representation of the literal [l]. *)
|
||||
let string_of_literal = function
|
||||
| Integer i -> "Integer(" ^ string_of_int i ^ ")"
|
||||
| Float f -> "Float(" ^ string_of_float f ^ ")"
|
||||
| Character c -> "Character('" ^ Char.escaped c ^ "')"
|
||||
| String s -> "String(\"" ^ s ^ "\")"
|
||||
| Boolean b -> "Boolean(" ^ string_of_bool b ^ ")"
|
||||
| Null -> "Null"
|
||||
|
||||
(** [string_of_expression e] returns a string representation of the expression [e]. *)
|
||||
let rec string_of_expression = function
|
||||
| Literal l -> "Literal(" ^ string_of_literal l ^ ")"
|
||||
|
||||
Reference in New Issue
Block a user