Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Flex / Yacc sources for C parser

Reply
Thread Tools

Flex / Yacc sources for C parser

 
 
Wolfgang Draxinger
Guest
Posts: n/a
 
      12-25-2007
I'm currently working on a laguange similair in concept to Vala
(google for it on the Gnome project site). A (very) high level
language is translated into intermediary C, which is then
compiled to target.

I want to be able to "include" C headers, so that I don't have to
write bindings. That however means, that I have to parse them. I
could now of course write my own Flex / Yacc code, but I
presume, that there are ready to use C parser frameworks, which
can be filled with own code. Mostly it's about to get the
symbols. Preprocessor macros will be handed down into the
generated C code, but my compiler shall understand them to
enable compile time static type checking.

Wolfgang Draxinger
--
E-Mail address works, Jabber: http://www.velocityreviews.com/forums/(E-Mail Removed), ICQ: 134682867

 
Reply With Quote
 
 
 
 
santosh
Guest
Posts: n/a
 
      12-25-2007
Wolfgang Draxinger wrote:

> I'm currently working on a laguange similair in concept to Vala
> (google for it on the Gnome project site). A (very) high level
> language is translated into intermediary C, which is then
> compiled to target.
>
> I want to be able to "include" C headers, so that I don't have to
> write bindings. That however means, that I have to parse them. I
> could now of course write my own Flex / Yacc code, but I
> presume, that there are ready to use C parser frameworks, which
> can be filled with own code. Mostly it's about to get the
> symbols. Preprocessor macros will be handed down into the
> generated C code, but my compiler shall understand them to
> enable compile time static type checking.


Try lcc, which is touted as a re-targetable C compiler. It's often
praised for code clarity and modularity, so you may be able to rip out
the relevant pieces for your use.

<http://www.cs.princeton.edu/software/lcc/>
<http://www.kernel.org/pub/software/devel/sparse/>

 
Reply With Quote
 
 
 
 
George Peter Staplin
Guest
Posts: n/a
 
      12-25-2007
Wolfgang Draxinger wrote:
> I'm currently working on a laguange similair in concept to Vala
> (google for it on the Gnome project site). A (very) high level
> language is translated into intermediary C, which is then
> compiled to target.
>
> I want to be able to "include" C headers, so that I don't have to
> write bindings. That however means, that I have to parse them. I
> could now of course write my own Flex / Yacc code, but I
> presume, that there are ready to use C parser frameworks, which
> can be filled with own code. Mostly it's about to get the
> symbols. Preprocessor macros will be handed down into the
> generated C code, but my compiler shall understand them to
> enable compile time static type checking.
>
> Wolfgang Draxinger


I managed to produce a C99 (mostly GNUC compatible) grammar via some C89
samples on the net.

http://c-faq.com/resources/grammars.html

See also:
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html

That page has a lexer for C, and CPP.

GNUC is difficult to parse entirely and properly with Yacc-based
parsers. GNU's C compiler doesn't seem to use Yacc as much as the
typical compiler (lots of hand written parsing from what I saw).



George
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Did using Yacc in the Ruby parser require a lot of messy hacking? Robert Ruby 2 04-23-2008 09:22 AM
Does Perl use a special hand-made parser, or does it use Yacc or someother pre-packaged tool? Robert Perl Misc 3 04-17-2008 12:12 AM
Does Python use a special home-made parser, or does it use Yacc? Robert Python 1 04-16-2008 07:56 PM
flex and yacc c/c++ C++ 1 04-10-2007 04:45 AM
Re: [OT, welcome msg] Yacc/G++ parser probs. Mike Wahler C++ 2 07-08-2003 08:39 PM



Advertisments