[ragel-users] How to get a C "int" value?

Iñaki Baz Castillo ibc at aliax.net
Fri Dec 4 00:39:06 UTC 2009


Hi, for sure I miss something very easy...
  
  alphtype unsigned char;
  DIGIT    = "0".."9";
  position = ( DIGIT )+ >start_position %end_position;

I just want to get the 'position' numeric value into a 'position' int C 
variable, so I try:

  int *position_pointer = NULL;
  int position;
  [...]
  action start_position  { position_pointer = p; }
  action end_position    { position = *position_pointer; }

However, even if the parser works perfectly I get these values when printing 
the variable position with "printf("position = %i\n", position);".

This is the mapping I get between the numbers I pass to the parser and the 
value of obtained "position" C int variable:

  1 => 1681204529
  2 => 1681204530
  3 => 1681204531

So obviously I do somethign wrong when taking the bytes for the integer. Any 
help please?
Thanks a lot.


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




More information about the ragel-users mailing list