Why don't you just use Bison/Flex for that task?

As far as i know, most Ruby Parser Generators compile to Ruby. (for  
example DHAKA)
The resulting (compiled) statemachine is not very readable.

And even if you write the parser by hand, I don't have high hopes that  
a translation to "readable" C-Code
is easily possible.[1]

So if speed is an issue, don't code it by hand but code it with a tool  
that is right for the job. Thats neither C
nor Ruby.
If speed is not that much of an issue, write you parser in one of the  
available libraries and measure wether
it fits your needs. Thats the only way to find out.

Regards,
Florian Gilcher

[1]: Whats that anyway? ;)

On Oct 27, 2008, at 8:44 PM, Axel Etzold wrote:

> Dear all,
>
> I am looking for a (semi-)automatic conversion of a Ruby script to C  
> or C++, so
> that readable source code for a human C/C++ programmer is produced.
>
> The program should read in text from a file as a string, split and  
> search it using regular expressions,
> convert some numbers into floats and perform some calculations on them
> (the latter part is done using some existing C code).
>
> The text file to be read has  this structure:
>
> --------------------
> P1
> P2 23
> P4 27
> --------------------
> P2
> P3 1
> P5 457
> P6 3
> P377 56
> --------------------
>
> Thus, P1 is a starting point and the distance to point P2 is 23 etc.
> There is a varying number of entries in each of the parts separated by
> dashes.
> Is there some gem that would allow me to write a nice short
> Ruby script doing the above-mentioned manipulations and translate it  
> for me into
> readable C/C++, such that I'd have to specify as few as possible  
> size and variable
> type declarations ?
> I have about a hundred thousand points and relative distances, so  
> speed could matter here ...
> and I'd have a hard time defending the use of a scripting language  
> with the people
> I am collaborating here.
>
>
> Thank you very much!
>
> Best regards,
>
> Axel
>
>
> -- 
> "Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
> Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail
>