Fix literal bytes

This commit is contained in:
Tom Jack 2020-01-09 16:50:27 -06:00
parent e67e2098c2
commit 1b0ed4d4de
8 changed files with 8 additions and 8 deletions

View File

@ -378,7 +378,7 @@ let mk_string lexeme region =
let mk_bytes lexeme region = let mk_bytes lexeme region =
let norm = Str.(global_replace (regexp "_") "" lexeme) in let norm = Str.(global_replace (regexp "_") "" lexeme) in
let value = lexeme, Hex.of_string norm let value = lexeme, `Hex norm
in Bytes Region.{region; value} in Bytes Region.{region; value}
let mk_int lexeme region = let mk_int lexeme region =

View File

@ -443,7 +443,7 @@ let mk_string lexeme region = String Region.{region; value=lexeme}
let mk_bytes lexeme region = let mk_bytes lexeme region =
let norm = Str.(global_replace (regexp "_") "" lexeme) in let norm = Str.(global_replace (regexp "_") "" lexeme) in
let value = lexeme, Hex.of_string norm let value = lexeme, `Hex norm
in Bytes Region.{region; value} in Bytes Region.{region; value}
type int_err = Non_canonical_zero type int_err = Non_canonical_zero

View File

@ -361,7 +361,7 @@ let mk_string lexeme region = String Region.{region; value=lexeme}
let mk_bytes lexeme region = let mk_bytes lexeme region =
let norm = Str.(global_replace (regexp "_") "" lexeme) in let norm = Str.(global_replace (regexp "_") "" lexeme) in
let value = lexeme, Hex.of_string norm let value = lexeme, `Hex norm
in Bytes Region.{region; value} in Bytes Region.{region; value}
let mk_int lexeme region = let mk_int lexeme region =

View File

@ -356,7 +356,7 @@ let rec simpl_expression :
return @@ e_literal ~loc Literal_unit return @@ e_literal ~loc Literal_unit
| EBytes x -> | EBytes x ->
let (x , loc) = r_split x in let (x , loc) = r_split x in
return @@ e_literal ~loc (Literal_bytes (Bytes.of_string @@ fst x)) return @@ e_literal ~loc (Literal_bytes (Hex.to_bytes @@ snd x))
| ETuple tpl -> simpl_tuple_expression @@ (npseq_to_list tpl.value) | ETuple tpl -> simpl_tuple_expression @@ (npseq_to_list tpl.value)
| ERecord r -> | ERecord r ->
let (r , loc) = r_split r in let (r , loc) = r_split r in

View File

@ -326,7 +326,7 @@ let rec simpl_expression (t:Raw.expr) : expr result =
return @@ e_literal ~loc Literal_unit return @@ e_literal ~loc Literal_unit
| EBytes x -> | EBytes x ->
let (x' , loc) = r_split x in let (x' , loc) = r_split x in
return @@ e_literal ~loc (Literal_bytes (Bytes.of_string @@ fst x')) return @@ e_literal ~loc (Literal_bytes (Hex.to_bytes @@ snd x'))
| ETuple tpl -> | ETuple tpl ->
let (tpl' , loc) = r_split tpl in let (tpl' , loc) = r_split tpl in
simpl_tuple_expression ~loc @@ npseq_to_list tpl'.inside simpl_tuple_expression ~loc @@ npseq_to_list tpl'.inside

View File

@ -1,5 +1,5 @@
function concat_op (const s : bytes) : bytes is function concat_op (const s : bytes) : bytes is
begin skip end with bytes_concat(s , ("7070" : bytes)) begin skip end with bytes_concat(s , 0x7070)
function slice_op (const s : bytes) : bytes is function slice_op (const s : bytes) : bytes is
begin skip end with bytes_slice(1n , 2n , s) begin skip end with bytes_slice(1n , 2n , s)

View File

@ -1,5 +1,5 @@
let concat_op (s : bytes) : bytes = let concat_op (s : bytes) : bytes =
Bytes.concat s ("7070" : bytes) Bytes.concat s 0x7070
let slice_op (s : bytes) : bytes = let slice_op (s : bytes) : bytes =
Bytes.slice 1n 2n s Bytes.slice 1n 2n s

View File

@ -1,4 +1,4 @@
let concat_op = (s: bytes): bytes => Bytes.concat(s, "7070": bytes); let concat_op = (s: bytes): bytes => Bytes.concat(s, 0x7070);
let slice_op = (s: bytes): bytes => Bytes.slice(1n, 2n, s); let slice_op = (s: bytes): bytes => Bytes.slice(1n, 2n, s);