mirror of
https://github.com/LucasVbr/croissant.git
synced 2026-07-09 06:57:48 +00:00
refactor: Edit type name for consistency
This commit is contained in:
+19
-7
@@ -4,12 +4,12 @@ open Syntax
|
||||
|
||||
(** [string_of_type t] returns a string representation of the type [t]. *)
|
||||
let string_of_type = function
|
||||
| Type_Integer -> "Type_Integer"
|
||||
| Type_Float -> "Type_Float"
|
||||
| Type_Character -> "Type_Character"
|
||||
| Type_String -> "Type_String"
|
||||
| Type_Boolean -> "Type_Boolean"
|
||||
| Type_Void -> "Type_Void"
|
||||
| IntegerType -> "IntegerType"
|
||||
| FloatType -> "FloatType"
|
||||
| CharacterType -> "CharacterType"
|
||||
| StringType -> "StringType"
|
||||
| BooleanType -> "BooleanType"
|
||||
| VoidType -> "VoidType"
|
||||
|
||||
(** [string_of_binary_operator op] returns a string representation of the binary operator [op]. *)
|
||||
let string_of_binary_operator = function
|
||||
@@ -68,4 +68,16 @@ let string_of_statement = function
|
||||
let string_of_source_file = function
|
||||
| SourceFile stmts ->
|
||||
let stmt_strings = List.map string_of_statement stmts in
|
||||
"SourceFile([" ^ String.concat ", " stmt_strings ^ "])"
|
||||
"SourceFile([" ^ String.concat ", " stmt_strings ^ "])"
|
||||
|
||||
(** The signature of the module [PRINT]. *)
|
||||
module type Print = sig
|
||||
val string_of_type : Syntax._type -> string
|
||||
val string_of_binary_operator : Syntax.binary_operator -> string
|
||||
val string_of_unary_operator : Syntax.unary_operator -> string
|
||||
val string_of_literal : Syntax.literal -> string
|
||||
val string_of_expression : Syntax.expression -> string
|
||||
val string_of_variable_declaration : Syntax.variable_declaration -> string
|
||||
val string_of_statement : Syntax.statement -> string
|
||||
val string_of_source_file : Syntax.source_file -> string
|
||||
end
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
(* lib/ast/syntax.ml *)
|
||||
|
||||
type _type =
|
||||
| Type_Integer
|
||||
| Type_Float
|
||||
| Type_Character
|
||||
| Type_String
|
||||
| Type_Boolean
|
||||
| Type_Void
|
||||
| IntegerType
|
||||
| FloatType
|
||||
| CharacterType
|
||||
| StringType
|
||||
| BooleanType
|
||||
| VoidType
|
||||
|
||||
type literal =
|
||||
| Integer of int
|
||||
|
||||
+6
-6
@@ -75,12 +75,12 @@ variable_declaration:
|
||||
| IDENTIFIER ":" tp { VariableDeclaration($3, Identifier($1), Literal(Null)) }
|
||||
|
||||
tp:
|
||||
| INTEGER_TYPE { Type_Integer }
|
||||
| FLOAT_TYPE { Type_Float }
|
||||
| CHARACTER_TYPE { Type_Character }
|
||||
| STRING_TYPE { Type_String }
|
||||
| BOOLEAN_TYPE { Type_Boolean }
|
||||
| VOID_TYPE { Type_Void }
|
||||
| INTEGER_TYPE { IntegerType }
|
||||
| FLOAT_TYPE { FloatType }
|
||||
| CHARACTER_TYPE { CharacterType }
|
||||
| STRING_TYPE { StringType }
|
||||
| BOOLEAN_TYPE { BooleanType }
|
||||
| VOID_TYPE { VoidType }
|
||||
|
||||
expression:
|
||||
| literal { Literal($1) }
|
||||
|
||||
Reference in New Issue
Block a user