Re: about H file parser for standard C
- From: "Christian Ehlscheid" <christian.nospam@xxxxxx>
- Date: Fri, 20 May 2005 07:57:27 +0200
Hello,
> I think you all have the experience to do the following things:
this is not an easy thing to do, and i think very few people here know how
to do it cause it's not a job
of an application developer, what you described is the job of a compiler
writer / language designer ..
if you want to do it yourself you have to make yourself familiar with
regular expressions and grammar parsing of languages (using BNF)
there're some tools that can assist you with this, namely
flex (gnu project) - which is able to generate a C program out of a regular
expression specification
and
bison (also from gnu) - which is able to generate a language parser out of a
grammar (BNF) specification ..
there are more tools for language parsing ..
but these were the two i used to generate an C struct source to source
translator for MS Visual FoxPro (an interpreted xBase language)
but it has taken me about 6 months, and about 3 months of studying first to
get an overview how a compiler works under the hood, and it was far from
beeing easy ...
and this tool even not has the features you'll need because it can't handle
complete header files .. and also doesn't provide a C preprocessor ... so
one has to substitute the preprocessor definition by hand with their actual
values ..
you may come around the preprocessor issue by
instructing your C preprocessor to store the preprocessed headers to other
files
another way to do it might be to automate the MS VC development IDE,
the IDE has a object hierarchy with which you can access the actual code it
has parsed and as long as i know it is COM automatable so you may be able to
write some algorithms to traverse each structure object and output the
according C code
this is definitly not a shareware kind of app, and your project has to be
BIG so the time you invest to implement it yourself pays off in the end ..
Regards
Christian
.
- Follow-Ups:
- Re: about H file parser for standard C
- From: Jerry Coffin
- Re: about H file parser for standard C
- From: Astroller
- Re: about H file parser for standard C
- References:
- about H file parser for standard C
- From: Astroller
- about H file parser for standard C
- Prev by Date: Re: How to use win32 api to show desktop
- Next by Date: Re: about H file parser for standard C
- Previous by thread: Re: about H file parser for standard C
- Next by thread: Re: about H file parser for standard C
- Index(es):
Relevant Pages
|