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

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


El Viernes, 4 de Diciembre de 2009, Iñaki Baz Castillo escribió:
> 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

Ok, I understand: what I'm getting from Ragel are chars, not int values.
I must convert the string representing a integer to a real int variable, but 
that's out of the Ragel's scope :)


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




More information about the ragel-users mailing list