You’d probably need to build a lexer/parser that can understand this
subset
of C. I’ve never successfully built a parser, it’s hard, but check out
gems
like Treetop and Citrus. They should allow you to build an abstract
syntax
tree that represents the code. Then you’ll probably have to analyze the
AST
to do some sort of type determining (ie if I pass it a string, then I
know
its argument has type of string) check out Hindley–Milner type system - Wikipedia for that purpose.
Once
you’ve got all of that, just write it back out, only when writing it
out,
use the C syntax instead of the Ruby syntax.
Other thoughts:
Racc might also be useful, but looked pretty formidable to me when I
tried to play with it.