Change PVAL_num to PVAL_int and remove non-int literal forms.
This commit is contained in:
@@ -303,7 +303,7 @@ and parse_eq_pexp_opt (ps:pstate) : Ast.pexp option =
|
|||||||
|
|
||||||
type pval =
|
type pval =
|
||||||
PVAL_str of string
|
PVAL_str of string
|
||||||
| PVAL_num of int64
|
| PVAL_int of int64
|
||||||
| PVAL_bool of bool
|
| PVAL_bool of bool
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ let unexpected_val (expected:string) (v:pval) =
|
|||||||
let got =
|
let got =
|
||||||
match v with
|
match v with
|
||||||
PVAL_str s -> "str \"" ^ (String.escaped s) ^ "\""
|
PVAL_str s -> "str \"" ^ (String.escaped s) ^ "\""
|
||||||
| PVAL_num i -> "num " ^ (Int64.to_string i)
|
| PVAL_int i -> "int " ^ (Int64.to_string i)
|
||||||
| PVAL_bool b -> if b then "bool true" else "bool false"
|
| PVAL_bool b -> if b then "bool true" else "bool false"
|
||||||
in
|
in
|
||||||
(* FIXME (issue #70): proper error reporting, please. *)
|
(* FIXME (issue #70): proper error reporting, please. *)
|
||||||
@@ -494,9 +494,9 @@ and eval_pexp (env:env) (exp:Ast.pexp) : pval =
|
|||||||
(Ast.BINOP_add, PVAL_str az, PVAL_str bz) ->
|
(Ast.BINOP_add, PVAL_str az, PVAL_str bz) ->
|
||||||
PVAL_str (az ^ bz)
|
PVAL_str (az ^ bz)
|
||||||
| _ ->
|
| _ ->
|
||||||
let av = (need_num av) in
|
let av = (need_int av) in
|
||||||
let bv = (need_num bv) in
|
let bv = (need_int bv) in
|
||||||
PVAL_num
|
PVAL_int
|
||||||
begin
|
begin
|
||||||
match bop with
|
match bop with
|
||||||
Ast.BINOP_add -> Int64.add av bv
|
Ast.BINOP_add -> Int64.add av bv
|
||||||
@@ -515,7 +515,7 @@ and eval_pexp (env:env) (exp:Ast.pexp) : pval =
|
|||||||
Ast.UNOP_not ->
|
Ast.UNOP_not ->
|
||||||
PVAL_bool (not (eval_pexp_to_bool env a))
|
PVAL_bool (not (eval_pexp_to_bool env a))
|
||||||
| Ast.UNOP_neg ->
|
| Ast.UNOP_neg ->
|
||||||
PVAL_num (Int64.neg (eval_pexp_to_num env a))
|
PVAL_int (Int64.neg (eval_pexp_to_int env a))
|
||||||
| _ -> bug () "Unexpected unop in Cexp.eval_pexp"
|
| _ -> bug () "Unexpected unop in Cexp.eval_pexp"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -530,10 +530,8 @@ and eval_pexp (env:env) (exp:Ast.pexp) : pval =
|
|||||||
| Ast.PEXP_lit (Ast.LIT_bool b) ->
|
| Ast.PEXP_lit (Ast.LIT_bool b) ->
|
||||||
PVAL_bool b
|
PVAL_bool b
|
||||||
|
|
||||||
| Ast.PEXP_lit (Ast.LIT_int i)
|
| Ast.PEXP_lit (Ast.LIT_int i) ->
|
||||||
| Ast.PEXP_lit (Ast.LIT_uint i)
|
PVAL_int i
|
||||||
| Ast.PEXP_lit (Ast.LIT_mach_int (_, i)) ->
|
|
||||||
PVAL_num i
|
|
||||||
|
|
||||||
| Ast.PEXP_str s ->
|
| Ast.PEXP_str s ->
|
||||||
PVAL_str s
|
PVAL_str s
|
||||||
@@ -546,13 +544,13 @@ and eval_pexp_to_str (env:env) (exp:Ast.pexp) : string =
|
|||||||
PVAL_str s -> s
|
PVAL_str s -> s
|
||||||
| v -> unexpected_val "str" v
|
| v -> unexpected_val "str" v
|
||||||
|
|
||||||
and need_num (cv:pval) : int64 =
|
and need_int (cv:pval) : int64 =
|
||||||
match cv with
|
match cv with
|
||||||
PVAL_num n -> n
|
PVAL_int n -> n
|
||||||
| v -> unexpected_val "num" v
|
| v -> unexpected_val "int" v
|
||||||
|
|
||||||
and eval_pexp_to_num (env:env) (exp:Ast.pexp) : int64 =
|
and eval_pexp_to_int (env:env) (exp:Ast.pexp) : int64 =
|
||||||
need_num (eval_pexp env exp)
|
need_int (eval_pexp env exp)
|
||||||
|
|
||||||
and eval_pexp_to_bool (env:env) (exp:Ast.pexp) : bool =
|
and eval_pexp_to_bool (env:env) (exp:Ast.pexp) : bool =
|
||||||
match eval_pexp env exp with
|
match eval_pexp env exp with
|
||||||
@@ -655,7 +653,7 @@ let parse_crate_file
|
|||||||
ident) ps)
|
ident) ps)
|
||||||
| Some (PVAL_bool b) -> LIT_BOOL b
|
| Some (PVAL_bool b) -> LIT_BOOL b
|
||||||
| Some (PVAL_str s) -> LIT_STR s
|
| Some (PVAL_str s) -> LIT_STR s
|
||||||
| Some (PVAL_num n) -> LIT_INT n
|
| Some (PVAL_int n) -> LIT_INT n
|
||||||
in
|
in
|
||||||
let ps =
|
let ps =
|
||||||
make_parser crate_cache sess get_mod get_cenv_tok
|
make_parser crate_cache sess get_mod get_cenv_tok
|
||||||
|
|||||||
Reference in New Issue
Block a user