Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby/Python - generating and parsing C/C++ code

I need to generate C structs and arrays from data stored in a db table, and alternately parse similar info. I use both ruby and python for this task, and was wondering if anyone heard of a module/lib that handles this for either/both languages? I could do this on my own with some string processing, but wanted to check if there's a known and tested parser out there that people know of. thanks.

like image 698
sa125 Avatar asked Mar 02 '26 16:03

sa125


2 Answers

Check out open-source software tool SWIG (Simplified Wrapper and Interface Generator). First sentence of the intro on the webpage:

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of languages including common scripting languages such as Perl, PHP, Python, Tcl and Ruby.

Very mature (initial release - February 1996 according to Wikipedia) and there are lots of tutorials, documentation, and help.

like image 174
martineau Avatar answered Mar 05 '26 05:03

martineau


There is a basic C struct parser here on the pyparsing wiki. Pyparsing is a Python module for creating parsers by assembling separate parsing building blocks together. (No help on the Ruby part of the question, though.)

like image 32
PaulMcG Avatar answered Mar 05 '26 05:03

PaulMcG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!