Permalink
Browse files

[cleanup] remove chars: compiler

  • Loading branch information...
1 parent 53c835a commit 0ab80d5fe4c6e479081fae4305804662ff2d250d @fpessaux fpessaux committed with François-Régis Sinot Jul 29, 2011
View
@@ -270,16 +270,12 @@ module type S = sig
*)
(** *)
- type ty_char
type ty_float
type ty_int
type ty_null
type ty_string
(** *)
- val wrap_char : char -> ty_char
- val unwrap_char : ty_char -> char
-
val wrap_float : float -> ty_float
val unwrap_float : ty_float -> float
@@ -379,14 +379,11 @@ b_BASE <-
/ b_External
/ "(" spacing b_ENTRY spacing ")" {{ __3 }}
-b_Const <- (CintError / Cint / Cfloat / Cstring / Cchar ) {{ B.Const (pos(), __1) }}
+b_Const <- (Cint / Cfloat / Cstring) {{ B.Const (pos(), __1) }}
-CintError <- "int64" ![a-zA-Z]
- {{ error "@{<bright>int64@} are not supported for external primitives,@ use an @{<bright>int@} or use an @{<bright>external type@}@\n" }}
Cint <- "int" ![a-zA-Z] {{ Q.TyInt }}
Cfloat <- "float" ![a-zA-Z] {{ Q.TyFloat }}
Cstring <- "string" ![a-zA-Z] {{ Q.TyString }}
-Cchar <- "char" ![a-zA-Z] {{ Q.TyChar }}
b_TypeVar <-
/ "'" name
@@ -154,7 +154,6 @@ struct
match t with
| B.Const (_, c) -> (
match c with
- | Q.TyChar -> serverlib fmt opa_char
| Q.TyFloat -> serverlib fmt opa_float
| Q.TyInt -> serverlib fmt opa_int
| Q.TyNull -> serverlib fmt opa_null
View
@@ -62,15 +62,13 @@ type const_expr =
| Int of int (** simplify the life in opa / ml code generator *)
| Float of float
| String of string
- | Char of char
(**
The type of a simple value.
Please keep them sorted alphabetically, for tests and display.
*)
type const_ty =
- | TyChar
| TyFloat
| TyInt
| TyNull (** empty type: nothing should really have this type *)
@@ -84,14 +82,12 @@ struct
| Int _ -> TyInt
| Float _ -> TyFloat
| String _ -> TyString
- | Char _ -> TyChar
(** Return a human-readable version of a simple value.*)
let string_of_expr = function
| Int i -> string_of_int i
| Float f -> string_of_float f
| String s -> Printf.sprintf "%S" s
- | Char c -> Printf.sprintf "%C" c
let pp_expr fmt expr = Format.pp_print_string fmt (string_of_expr expr)
@@ -101,7 +97,6 @@ struct
(** if we reswitch to Int64.t, to preserve confusion in declaration of type (e.g. by using register directives in libbsl) it is preferable to print int64 instead of int *)
| TyFloat -> "float"
| TyString -> "string"
- | TyChar -> "char"
| TyNull -> "null"
let pp_ty fmt ty = Format.pp_print_string fmt (string_of_ty ty)
@@ -118,15 +113,13 @@ struct
| TyInt -> "long long int"
| TyFloat -> "double"
| TyString -> "char *"
- | TyChar -> "char"
| TyNull -> assert false (* "void *" ?? *)
(** meta : keep it not too far from the definition *)
let meta = function
| TyInt -> "TyInt"
| TyFloat -> "TyFloat"
| TyString -> "TyString"
- | TyChar -> "TyChar"
| TyNull -> "TyNull"
end
@@ -204,7 +204,6 @@ struct
let int i = const (Q.Int i)
let float f = const (Q.Float f)
let string s = const (Q.String s)
- let char c = const (Q.Char c)
let coerce e t = Q.Coerce (Annot.refresh (Q.Label.expr e), e, t)
@@ -960,7 +959,6 @@ struct
let int ?(label=Annot.next_label nopos) i = const ~label (Q.Int i)
let float ?(label=Annot.next_label nopos) f = const ~label (Q.Float f)
let string ?(label=Annot.next_label nopos) s = const ~label (Q.String s)
- let char ?(label=Annot.next_label nopos) c = const ~label (Q.Char c)
let letin ?(label=Annot.next_label nopos) l e = Q.LetIn (label, l, e)
let letrecin ?(label=Annot.next_label nopos) l e = Q.LetRecIn (label, l, e)
@@ -139,7 +139,6 @@ sig
val int : int -> QmlAst.expr
val float : float -> QmlAst.expr
val string : string -> QmlAst.expr
- val char : char -> QmlAst.expr
val unit : unit -> QmlAst.expr
val _false: unit -> QmlAst.expr
val _true: unit -> QmlAst.expr
@@ -486,7 +485,6 @@ sig
val int : ?label:Annot.label -> int -> QmlAst.expr
val float : ?label:Annot.label -> float -> QmlAst.expr
val string : ?label:Annot.label -> string -> QmlAst.expr
- val char : ?label:Annot.label -> char -> QmlAst.expr
val directive : ?label:Annot.label -> QmlAst.qml_directive -> QmlAst.expr list -> QmlAst.ty list -> QmlAst.expr
@@ -353,7 +353,6 @@ struct
| Q.Int a, Q.Int b -> Pervasives.compare a b
| Q.Float a, Q.Float b -> Pervasives.compare a b
| Q.String a, Q.String b -> String.compare a b
- | Q.Char a, Q.Char b -> Char.compare a b
| _ -> assert false
let equal a b = compare a b = 0
@@ -1160,11 +1160,7 @@ struct
| Q.Int i, Q.Int i' -> if i+1=i' then [] else [Q.Int( i+1 )]
| Q.Float f, Q.Float f' -> let f'' = (f+.f')/.2.0 in if f<f'' && f''< f' then [Q.Float f''] else []
| Q.String s, Q.String s' -> [Q.String (s^"_"^s')]
- | Q.Char c, Q.Char c' ->
- let c = Char.code c in
- let c' = Char.code c' in
- if c+1=c' then [] else [Q.Char( Char.chr (c+1))]
- | Q.Char _, _ | Q.String _ , _ | Q.Int _ , _ | Q.Float _,_ -> assert false
+ | Q.String _ , _ | Q.Int _ , _ | Q.Float _,_ -> assert false
in
let outside first last = match first,last with
| Q.Int i, Q.Int i' ->
@@ -1178,15 +1174,7 @@ struct
else [Q.Float (f +. 1.0)]
else [Q.Float (f' -. 1.0)]
| Q.String _, Q.String s' -> [ Q.String (s'^", me and many many others") ]
- | Q.Char c, Q.Char c' ->
- let c = Char.code c in
- let c' = Char.code c' in
- if c = 0 then
- if c' = 255 then []
- else [Q.Char (Char.chr (c'+1))]
- else [Q.Char (Char.chr (c'-1))]
- | Q.Char _, _ | Q.String _ , _ | Q.Int _ , _ | Q.Float _,_ -> assert false
- in
+ | Q.String _ , _ | Q.Int _ , _ | Q.Float _,_ -> assert false in
let first = List.hd l in
let rec aux last l =
match last,l with
View
@@ -804,7 +804,6 @@ let sexp_tyv f t = Format.pp_print_string f (QmlTypeVars.TypeVar.to_string t)
let sexp_rowv f t = Format.pp_print_string f (QmlTypeVars.RowVar.to_string t)
let sexp_colv f t = Format.pp_print_string f (QmlTypeVars.ColVar.to_string t)
let rec sexp_ty f = function
- | Q.TypeConst Q.TyChar -> Format.fprintf f "C"
| Q.TypeConst Q.TyFloat -> Format.fprintf f "F"
| Q.TypeConst Q.TyInt -> Format.fprintf f "I"
| Q.TypeConst Q.TyNull -> Format.fprintf f "Null"
@@ -446,8 +446,6 @@ let type_float () = type_named (QmlAst.TypeIdent.of_string Opacapi.Types.float)
let type_string () = type_named (QmlAst.TypeIdent.of_string Opacapi.Types.string) [] None
-let type_char () = type_named (QmlAst.TypeIdent.of_string Opacapi.Types.char) [] None
-
(* ************************************************************************** *)
@@ -70,7 +70,6 @@ val type_int: unit -> W_Algebra.simple_type
val type_bool: unit -> W_Algebra.simple_type
val type_float: unit -> W_Algebra.simple_type
val type_string: unit -> W_Algebra.simple_type
-val type_char: unit -> W_Algebra.simple_type
val type_arrow:
W_Algebra.simple_type list -> W_Algebra.simple_type -> W_Algebra.simple_type
val type_closed_record:
@@ -29,7 +29,6 @@ let infer_constant_type = function
| QmlAst.Int _ -> W_CoreTypes.type_int ()
| QmlAst.Float _ -> W_CoreTypes.type_float ()
| QmlAst.String _ -> W_CoreTypes.type_string ()
- | QmlAst.Char _ -> W_CoreTypes.type_char ()
@@ -102,7 +102,6 @@ let simple_type_to_qml_type initial_ty =
| "int" -> QmlAst.TypeConst QmlAst.TyInt
| "float" -> QmlAst.TypeConst QmlAst.TyFloat
| "string" -> QmlAst.TypeConst QmlAst.TyString
- | "char" -> QmlAst.TypeConst QmlAst.TyChar
| _ ->
(* The general and default case. Attention, ni QML we
never export the unwounded representation of the type,
@@ -299,7 +299,6 @@ let qml_type_to_simple_type qml_tydef_env initial_qml_ty ~is_type_annotation =
match qml_ty with
| QmlAst.TypeConst const_ty -> (
match const_ty with
- | QmlAst.TyChar -> W_CoreTypes.type_char ()
| QmlAst.TyFloat -> W_CoreTypes.type_float ()
| QmlAst.TyInt -> W_CoreTypes.type_int ()
| QmlAst.TyString -> W_CoreTypes.type_string ()
View
@@ -43,7 +43,6 @@ type const_type_expr =
| TypeInt64
| TypeFloat
| TypeBool
- | TypeChar
| TypeUnit
(* Module.Module.name *)
View
@@ -116,7 +116,6 @@ struct
| TypeInt64 -> output_string oc "int64"
| TypeFloat -> output_string oc "float"
| TypeBool -> output_string oc "bool"
- | TypeChar -> output_string oc "char"
| TypeUnit -> output_string oc "unit"
let type_name oc = output_concat_map oc "." output_string
@@ -19,13 +19,12 @@ read default.trx global (spacing)
spacing <- (Default.space $ / Default.mlcomment)* $
read ocaml_keywords.trx
-typeconst <- (IntT / Int64T / FloatT / StringT / UnitT / CharT / BoolT) {{ TypeConst __1 }}
+typeconst <- (IntT / Int64T / FloatT / StringT / UnitT / BoolT) {{ TypeConst __1 }}
IntT <- "int" {{ TypeInt }}
Int64T <- "int64" {{ TypeInt64 }}
FloatT <- "float" {{ TypeFloat }}
StringT <- "string" {{ TypeString }}
UnitT <- "unit" {{ TypeUnit }}
-CharT <- "char" {{ TypeChar }}
BoolT <- "bool" {{ TypeBool }}
typeIdent_cont <- [a-zA-Z0-9_]
@@ -137,7 +137,6 @@ OpaDocXhtml = {{
else id
rec aux_ty_const(ty_const) =
match ty_const with
- | {TyChar} -> <>char</>
| {TyInt} -> <>int</>
| {TyFloat} -> <>float</>
| {TyString} -> <>string</>
@@ -65,7 +65,6 @@ OpaApiFile = {{
end
rec aux_ty_const(table, ty_const) =
match ty_const with
- | {TyChar} -> associate_id_val("char", val, table)
| {TyInt} -> associate_id_val("int", val, table)
| {TyFloat} -> associate_id_val("float", val, table)
| {TyString} -> associate_id_val("string", val, table)
View
@@ -40,7 +40,7 @@ let keyword = function
| "match" | "with" | "type" | "do" | "if" | "then" | "else" | "as" | "_" -> true
| _ -> false
let basic_type = function
- | "int" | "char" | "string" | "float" -> true
+ | "int" | "string" | "float" -> true
| _ -> false
let operator_regexp = Str.regexp "[-.+\\^*/<>=@|&!]+"
let classify_string s =
@@ -183,7 +183,6 @@ object (self)
| CInt i -> Format.pp_print_string f (Big_int.string_of_big_int i)
| CFloat float -> Format.pp_print_float f float
| CString s -> pp f "\"%s\"" (QmlPrint.escaped_string s)
- | CChar int -> try pp f "%C" (Char.chr int) with Invalid_argument _ -> pp f "'\\u%#x'" int
method field f s =
Format.pp_print_string f (
@@ -217,7 +216,6 @@ object (self)
| TyInt -> "int"
| TyFloat -> "float"
| TyString -> "string"
- | TyChar -> "char"
)
method rowvar f _ = Format.pp_print_string f "..."
method colvar f _ = Format.pp_print_string f "..."
View
@@ -238,7 +238,6 @@ struct
| SA.TyInt -> QA.TyInt
| SA.TyFloat -> QA.TyFloat
| SA.TyString -> QA.TyString
- | SA.TyChar -> QA.TyChar
and ty x = ty_node (fst x)
and ty_node = function
@@ -351,11 +350,6 @@ struct
Pervasives.max_int)
| SA.CFloat f -> QA.Float f
| SA.CString s -> QA.String s
- | SA.CChar i ->
- try QA.Char (Char.chr i)
- with Invalid_argument "Char.chr" ->
- let context = OpaError.Context.annot opa_annot in
- OpaError.error context "Character %d is not representable@." i
let ident = Arg.exprident
View
@@ -77,7 +77,6 @@ type const_expr_node =
| CFloat of float
(* | CFixed of fixed*)(**This is actually a user-level data structure.*)
| CString of string (**A UTF-8 encoded string.*)
- | CChar of int (**A unicode character, represented by its number.*)
and const_expr = const_expr_node label (* cf libqmlcompil/qmlLoc.ml *)
@@ -202,7 +201,6 @@ and const_ty_node =
| TyInt
| TyFloat
| TyString
- | TyChar
and 'ident rowvar = Rowvar of 'ident
and 'ident colvar = Colvar of 'ident
@@ -150,7 +150,6 @@ struct
let string ?(label=w()) () = (TypeConst TyString, c label)
let int ?(label=w()) () = (TypeConst TyInt, c label)
let float ?(label=w()) () = (TypeConst TyFloat, c label)
- let char ?(label=w()) () = (TypeConst TyChar, c label)
let bool ?label () = name ?label Opacapi.Types.bool
end
@@ -207,8 +206,6 @@ struct
let big_int ?label i = constant ?label (CInt i)
let int ?label i = big_int ?label (Big_int.big_int_of_int i)
let bool ?label b = if b then true_ ?label () else false_ ?label ()
- let unicode_char ?label code = constant ?label (CChar code)
- let char ?label c = unicode_char ?label (Char.code c)
let ident ?(label=w()) i = (Ident i, c label)
let var = ident
@@ -65,7 +65,6 @@ sig
val string : ?label:annot -> unit -> ident ty
val int : ?label:annot -> unit -> ident ty
val float : ?label:annot -> unit -> ident ty
- val char : ?label:annot -> unit -> ident ty
val bool : ?label:annot -> unit -> ident ty
end
@@ -118,8 +117,6 @@ sig
val float : ?label:annot -> float -> (ident, _) expr
val big_int : ?label:annot -> Big_int.big_int -> (ident, _) expr
val int : ?label:annot -> int -> (ident, _) expr
- val unicode_char : ?label:annot -> int -> (ident, _) expr
- val char : ?label:annot -> char -> (ident, _) expr
val ident : ?label:annot -> ident -> (ident, _) expr
val var : ?label:annot -> ident -> (ident, _) expr
@@ -291,12 +291,6 @@ struct
| (Const (CString s), _) -> Some s
| _ -> None
let get_string x = exn_of_opt Exit get_string_opt x
-
- let get_char_opt e =
- match Coerce.remove e with
- | (Const (CChar c), _) -> Some c
- | _ -> None
- let get_char x = exn_of_opt Exit get_char_opt x
end
module Datatype =
@@ -376,7 +370,6 @@ struct
| CInt _ -> TyInt
| CFloat _ -> TyFloat
| CString _ -> TyString
- | CChar _ -> TyChar
let type_of x = type_of_node (fst x)
end
@@ -1003,7 +1003,6 @@ opa_in_braces <- lbrace expr:e rbrace {{ e }}
const <- float:f {{ CFloat f }}
/ int:i {{ CInt (Big_int.big_int_of_int i) }}
/ string:s {{ CString s }}
- / char:c {{ CChar c}}
(**
{6 Types}
@@ -1018,7 +1017,6 @@ type_const = deco just_type_const;
just_type_const <- (=exact_ident("int")) {{TypeConst TyInt}}
/ (=exact_ident("float")) {{TypeConst TyFloat}}
/ (=exact_ident("string")) {{TypeConst TyString}}
- / (=exact_ident("char")) {{TypeConst TyChar}}
(**
{7 Type variables}
Oops, something went wrong.

0 comments on commit 0ab80d5

Please sign in to comment.