1. c header file parser

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

new topic     » topic index » view message » categorize

2. Re: c header file parser

bugmagnet said...

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: c header file parser

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: c header file parser

ghaberek said...

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: c header file parser

I have something like this but it relies on joy.e which has never been released. I will first have to release joy.e.

new topic     » goto parent     » topic index » view message » categorize

6. Re: c header file parser

I have uploaded my abandoned work at

https://github.com/shawnpringle/h2e

My joy library is a dependency is now available at:

http://github.com/shawnpringle/joy

and also http://www.RapidEuphoria.com/uploads/joy.tar.gz

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu