python_etf icon indicating copy to clipboard operation
python_etf copied to clipboard

Can't parse Bin syntax properly

Open Hattes opened this issue 7 years ago • 3 comments

It seems that this library only handles Bins that only contain a string, but there are other cases, as specified here: http://erlang.org/doc/programming_examples/bit_syntax.html

Specifically I wasn't able to parse this expression today: <<1,2,3,4,5,6,7,8>>.

Hattes avatar Apr 13 '18 10:04 Hattes

Thanks for reporting this! please check this update https://github.com/machinezone/python_etf/commit/9337b6385d63b79513ed5411b81491bd12a7a3cf

the following test was added:

eq_(decode('<<>>.'), [('')])
eq_(decode('<<"ohai">>.'), [('ohai')])
eq_(decode('<<"ohai", "ohai">>.'), [('ohaiohai')])
eq_(decode('<<97, 98, 99>>.'), [('abc')])

parsifal-47 avatar Apr 16 '18 09:04 parsifal-47

Thanks, that does indeed cover my use case. However it doesn't quite cover all the different forms of bin syntax, as explained in the link I gave. Note the Size and TypeSpecifierList terms that are described there.

Hattes avatar Apr 20 '18 06:04 Hattes

but we don't have variables and matching, only constants are allowed, I'm not completely sure that 1:4/little-signed-integer-unit:8 would be useful

parsifal-47 avatar Apr 20 '18 09:04 parsifal-47