1. c header file parser
- Posted by bugmagnet Oct 13, 2015
- 1850 views
Does Euphoria have the equivalent of FreePascal's h2pas utility?
When I'm not doing Euphoria I'm doing GnuCOBOL (well, that and some other things as well) and am trying to find some code I can adapt for a GnuCOBOL project I'm doing which needs some C headers morphed into COBOL.
bugmagnet
2. Re: c header file parser
- Posted by petelomax Oct 13, 2015
- 1760 views
Does Euphoria have the equivalent of FreePascal's h2pas utility?
When I'm not doing Euphoria I'm doing GnuCOBOL (well, that and some other things as well) and am trying to find some code I can adapt for a GnuCOBOL project I'm doing which needs some C headers morphed into COBOL.
bugmagnet
I wrote cffi.e not too long ago, but rather than take a whole .h file you have to copy small snippets of interest, is that any use?
Easiest way to get it is https://bitbucket.org/petelomax/phix then navigate source -> builtins -> cffi.e -> raw
You can also get source -> docs -> phix -> phix.chm which I've just pushed, if you're looking for some documentation for it.
Pete
3. Re: c header file parser
- Posted by ghaberek (admin) Oct 13, 2015
- 1688 views
Parsing C is hard. A lot of the syntax in C depends on its context.
typedef int foo; foo * bar; // 'bar' is a pointer to a variable of type 'foo' int foo, baz, bar; baz = foo * bar; // baz equals foo times bar
So the expression foo * bar changes meaning based on whether foo is a type or a variable.
It's also really hard to parse macros correctly. Static macros, which are typically used as constants in C, are pretty simple to translate. But some macros merely exist and contain no value, and those should translate to a with define statement for use with ifdef. There are also macro functions, which, among other factors, can get horribly complicated because of the way they can concatenate and "stringify" their parameter names.
-Greg
4. Re: c header file parser
- Posted by bugmagnet Oct 13, 2015
- 1677 views
Parsing C is hard. A lot of the syntax in C depends on its context.
Believe me, I know!
And it's the Win32 headers for OLE. Ewwwwww.....
bugmagnet
5. Re: c header file parser
- Posted by SDPringle Oct 16, 2015
- 1603 views
I have something like this but it relies on joy.e which has never been released. I will first have to release joy.e.
6. Re: c header file parser
- Posted by SDPringle Oct 17, 2015
- 1587 views
I have uploaded my abandoned work at
https://github.com/shawnpringle/h2e
My joy library is a dependency is now available at: