<div dir="ltr"><div><div><div><div>Hello,<br></div>Thanks again  Adrain. In GTP protocol, I have some data (array of Information Element (IE)). Each IE  has around of 4 bytes. The data in the first byte is like that.<br></div>In this case, I should use all times mask and shift the bits.<br><br></div>Best regards<br></div>Sothy  <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 30, 2017 at 5:38 PM, Adrian Thurston <span dir="ltr"><<a href="mailto:thurston@colm.net" target="_blank">thurston@colm.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
    
<div>Looks like you accept all bytes so you don't really need ragel for that. Just need to mask and shift the bits.</div><div><br></div><div><br></div><div><br></div><div id="m_2842086865337638634composer_signature"><div style="font-size:9px">--</div><div style="font-size:9px">Adrian D. Thurston</div><div style="font-size:9px">Chief Scientist</div><div style="font-size:9px">Colm Networks</div><div style="font-size:9px"><a href="http://colm.net" target="_blank">http://colm.net</a></div><div></div></div><div><div class="h5"><br><br>-------- Original message --------<br>From: sothy shan <<a href="mailto:sothy.e98@gmail.com" target="_blank">sothy.e98@gmail.com</a>> <br>Date: 2017-09-30  6:43 AM  (GMT-05:00) <br>To: <a href="mailto:ragel@colm.net" target="_blank">ragel@colm.net</a> <br>Subject: Re: [ragel] Binary data and bits <br><br><div dir="ltr"><div><div><div><div><div><div><div>Thanks Adrain,<br><br></div>I am new to Ragel. I have one question. <br></div>One BYTE information: 010 1 1 000<br></div>I need to take firrst three bits into one int, other two bits are two boolean values and other three are together for one int.<br><br></div>How to write grammar for parsing this data?<br><br></div>Thanks for your help.<br><br></div>Best regards<br></div>Sothy<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 29, 2017 at 10:08 PM, Adrian Thurston <span dir="ltr"><<a href="mailto:thurston@colm.net" target="_blank">thurston@colm.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div style="font-size:14pt;font-family:Verdana,Geneva,sans-serif">
<p>Hi Sothy, you need to specify the grammar at the byte level. You can union bit patterns together, however.</p><div><div class="m_2842086865337638634h5">
<p>On 2017-09-27 15:35, sothy shan wrote:</p>
</div></div><blockquote type="cite" style="padding-left:5px;border-left:#1010ff 2px solid;margin-left:5px"><div><div class="m_2842086865337638634h5">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>Hi,</div>
I need to parse 4 bytes of data and some bits of data has valid information.</div>
How can I go with Ragel?</div>
I am going to use Ragel with  C++.<br><br></div>
Best regards</div>
Sothy<br><br></div>
<br>
</div></div><pre>______________________________<wbr>_________________
ragel mailing list
<a href="mailto:ragel@colm.net" target="_blank">ragel@colm.net</a>
<a href="http://www.colm.net/cgi-bin/mailman/listinfo/ragel" target="_blank">http://www.colm.net/cgi-bin/ma<wbr>ilman/listinfo/ragel</a>
</pre>
</blockquote>
</div>
<br>______________________________<wbr>_________________<br>
ragel mailing list<br>
<a href="mailto:ragel@colm.net" target="_blank">ragel@colm.net</a><br>
<a href="http://www.colm.net/cgi-bin/mailman/listinfo/ragel" rel="noreferrer" target="_blank">http://www.colm.net/cgi-bin/ma<wbr>ilman/listinfo/ragel</a><br>
<br></blockquote></div><br></div>
</div></div></div><br>______________________________<wbr>_________________<br>
ragel mailing list<br>
<a href="mailto:ragel@colm.net">ragel@colm.net</a><br>
<a href="http://www.colm.net/cgi-bin/mailman/listinfo/ragel" rel="noreferrer" target="_blank">http://www.colm.net/cgi-bin/<wbr>mailman/listinfo/ragel</a><br>
<br></blockquote></div><br></div>