[ragel-users] Little-endian / big-endian (alphabetic char)

thurston at complang.org thurston at complang.org
Wed Aug 17 03:04:24 UTC 2011


Unfortunately, specifying certain low bits is a problem for the definition language. You end up needing to write 0 or 2 or 4 or 6 ... 

Underlying implementation can do it, but it's not an efficient implementation. 
High bits are easy for both language and implementation: 0 .. 127. 

-Adrian
------Original Message------
From: Iñaki Baz Castillo
Sender: ragel-users-bounces at complang.org
To: ragel-users at complang.org
ReplyTo: ragel-users at complang.org
Subject: [ragel-users] Little-endian / big-endian (alphabetic char)
Sent: Aug 15, 2011 1:43 PM

Hi, trying to make a parser for a binary protocol:

  http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10#section-4.2

I get the following case:

Byte number 2 in the protocol message is as follows:

- bit 0:       FIN bit
- bits 1-7:   Payload length (means 2^N bytes).

I receive the data from the network. The data is read from a Ruby
server and then passed to a C parser built with Ragel. So within Ragel
code (actions) I must check if bit 0 (FIN) is 1 or 0.
The Ragel grammar alphabetic is "char", so I can check whether such
char is > some value (which means that first bit is 0 or 1, so I get
FIN bit value).

The question is: how can I know if I'm cheking the byte in big-endian
or in litte-endian? Probably this question makes no sense at all since
data was already received by the Ruby server, so it has been converted
to host byte order, so I must not care about it, am I right?


Thanks a lot.


-- 
Iñaki Baz Castillo
<ibc at aliax.net>

_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users
_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users



More information about the ragel-users mailing list