Binaries Mapping

Binaries Mapping

Binaries in Hamler are imported from Erlang. The Bit Syntax Expressions in Erlang are defined as below:

<<>>
<<E1,...,En>>

Ei ::= Value
     | Value ":" Size
     | Value "/" TypeSpecifierList
     | Value ":" Size "/" TypeSpecifierList

The Bit Syntax in Hamler is a bit different from Erlang, that ‘/‘ is replaced with ‘:’:

<<>>
<<E1,...,En>>
Ei ::= Value
    |  Value ":" Size
    |  Value ":" TypeSpecifierList
    |  Value ":" Size ":" TypeSpecifierList

Binaries in Hamler:

<<127,0,0,1>>
<<"ABC">>

-- Binary Pattern Match
<<bigI:16:Big-Unsigned-Integer>> = <<1,2>>
<<litI:16:Little-Signed-Integer>> = <<1,2>>

Binaries in Erlang:

<<127,0,0,1>>
<<"ABC">>
<<1:16,2:4,3:4>>

-- Binary Pattern Match
<<X:3,Y:5,Z:8>> = <<1,0>>
<<BigI:16/big-unsigned-integer>> = <<1,2>>
<<LitI:16/little-signed-integer>> = <<1,2>>